def topVideos(params, url, category): url2 = url data = scrapertools.cachePage(url) patron = '<option value="([^"]+)" >([^<]+)</option>' matches = re.compile(patron, re.DOTALL).findall(data) if len(matches) > 0: opciones = [] urls = [] opciones.append("Todo el Tiempo") urls.append("http://www.sonolatino.com/topvideos.html") opciones.append("Ultimos 2 dias") urls.append("http://www.sonolatino.com/topvideos.html?do=recent") for match in matches: opciones.append(scrapertools.unescape(match[1])) urls.append(match[0]) # Abre el di�logo de selecci�n dia = xbmcgui.Dialog() seleccion = dia.select("Elige Listar Top por :", opciones) logger.info("seleccion=%d" % seleccion) if seleccion == -1: return url2 = urls[seleccion] toplist(params, url2, category)
def devuelveListaEpisodios (params,url,category): """Scrapea la página de episodios y la devuelve como lista de diccionarios UPDATE 25-02-2011: Los últimos camibos de la web tvshack hacen este procedimiento innecesariamente complejo. Rediseñado --> Los habituales en los canales de pelisalacarta. <-- [{Episodio}] Lista de diccionarios con los datos de cada episodio Al añadir los episodios como diccionarios nos permite añadir o borrar claves a voluntad dejando abierto el diseño a poder añadir información en los canales que ésta exista. Las clave básicas en el momento de escribir este canal son: 'title' : Título del episodio - Para la biblioteca peferiblemente en formato NOMBRE_SERIE - TEMPORADAxEPISODIO TÍTULO_EPISODIO LOQUESEA 'url' : URL del episodio 'plot' : Resumen del episodio (o de la serie si éste no existe para este canal) 'thumbnail' : Fotograma del episodio o carátula de la serie """ if params.has_key("Serie"): serie = params.get("Serie") else: serie = "" # Descarga la p�gina data = scrapertools.cachePage(url) temporada = '0' # Extraemos los episodios por medio de expresiones regulares (patrón) # Ej. Serie: <li class="listm"><a href="/tv/Family_Guy/season_1/episode_1/">ep1. Death Has a Shadow</a><a href=""><span>31/1/1999</span></a></li> # Ej. Anime: EN DESUSO <li><a href="http://tvshack.bz/anime/07_Ghost/season_1/episode_5/">ep5. Episode 5</a><a href=""><span>??/??/????</span></a></li> # Ej. Musica:EN DESUSO <li><a href="http://tvshack.bz/music/Michael_Jackson/C85E8225E45E/">Black Or White<span>2,301 views</span></a></li><li><a patronepisodios = '''(?x) # Activa opción VERBOSE. <li\ class="listm"><a\ href=" # Basura (?:http://tvshack\.bz)?([^"]+)" #\g1 = Path (relativo) del episodio/video [^>]*> # Basura ([0-9]+) #\g2 = Temporada x([0-9]+) #\g3 = Número de episodio \ ([^<]+) #\g4 = Nombre del episodio <\/a><\/li> # Basura ''' episodiosREO = re.compile(patronepisodios) ## Objeto de Expresión Regular (REO) listaEp = [] # Lista de Episodios Ep = {} # Diccionario con la info de cada episodio # UPDATE 25-2-2011: La nueva web tampoco tiene infor de serie ni fechas de emisión Ep['thumbnail']= "" Ep['plot']= "" for match in episodiosREO.finditer (data): if category != 'Musica': title = match.expand (serie + ' - \g<2>x\g<3> - \g<4>') #con expand los grupos referenciados empiezan en 1 else: title = match.expand ('\g<3> (visto \g<5> veces)') #con expand los grupos referenciaos empiezan en 1 #URL del episodio Ep['title'] = scrapertools.unescape(title) Ep['url'] = TVSHACK_URL + match.group(1) listaEp.append(Ep.copy()) #Se añade el episodio a la lista (hay que copiarlo) return listaEp
def addnewfolder( canal , accion , category , title , url , thumbnail , plot , Serie="",totalItems=0): addnewfolderextra( canal , accion , category , scrapertools.unescape(title) , url , thumbnail , plot , "" ,Serie,totalItems)
def detail(params,url,category): logger.info("[peliculasid.py] detail") title = urllib.unquote_plus( params.get("title") ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = urllib.unquote_plus( params.get("plot") ) # Descarga la p�gina data = scrapertools.cachePage(url) #logger.info(data) patrondescrip = '<strong>Sinopsis:</strong><br />(.*?)</p>' matches = re.compile(patrondescrip,re.DOTALL).findall(data) if len(matches)>0: descripcion = matches[0] descripcion = descripcion.replace("<br/>","") descripcion = descripcion.replace("\r","") descripcion = descripcion.replace("\n"," ") descripcion = descripcion.replace("\t"," ") descripcion = re.sub("<[^>]+>"," ",descripcion) #logger.info("descripcion="+descripcion) descripcion = acentos(descripcion) #logger.info("descripcion="+descripcion) try : plot = unicode( descripcion, "utf-8" ).encode("iso-8859-1") except: plot = descripcion plot = scrapertools.unescape(plot.strip()) #--- Busca los videos Directos patronvideos = 'flashvars" value="file=([^\&]+)\&' matches = re.compile(patronvideos,re.DOTALL).findall(data) if len(matches)>0: if ("xml" in matches[0]): xbmctools.addnewvideo( CHANNELNAME , "play" , category , "xml" , "Reproducir todas las partes a la vez" , matches[0] , thumbnail , plot ) #data = scrapertools.cachePage(matches[0]) req = urllib2.Request(matches[0]) try: response = urllib2.urlopen(req) except: xbmctools.alertnodisponible() return data=response.read() response.close() #logger.info("archivo xml :"+data) newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>' newmatches = re.compile(newpatron,re.DOTALL).findall(data) if len(newmatches)>0: for match in newmatches: logger.info(" videos = "+match[1]) if match[1].startswith("vid"): subtitle = match[0] + " (rtmpe) no funciona en xbmc" else: subtitle = match[0] xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+subtitle, match[1] , thumbnail , plot ) else: logger.info(" matches = "+matches[0]) xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title, matches[0] , thumbnail , plot ) # Ahora usa servertools listavideos = servertools.findvideos(data) j=1 for video in listavideos: videotitle = video[0] url = video[1] server = video[2] xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , (title.strip() + " (%d) " + videotitle) % j , url , thumbnail , plot ) j=j+1 patronvideos = '<a href="(http://peliculasid.net/modulos/iframeplayer.php[^"]+)" target="[^"]+">([^<]+)</a>' #patronvideos2 = 'file=([^\&]+)\&' matches = re.compile(patronvideos,re.DOTALL).findall(data) if len(matches)>0: urllists = "" for match in matches: if urllists == "": urllists = match[0] else: urllists = urllists + "|" + match[0] #data2 = scrapertools.cachePage(match[0]) #matches2 = re.compile(patronvideos2,re.DOTALL).findall(data2) xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title+" - "+match[1], match[0] , thumbnail , plot ) xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , "(Reproducir todas las partes a la vez...)", urllists , thumbnail , plot ) ## --------------------------------------------------------------------------------------## # Busca enlaces de videos para el servidor vkontakte.ru # ## --------------------------------------------------------------------------------------## #"http://vkontakte.ru/video_ext.php?oid=89710542&id=147003951&hash=28845bd3be717e11&hd=1 ''' var video_host = 'http://cs12916.vkontakte.ru/'; var video_uid = '87155741'; var video_vtag = 'fc697084d3'; var video_no_flv = 1; var video_max_hd = '1' ''' patronvideos = '<iframe src="(http://vk[^/]+/video_ext.php[^"]+)"' matches = re.compile(patronvideos,re.DOTALL).findall(data) if len(matches)>0: print " encontro VKontakte.ru :%s" %matches[0] data2 = scrapertools.cachePage(matches[0]) print data2 patron = "var video_host = '([^']+)'.*?" patron += "var video_uid = '([^']+)'.*?" patron += "var video_vtag = '([^']+)'.*?" patron += "var video_no_flv = ([^;]+);.*?" patron += "var video_max_hd = '([^']+)'" matches2 = re.compile(patron,re.DOTALL).findall(data2) if len(matches2)>0: #http://cs12385.vkontakte.ru/u88260894/video/d09802a95b.360.mp4 for match in matches2: if match[3].strip() == "0": tipo = "flv" videourl = "%s/u%s/video/%s.%s" % (match[0],match[1],match[2],tipo) xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+"[VKONTAKTE] [%s]" %tipo, videourl , thumbnail , plot ) else: tipo = "360.mp4" videourl = "%s/u%s/video/%s.%s" % (match[0],match[1],match[2],tipo) xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+"[VKONTAKTE] [%s]" %tipo, videourl , thumbnail , plot ) tipo = "240.mp4" videourl = "%s/u%s/video/%s.%s" % (match[0],match[1],match[2],tipo) xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+"[VKONTAKTE] [%s]" %tipo, videourl , thumbnail , plot ) patronvideos = '"(http://peliculasid.net/modulos/iframevk.php[^"]+)"' matches = re.compile(patronvideos,re.DOTALL).findall(data) if len(matches)>0: print " encontro VKontakte.ru :%s" %matches[0] xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title+" - [VKserver]", matches[0] , thumbnail , plot ) patronvideos = '"(http://peliculasid.net/modulos/iframemv.php[^"]+)"' matches = re.compile(patronvideos,re.DOTALL).findall(data) if len(matches)>0: print " encontro Megavideo :%s" %matches[0] xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Megavideo" , title+" - [Megavideo]", matches[0] , thumbnail , plot ) # Label (top-right)... xbmcplugin.setPluginCategory( handle=pluginhandle, category=category ) xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE ) xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
def detail(params,url,category): logger.info("[nolomires.py] detail") title = acentos(urllib.unquote_plus( params.get("title") )) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = "" scrapedurl = "" # Descarga la p�gina data = scrapertools.cachePage(url) #logger.info(data) # Extrae el argumento patronarg = '<h[2-3]>(<span style.*?)</p>' matches = re.compile(patronarg,re.DOTALL).findall(data) if len(matches)>0: plot = re.sub("<[^>]+>"," ",matches[0]) patronthumb = '<div id="textimg"><img src="([^"]+)"' matches = re.compile(patronthumb,re.DOTALL).findall(data) if len(matches)>0: thumbnail = matches[0] # ------------------------------------------------------------------------------------ # Busca los enlaces a los videos en los servidores habilitados # ------------------------------------------------------------------------------------ listavideos = servertools.findvideos(data) for video in listavideos: videotitle = video[0] url = video[1] server = video[2] xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , title.strip() + " - " + videotitle , url , thumbnail , plot ) ## --------------------------------------------------------------------------------------## # Busca enlaces a videos .flv o (.mp4 dentro de un xml) # ## --------------------------------------------------------------------------------------## patronvideos = 'file=(http\:\/\/[^\&]+)\&' matches = re.compile(patronvideos,re.DOTALL).findall(data) scrapertools.printMatches(matches) playWithSubt = "play" c = 0 if len(matches)>0: for match in matches: print "link xml :%s" %match subtitle = "[FLV-Directo]" c += 1 sub = "" if ("/xml" in match): data2 = scrapertools.cachePage(match) logger.info("data2="+data2) patronvideos = '<track>.*?' patronvideos += '<title>([^<]+)</title>[^<]+' patronvideos += '<location>([^<]+)</location>(?:[^<]+' patronvideos += '<meta rel="type">video</meta>[^<]+|[^<]+)' patronvideos += '<meta rel="captions">([^<]+)</meta>[^<]+' patronvideos += '</track>' matches2 = re.compile(patronvideos,re.DOTALL).findall(data2) scrapertools.printMatches(matches) if len(matches2)==0: newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>' matches2 = re.compile(newpatron,re.DOTALL).findall(data2) sub = "None" for match2 in matches2: try: if match2[2].endswith(".xml"): # Subtitulos con formato xml son incompatibles con XBMC sub = "[Subtitulo incompatible con xbmc]" playWithSubt = "play" except: pass if ".mp4" in match2[1]: subtitle = "[MP4-Directo]" scrapedtitle = '%s (castellano) - %s %s' %(title,match2[0],subtitle) scrapedurl = match2[1].strip() scrapedthumbnail = thumbnail scrapedplot = plot if ("cast.xml" or "mirror.xml") not in match and sub == "": scrapedtitle = '%s (V.O.S) - %s %s %s' %(title,match2[0],subtitle,sub) try: if not match2[2].endswith("cine-adicto2.srt") and (sub == ""): scrapedurl = scrapedurl + "|" + match2[2] playWithSubt = "play2" except:pass if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]") # A�ade al listado de XBMC xbmctools.addnewvideo( CHANNELNAME , playWithSubt , category , "Directo" , scrapedtitle, scrapedurl , scrapedthumbnail, scrapedplot ) else: if match.endswith(".srt"): scrapedurl = scrapedurl + "|" + match xbmctools.addnewvideo( CHANNELNAME ,"play2" , category , "Directo" , title + " (V.O.S) - "+subtitle, scrapedurl , thumbnail , plot ) if match.endswith(".xml"): sub = "[Subtitulo incompatible con xbmc]" xbmctools.addnewvideo( CHANNELNAME ,"play" , category , "Directo" , title + " (V.O) - %s %s" %(subtitle,sub), scrapedurl , thumbnail , plot ) scrapedurl = match print scrapedurl ## --------------------------------------------------------------------------------------## # Busca enlaces de videos para el servidor vk.com # ## --------------------------------------------------------------------------------------## #http://vkontakte.ru/video_ext.php?oid=93103247&id=149051583&hash=793cde84b05681fa&hd=1 patronvideos = '<iframe src="(http://[^\/]+\/video_ext.php[^"]+)"' matches = re.compile(patronvideos,re.DOTALL).findall(data) if len(matches)>0: print " encontro VK.COM :%s" %matches[0] videourl = vk.geturl(scrapertools.unescape(matches[0])) xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+"[VK]", videourl , thumbnail , plot ) # Label (top-right)... xbmcplugin.setPluginCategory( handle=pluginhandle, category=category ) # Disable sorting... xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE ) # End of directory... xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
def detail(params, url, category): logger.info("[peliculasid.py] detail") title = urllib.unquote_plus(params.get("title")) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = urllib.unquote_plus(params.get("plot")) # Descarga la p�gina data = scrapertools.downloadpageGzip(url) #logger.info(data) patrondescrip = '<strong>Sinopsis:</strong><br />(.*?)</p>' matches = re.compile(patrondescrip, re.DOTALL).findall(data) if len(matches) > 0: descripcion = matches[0] descripcion = descripcion.replace("<br/>", "") descripcion = descripcion.replace("\r", "") descripcion = descripcion.replace("\n", " ") descripcion = descripcion.replace("\t", " ") descripcion = re.sub("<[^>]+>", " ", descripcion) #logger.info("descripcion="+descripcion) descripcion = acentos(descripcion) #logger.info("descripcion="+descripcion) try: plot = unicode(descripcion, "utf-8").encode("iso-8859-1") except: plot = descripcion plot = scrapertools.unescape(plot.strip()) #--- Busca los videos Directos patronvideos = 'flashvars" value="file=([^\&]+)\&' matches = re.compile(patronvideos, re.DOTALL).findall(data) if len(matches) > 0: if ("xml" in matches[0]): xbmctools.addnewvideo(CHANNELNAME, "play", category, "xml", "Reproducir todas las partes a la vez", matches[0], thumbnail, plot) #data = scrapertools.downloadpageGzip(matches[0]) req = urllib2.Request(matches[0]) try: response = urllib2.urlopen(req) except: xbmctools.alertnodisponible() return data = response.read() response.close() #logger.info("archivo xml :"+data) newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>' newmatches = re.compile(newpatron, re.DOTALL).findall(data) if len(newmatches) > 0: for match in newmatches: logger.info(" videos = " + match[1]) if match[1].startswith("vid"): subtitle = match[0] + " (rtmpe) no funciona en xbmc" else: subtitle = match[0] xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", title + " - " + subtitle, match[1], thumbnail, plot) else: logger.info(" matches = " + matches[0]) xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", title, matches[0], thumbnail, plot) # Ahora usa servertools listavideos = servertools.findvideos(data) j = 1 for video in listavideos: videotitle = video[0] url = video[1] server = video[2] xbmctools.addnewvideo(CHANNELNAME, "play", category, server, (title.strip() + " (%d) " + videotitle) % j, url, thumbnail, plot) j = j + 1 patronvideos = '<a href="(http://peliculasid.net/modulos/iframeplayer.php[^"]+)" target="[^"]+">([^<]+)</a>' #patronvideos2 = 'file=([^\&]+)\&' matches = re.compile(patronvideos, re.DOTALL).findall(data) if len(matches) > 0: urllists = "" for match in matches: if urllists == "": urllists = match[0] else: urllists = urllists + "|" + match[0] #data2 = scrapertools.downloadpageGzip(match[0]) #matches2 = re.compile(patronvideos2,re.DOTALL).findall(data2) xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", title + " - " + match[1], match[0], thumbnail, plot) xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", "(Reproducir todas las partes a la vez...)", urllists, thumbnail, plot) ## --------------------------------------------------------------------------------------## # Busca enlaces de videos para el servidor vkontakte.ru # ## --------------------------------------------------------------------------------------## #"http://vkontakte.ru/video_ext.php?oid=89710542&id=147003951&hash=28845bd3be717e11&hd=1 ''' var video_host = 'http://cs12916.vkontakte.ru/'; var video_uid = '87155741'; var video_vtag = 'fc697084d3'; var video_no_flv = 1; var video_max_hd = '1' ''' patronvideos = '<iframe src="(http://vk[^/]+/video_ext.php[^"]+)"' matches = re.compile(patronvideos, re.DOTALL).findall(data) if len(matches) > 0: print " encontro VKontakte.ru :%s" % matches[0] data2 = scrapertools.downloadpageGzip(matches[0]) print data2 patron = "var video_host = '([^']+)'.*?" patron += "var video_uid = '([^']+)'.*?" patron += "var video_vtag = '([^']+)'.*?" patron += "var video_no_flv = ([^;]+);.*?" patron += "var video_max_hd = '([^']+)'" matches2 = re.compile(patron, re.DOTALL).findall(data2) if len( matches2 ) > 0: #http://cs12385.vkontakte.ru/u88260894/video/d09802a95b.360.mp4 for match in matches2: if match[3].strip() == "0": tipo = "flv" videourl = "%s/u%s/video/%s.%s" % (match[0], match[1], match[2], tipo) xbmctools.addnewvideo( CHANNELNAME, "play", category, "Directo", title + " - " + "[VKONTAKTE] [%s]" % tipo, videourl, thumbnail, plot) else: tipo = "360.mp4" videourl = "%s/u%s/video/%s.%s" % (match[0], match[1], match[2], tipo) xbmctools.addnewvideo( CHANNELNAME, "play", category, "Directo", title + " - " + "[VKONTAKTE] [%s]" % tipo, videourl, thumbnail, plot) tipo = "240.mp4" videourl = "%s/u%s/video/%s.%s" % (match[0], match[1], match[2], tipo) xbmctools.addnewvideo( CHANNELNAME, "play", category, "Directo", title + " - " + "[VKONTAKTE] [%s]" % tipo, videourl, thumbnail, plot) patronvideos = '"(http://peliculasid.net/modulos/iframevk.php[^"]+)"' matches = re.compile(patronvideos, re.DOTALL).findall(data) if len(matches) > 0: print " encontro VKontakte.ru :%s" % matches[0] xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", title + " - [VKserver]", matches[0], thumbnail, plot) patronvideos = '"(http://peliculasid.net/modulos/iframemv.php[^"]+)"' matches = re.compile(patronvideos, re.DOTALL).findall(data) if len(matches) > 0: print " encontro Megavideo :%s" % matches[0] xbmctools.addnewvideo(CHANNELNAME, "play", category, "Megavideo", title + " - [Megavideo]", matches[0], thumbnail, plot) # Label (top-right)... xbmcplugin.setPluginCategory(handle=pluginhandle, category=category) xbmcplugin.addSortMethod(handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(handle=pluginhandle, succeeded=True)
def devuelveListaEpisodios(params, url, category): """Scrapea la página de episodios y la devuelve como lista de diccionarios UPDATE 25-02-2011: Los últimos camibos de la web tvshack hacen este procedimiento innecesariamente complejo. Rediseñado --> Los habituales en los canales de pelisalacarta. <-- [{Episodio}] Lista de diccionarios con los datos de cada episodio Al añadir los episodios como diccionarios nos permite añadir o borrar claves a voluntad dejando abierto el diseño a poder añadir información en los canales que ésta exista. Las clave básicas en el momento de escribir este canal son: 'title' : Título del episodio - Para la biblioteca peferiblemente en formato NOMBRE_SERIE - TEMPORADAxEPISODIO TÍTULO_EPISODIO LOQUESEA 'url' : URL del episodio 'plot' : Resumen del episodio (o de la serie si éste no existe para este canal) 'thumbnail' : Fotograma del episodio o carátula de la serie """ if params.has_key("Serie"): serie = params.get("Serie") else: serie = "" # Descarga la p�gina data = scrapertools.cachePage(url) temporada = '0' # Extraemos los episodios por medio de expresiones regulares (patrón) # Ej. Serie: <li class="listm"><a href="/tv/Family_Guy/season_1/episode_1/">ep1. Death Has a Shadow</a><a href=""><span>31/1/1999</span></a></li> # Ej. Anime: EN DESUSO <li><a href="http://tvshack.bz/anime/07_Ghost/season_1/episode_5/">ep5. Episode 5</a><a href=""><span>??/??/????</span></a></li> # Ej. Musica:EN DESUSO <li><a href="http://tvshack.bz/music/Michael_Jackson/C85E8225E45E/">Black Or White<span>2,301 views</span></a></li><li><a patronepisodios = '''(?x) # Activa opción VERBOSE. <li\ class="listm"><a\ href=" # Basura (?:http://tvshack\.bz)?([^"]+)" #\g1 = Path (relativo) del episodio/video [^>]*> # Basura ([0-9]+) #\g2 = Temporada x([0-9]+) #\g3 = Número de episodio \ ([^<]+) #\g4 = Nombre del episodio <\/a><\/li> # Basura ''' episodiosREO = re.compile( patronepisodios) ## Objeto de Expresión Regular (REO) listaEp = [] # Lista de Episodios Ep = {} # Diccionario con la info de cada episodio # UPDATE 25-2-2011: La nueva web tampoco tiene infor de serie ni fechas de emisión Ep['thumbnail'] = "" Ep['plot'] = "" for match in episodiosREO.finditer(data): if category != 'Musica': title = match.expand( serie + ' - \g<2>x\g<3> - \g<4>' ) #con expand los grupos referenciados empiezan en 1 else: title = match.expand( '\g<3> (visto \g<5> veces)' ) #con expand los grupos referenciaos empiezan en 1 #URL del episodio Ep['title'] = scrapertools.unescape(title) Ep['url'] = TVSHACK_URL + match.group(1) listaEp.append( Ep.copy()) #Se añade el episodio a la lista (hay que copiarlo) return listaEp
def detail(params, url, category): logger.info("[nolomires.py] detail") title = acentos(urllib.unquote_plus(params.get("title"))) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = "" scrapedurl = "" # Descarga la p�gina data = scrapertools.cachePage(url) #logger.info(data) # Extrae el argumento patronarg = '<h[2-3]>(<span style.*?)</p>' matches = re.compile(patronarg, re.DOTALL).findall(data) if len(matches) > 0: plot = re.sub("<[^>]+>", " ", matches[0]) patronthumb = '<div id="textimg"><img src="([^"]+)"' matches = re.compile(patronthumb, re.DOTALL).findall(data) if len(matches) > 0: thumbnail = matches[0] # ------------------------------------------------------------------------------------ # Busca los enlaces a los videos en los servidores habilitados # ------------------------------------------------------------------------------------ listavideos = servertools.findvideos(data) for video in listavideos: videotitle = video[0] url = video[1] server = video[2] xbmctools.addnewvideo(CHANNELNAME, "play", category, server, title.strip() + " - " + videotitle, url, thumbnail, plot) ## --------------------------------------------------------------------------------------## # Busca enlaces a videos .flv o (.mp4 dentro de un xml) # ## --------------------------------------------------------------------------------------## patronvideos = 'file=(http\:\/\/[^\&]+)\&' matches = re.compile(patronvideos, re.DOTALL).findall(data) scrapertools.printMatches(matches) playWithSubt = "play" c = 0 if len(matches) > 0: for match in matches: print "link xml :%s" % match subtitle = "[FLV-Directo]" c += 1 sub = "" if ("/xml" in match): data2 = scrapertools.cachePage(match) logger.info("data2=" + data2) patronvideos = '<track>.*?' patronvideos += '<title>([^<]+)</title>[^<]+' patronvideos += '<location>([^<]+)</location>(?:[^<]+' patronvideos += '<meta rel="type">video</meta>[^<]+|[^<]+)' patronvideos += '<meta rel="captions">([^<]+)</meta>[^<]+' patronvideos += '</track>' matches2 = re.compile(patronvideos, re.DOTALL).findall(data2) scrapertools.printMatches(matches) if len(matches2) == 0: newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>' matches2 = re.compile(newpatron, re.DOTALL).findall(data2) sub = "None" for match2 in matches2: try: if match2[2].endswith( ".xml" ): # Subtitulos con formato xml son incompatibles con XBMC sub = "[Subtitulo incompatible con xbmc]" playWithSubt = "play" except: pass if ".mp4" in match2[1]: subtitle = "[MP4-Directo]" scrapedtitle = '%s (castellano) - %s %s' % ( title, match2[0], subtitle) scrapedurl = match2[1].strip() scrapedthumbnail = thumbnail scrapedplot = plot if ("cast.xml" or "mirror.xml") not in match and sub == "": scrapedtitle = '%s (V.O.S) - %s %s %s' % ( title, match2[0], subtitle, sub) try: if not match2[2].endswith("cine-adicto2.srt") and ( sub == ""): scrapedurl = scrapedurl + "|" + match2[2] playWithSubt = "play2" except: pass if (DEBUG): logger.info("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]") # A�ade al listado de XBMC xbmctools.addnewvideo(CHANNELNAME, playWithSubt, category, "Directo", scrapedtitle, scrapedurl, scrapedthumbnail, scrapedplot) else: if match.endswith(".srt"): scrapedurl = scrapedurl + "|" + match xbmctools.addnewvideo(CHANNELNAME, "play2", category, "Directo", title + " (V.O.S) - " + subtitle, scrapedurl, thumbnail, plot) if match.endswith(".xml"): sub = "[Subtitulo incompatible con xbmc]" xbmctools.addnewvideo( CHANNELNAME, "play", category, "Directo", title + " (V.O) - %s %s" % (subtitle, sub), scrapedurl, thumbnail, plot) scrapedurl = match print scrapedurl ## --------------------------------------------------------------------------------------## # Busca enlaces de videos para el servidor vk.com # ## --------------------------------------------------------------------------------------## #http://vkontakte.ru/video_ext.php?oid=93103247&id=149051583&hash=793cde84b05681fa&hd=1 patronvideos = '<iframe src="(http://[^\/]+\/video_ext.php[^"]+)"' matches = re.compile(patronvideos, re.DOTALL).findall(data) if len(matches) > 0: print " encontro VK.COM :%s" % matches[0] videourl = vk.geturl(scrapertools.unescape(matches[0])) xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", title + " - " + "[VK]", videourl, thumbnail, plot) # Label (top-right)... xbmcplugin.setPluginCategory(handle=pluginhandle, category=category) # Disable sorting... xbmcplugin.addSortMethod(handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE) # End of directory... xbmcplugin.endOfDirectory(handle=pluginhandle, succeeded=True)