Desarrollando canal para Xhamster...
Publicado: 05 Oct 2011, 22:42
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!
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!