Página 1 de 1

Desarrollando canal para Xhamster...

Publicado: 05 Oct 2011, 22:42
por boludiko
Hola a todos, estoy desarrollando el nuevo canal de xhamster.. el tema es que cuando uso el buscador recibo esta salida:


23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] cachePage url=http://xhamster.com/search.php?q=sexo+duro&qcat=video
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] MODO_CACHE=2 (no cachear)
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] downloadpage
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] url=http://xhamster.com/search.php?q=sexo+duro&qcat=video
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] post=None
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] ficherocookies=/Users/pablognu/Library/Application Support/XBMC/userdata/addon_data/plugin.video.pelisalacarta/cookies.lwp
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] Importando cookielib
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] cookielib disponible
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] Hay cookies
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] opener usando urllib2 (cookielib)
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] petición GET
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] ---------------------------
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] header=User-Agent
23:40:12 T:2955522048 M:1351204864 NOTICE: [scrapertools.py] ---------------------------
23:40:12 T:2955522048 M:1347653632 ERROR: Error Type: exceptions.ValueError
23:40:12 T:2955522048 M:1347653632 ERROR: Error Contents: timestamp out of range for platform time_t
23:40:12 T:2955522048 M:1347620864 ERROR: Traceback (most recent call last):
File "/Users/pablognu/Library/Application Support/XBMC/addons/plugin.video.pelisalacarta/default.py", line 27, in ?
launcher.run()
File "/Users/pablognu/Library/Application Support/XBMC/addons/plugin.video.pelisalacarta/platform/xbmc/launcher.py", line 224, in run
itemlist = channel.search(item,tecleado)
File "/Users/pablognu/Library/Application Support/XBMC/addons/plugin.video.pelisalacarta/pelisalacarta/channels/xhamster.py", line 39, in search
return buscar(item)
File "/Users/pablognu/Library/Application Support/XBMC/addons/plugin.video.pelisalacarta/pelisalacarta/channels/xhamster.py", line 45, in buscar
data = scrapertools.cache_page(item.url)
File "/Users/pablognu/Library/Application Support/XBMC/addons/plugin.video.pelisalacarta/core/scrapertools.py", line 40, in cache_page
return cachePage(url,post,headers,modo_cache)
File "/Users/pablognu/Library/Application Support/XBMC/addons/plugin.video.pelisalacarta/core/scrapertools.py", line 69, in cachePage
data = downloadpage(url,post,headers)
File "/Users/pablognu/Library/Application Support/XBMC/addons/plugin.video.pelisalacarta/core/scrapertools.py", line 402, in downloadpage
cj.save(ficherocookies)
File "../Python/Lib/_LWPCookieJar.py", line 88, in save
f.write(self.as_lwp_str(ignore_discard, ignore_expires))
File "../Python/Lib/_LWPCookieJar.py", line 74, in as_lwp_str
r.append("Set-Cookie3: %s" % lwp_cookie_str(cookie))
File "../Python/Lib/_LWPCookieJar.py", line 33, in lwp_cookie_str
if cookie.expires: h.append(("expires",
File "../Python/Lib/cookielib.py", line 90, in time2isoz
year, mon, mday, hour, min, sec = time.gmtime(t)[:6]
ValueError: timestamp out of range for platform time_t
23:40:12 T:2892935872 M:1347526656 ERROR: GetDirectory - Error getting plugin://plugin.video.pelisalacarta/?channel=xhamster&action=search&category=xhamster&title=Buscar&url=http%3A%2F%2Fxhamster.com%2Fsearch.php%3Fq%3D%25s%26qcat%3Dvideo&thumbnail=&plot=&extradata=&Serie=&show=
23:40:12 T:2892935872 M:1347526656 ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.pelisalacarta/?channel=xhamster&action=search&category=xhamster&title=Buscar&url=http%3A%2F%2Fxhamster.com%2Fsearch.php%3Fq%3D%25s%26qcat%3Dvideo&thumbnail=&plot=&extradata=&Serie=&show=) failed

El codigo encargado del buscador es el siguiente:


def mainlist(item):
logger.info("[xhamster.py] mainlist")
itemlist = []
itemlist.append( Item(channel=CHANNELNAME, action="videos" , title="Útimos videos" , url="http://www.xhamster.com/"))
itemlist.append( Item(channel=CHANNELNAME, action="listcategorias" , title="Listado Categorias"))
itemlist.append( Item(channel=CHANNELNAME, action="search" , title="Buscar", url="http://xhamster.com/search.php?q=%s&qcat=video"))
return itemlist

# REALMENTE PASA LA DIRECCION DE BUSQUEDA
def search(item,texto):
logger.info("[xhamster.py] search")
itemlist=[]
if item.url=="":
item.url="http://xhamster.com/search.php?q=%s&qcat=video"
tecleado = texto.replace( " ", "+" )
item.url = item.url % texto
return buscar(item)

# SECCION ENCARGADA DE BUSCAR
def buscar(item):
logger.info("[xhamster.py] buscar")
itemlist = []
data = scrapertools.cache_page(item.url)
logger.info(data)
matches = re.compile('<td valign="top" id="video_title">.*?</td>', re.S).findall(data)
itemlist = []
for match in matches:
datos = re.compile('<a href="([^"]+)".*?<img src=\'([^\']+).*?alt="([^"]+)"/>.*?</a>', re.S).findall(match)
for video in datos:
try:
scrapedtitle = unicode( video[2], "utf-8" ).encode("iso-8859-1")
except:
scrapedtitle = video[2]
scrapedurl = urlparse.urljoin( "http://www.xhamster.com" , video[0] )
scrapedthumbnail = video[1]
scrapedplot = ""
# Depuracion
logger.info(video[1])
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
itemlist.append( Item(channel=CHANNELNAME, action="play" , title=scrapedtitle , url=scrapedurl, thumbnail=scrapedthumbnail, plot=scrapedplot, show=scrapedtitle))
return item list

En la cabecera tengo definido esto:

import cookielib
import urlparse,urllib2,urllib,re
import os
import sys

from core import logger
from core import config
from core import scrapertools
from core.item import Item
from servers import server tools

A ver si me podeis echar un cable!

Saludos!

Re: Desarrollando canal para Xhamster...

Publicado: 05 Oct 2011, 22:51
por jesus
Tiene pinta de que tienes corrompido el fichero con las cookies, puesto que da el fallo en la librería de cookies.

Borra el cookies.lwp a ver si así se arregla.

Re: Desarrollando canal para Xhamster...

Publicado: 05 Oct 2011, 22:54
por boludiko
Ya lo he hecho y nada de nada... no consigue arrancar...

Re: Desarrollando canal para Xhamster...

Publicado: 05 Oct 2011, 22:59
por jesus
En scrapertools hay una función para descargar sin cookies, prueba a ver si con eso solucionas el problema.

Si no es un fallo en el fichero de cookies, será un fallo en la librería de las cookies que usa pelisalacarta.

Re: Desarrollando canal para Xhamster...

Publicado: 05 Oct 2011, 23:23
por boludiko
Jesus genio, usando:

data = scrapertools.downloadpageWithoutCookies(item.url)

Consigo que funcione todo a la perfección. Parece que la cookie esa por algún motivo no le gusta, tanto en 3.2 como en 3.2.2.

Ahora ya queda lo divertido xDD.. averiguar el famoso video...

Saludos!

Re: Desarrollando canal para Xhamster...

Publicado: 05 Oct 2011, 23:45
por blablableble
Googleando un poco he encontrado que es debido a bug al procesar una fecha superior a cierto momento del año 2038 , ( 32 bits de segundos desde el 1-1-1970 la hora epoch ), supongo que la fecha de validez de la cookie es mayor a eso, con lo que al intentar procesarla da error.

Según comentan en este link http://ubuntuforums.org/showthread.php?t=1095563 al usar MozillaCookieJar en vez de LWPCookieJar se soluciona, pero no sé si son exactamente iguales de sintaxis, con lo que se podría hacer un cambio sin mas o habria que cambiar más cosas.


Saludos.

Re: Desarrollando canal para Xhamster...

Publicado: 06 Oct 2011, 21:58
por jesus
Pues en principio debería ser tan sencillo como cambiar una por otra, y más teniendo en cuenta que en la última versión todo el código de las cookies está centralizado en el módulos scrapertools.

Me entretuve en limpiar uno por uno todos los conectores de los servidores, para quitar el código de las cookies que habíamos ido copiando de una a otra, y sustituirlo por llamadas a la función "cache_page" que siempre usa cookies.

De todas formas es un cambio jodido porque afecta a todas las descargas, lo haré pero lo probaré con calma...

Gracias por la pista :)