def play(params,url,category): logger.info("[sonolatino.py] play") title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" ) try: thumbnail = urllib.unquote_plus( params.get("thumbnail") ) except: thumbnail = xbmc.getInfoImage( "ListItem.Thumb" ) plot = urllib.unquote_plus( params.get("plot") ) plot = urllib.unquote_plus( params.get("plot") ) try: plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" ) except: plot = xbmc.getInfoLabel( "ListItem.Plot" ) server = params["server"] logger.info("[sonolatino.py] thumbnail="+thumbnail) logger.info("[sonolatino.py] server="+server) if server == "izlesene": print server data = scrapertools.cachePage(url) print data patron = 'durl="([^"]+)"' matches = re.compile(patron,re.DOTALL).findall(data) if len(matches)>0: url = matches[0] server = "Directo" xbmctools.play_video(__channel__,server,url,category,title,thumbnail,plot)
def play(params, url, category): xbmc.log("[skai_folders.py] play") title = unicode(xbmc.getInfoLabel("ListItem.Title"), "utf-8") thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = unicode(xbmc.getInfoLabel("ListItem.Plot"), "utf-8") server = "Directo" # -------------------------------------------------------- # DDownload page # -------------------------------------------------------- data = scrapertools.cachePage(url) pattern = 'rtmp://cp67754.edgefcs.net/ondemand/mp4:content/Fakeloi/20.*?mp4' matches = re.compile(pattern, re.DOTALL).findall(data) if len(matches) == 0: xbmctools.alerterrorpagina() return url = matches[0] xbmc.log("url=" + url) xbmctools.play_video(CHANNELCODE, server, url, category, title, thumbnail, plot)
def play(params,url,category): logger.info("[pintadibujos.py] play") title = urllib.unquote_plus( params.get("title") ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = urllib.unquote_plus( params.get("plot") ) server = params["server"] xbmctools.play_video(CHANNELNAME,server,url,category,title,thumbnail,plot)
def play(params,url,category): logger.info("[pelisflv.py] play") title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" ) server = params["server"] xbmctools.play_video(__channel__,server,url,category,title,thumbnail,plot)
def play(params,url,category): logger.info("[programastv.py] play") title = urllib.unquote_plus( params.get("title") ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" ) server = params["server"] xbmctools.play_video(CHANNELNAME,server,url,category,title,thumbnail,plot)
def play(params,url,category): logger.info("[watchanimeon.py] play") title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" ) server = params["server"] xbmctools.play_video(__channel__,server,url,category,title,thumbnail,plot)
def play(params, url, category): logger.info("[pintadibujos.py] play") title = urllib.unquote_plus(params.get("title")) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = urllib.unquote_plus(params.get("plot")) server = params["server"] xbmctools.play_video(CHANNELNAME, server, url, category, title, thumbnail, plot)
def play(params,url,category): logger.info("[stagevusite.py] play") title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" ) thumbnail = xbmc.getInfoImage( "ListItem.Thumb" ) plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" ) logger.info("[stagevusite.py] thumbnail="+thumbnail) server="stagevu" xbmctools.play_video(__channel__,server,url,category,title,thumbnail,plot)
def play(params, url, category): logger.info("[programastv.py] play") title = urllib.unquote_plus(params.get("title")) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = unicode(xbmc.getInfoLabel("ListItem.Plot"), "utf-8") server = params["server"] xbmctools.play_video(CHANNELNAME, server, url, category, title, thumbnail, plot)
def youtubeplay(params,url,category): logger.info("[trailertools.py] youtubeplay") #http://www.youtube.com/watch?v=byvXidWNf2A&feature=youtube_gdata title = urllib.unquote_plus( params.get("title") ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = "Ver Video" server = "youtube" #id = youtube.Extract_id(url) #videourl = youtube.geturl(id) xbmctools.play_video("Trailer",server,url,category,title,thumbnail,plot)
def play(params,url,category): logger.info("[seriesonline.py] play") title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" ) thumbnail = xbmc.getInfoImage( "ListItem.Thumb" ) plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" ) server = params["server"] logger.info("[seriesonline.py] thumbnail="+thumbnail) logger.info("[seriesonline.py] server="+server) xbmctools.play_video(CHANNELNAME,server,url,category,title,thumbnail,plot)
def play(params, url, category): logger.info("[seriesonline.py] play") title = unicode(xbmc.getInfoLabel("ListItem.Title"), "utf-8") thumbnail = xbmc.getInfoImage("ListItem.Thumb") plot = unicode(xbmc.getInfoLabel("ListItem.Plot"), "utf-8") server = params["server"] logger.info("[seriesonline.py] thumbnail=" + thumbnail) logger.info("[seriesonline.py] server=" + server) xbmctools.play_video(CHANNELNAME, server, url, category, title, thumbnail, plot)
def youtubeplay(params,url,category): logger.info("[peliculas21.py] youtubeplay") title = urllib.unquote_plus( params.get("title") ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = "Ver Video" server = "Directo" id = youtube.Extract_id(url) videourl = youtube.geturl(id) if videourl == ("" or "Esc"):return logger.info("link directo de youtube : "+videourl) xbmctools.play_video("Trailer",server,videourl,category,title,thumbnail,plot)
def play(params,url,category): logger.info("[veocine.py] play") title = urllib.unquote_plus( params.get("title") ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = urllib.unquote_plus( params.get("plot") ) server = urllib.unquote_plus( params.get("server") ) # Abre dialogo dialogWait = xbmcgui.DialogProgress() dialogWait.create( 'Accediendo al video...', title , plot ) # Cierra dialogo dialogWait.close() del dialogWait xbmctools.play_video(__channel__,server,url,category,title,thumbnail,plot)
def buscavideos(params, url, category): data = scrapertools.cachePage("http://www.redes-tv.com" + url) #<embed src="http://blip.tv/play/+3KB0rYcAg" type="application/x-shockwave-flash" patronvideos = '\n<div style="text-align: justify;">.+?</div>' matches = re.compile(patronvideos, re.DOTALL).findall(data) if DEBUG: scrapertools.printMatches(matches) #<embed src="http://blip.tv/play/+3KB0rYcAg" type="application/x-shockwave-flash" patronvideos = '<embed src="(http://blip.tv/play/\+.*?)" type="application/x-shockwave-flash"' matches = re.compile(patronvideos, re.DOTALL).findall(data) if DEBUG: scrapertools.printMatches(matches) #bliptv.bliptv("3011527") #mediaurl = bliptv.geturl(matches[0]) #logger.info("mediaurl="+mediaurl) xbmctools.play_video(__channel__, "bliptv", matches[0], "", "", "", "")
def buscavideos(params,url,category): data = scrapertools.cachePage("http://www.redes-tv.com"+url) #<embed src="http://blip.tv/play/+3KB0rYcAg" type="application/x-shockwave-flash" patronvideos = '\n<div style="text-align: justify;">.+?</div>' matches = re.compile(patronvideos,re.DOTALL).findall(data) if DEBUG: scrapertools.printMatches(matches) #<embed src="http://blip.tv/play/+3KB0rYcAg" type="application/x-shockwave-flash" patronvideos = '<embed src="(http://blip.tv/play/\+.*?)" type="application/x-shockwave-flash"' matches = re.compile(patronvideos,re.DOTALL).findall(data) if DEBUG: scrapertools.printMatches(matches) #bliptv.bliptv("3011527") #mediaurl = bliptv.geturl(matches[0]) #logger.info("mediaurl="+mediaurl) xbmctools.play_video(__channel__,"bliptv",matches[0],"","","","")
def detail(params, url, category): logger.info("[peliculasyonkis.py] detail") title = urllib.unquote_plus(params.get("title")) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = unicode(xbmc.getInfoLabel("ListItem.Plot"), "utf-8") # Descarga la pv°gina data = scrapertools.cachePage(url) # logger.info(data) # ------------------------------------------------------------------------------------ # Busca los enlaces a los videos # ------------------------------------------------------------------------------------ patronvideos = 'href="http://www.peliculasyonkis.sx/player/visor_([^\.]+).php.*?' patronvideos += 'id=([^"]+)".*?' patronvideos += 'alt="([^"]+)"' patronvideos += "(.*?)</tr>" matches = re.compile(patronvideos, re.DOTALL).findall(data) patronvideos1 = 'http://www.peliculasyonkis.sx/go/(d)/(.+?)".*?alt="([^"]+)"' patronvideos1 += "(.+?)<br /></span></div></td>" matches1 = re.compile(patronvideos1, re.DOTALL).findall(data) if len(matches1) > 0: for j in matches1: matches.append(j) if len(matches) > 0: scrapertools.printMatches(matches) id, serv = ChoiceOneVideo(matches, title) logger.info("[peliculasyonkis.py] id=" + id) url = Decrypt_Server(id, serv) if (serv in ["pymeno2", "pymeno3"]) and (":" in url): match = url.split(":") url = choiceOnePart(match) if url == "": return print "codigo :%s" % url else: xbmctools.alertnodisponible() return "" if url == "": return xbmctools.play_video(CHANNELNAME, SERVER[serv], url, category, title, thumbnail, plot)
def play(params, url, category): logger.info("[veocine.py] play") title = urllib.unquote_plus(params.get("title")) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = urllib.unquote_plus(params.get("plot")) server = urllib.unquote_plus(params.get("server")) # Abre dialogo dialogWait = xbmcgui.DialogProgress() dialogWait.create('Accediendo al video...', title, plot) # Cierra dialogo dialogWait.close() del dialogWait xbmctools.play_video(__channel__, server, url, category, title, thumbnail, plot)
def detail(params, url, category): logger.info("[peliculasyonkis.py] detail") title = urllib.unquote_plus(params.get("title")) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = unicode(xbmc.getInfoLabel("ListItem.Plot"), "utf-8") # Descarga la pv°gina data = scrapertools.cachePage(url) #logger.info(data) # ------------------------------------------------------------------------------------ # Busca los enlaces a los videos # ------------------------------------------------------------------------------------ patronvideos = 'href="http://www.peliculasyonkis.sx/player/visor_([^\.]+).php.*?' patronvideos += 'id=([^"]+)".*?' patronvideos += 'alt="([^"]+)"' patronvideos += '(.*?)</tr>' matches = re.compile(patronvideos, re.DOTALL).findall(data) patronvideos1 = 'http://www.peliculasyonkis.sx/go/(d)/(.+?)".*?alt="([^"]+)"' patronvideos1 += "(.+?)<br /></span></div></td>" matches1 = re.compile(patronvideos1, re.DOTALL).findall(data) if (len(matches1) > 0): for j in matches1: matches.append(j) if len(matches) > 0: scrapertools.printMatches(matches) id, serv = ChoiceOneVideo(matches, title) logger.info("[peliculasyonkis.py] id=" + id) url = Decrypt_Server(id, serv) if (serv in ["pymeno2", "pymeno3"]) and (":" in url): match = url.split(":") url = choiceOnePart(match) if url == "": return print 'codigo :%s' % url else: xbmctools.alertnodisponible() return "" if url == "": return xbmctools.play_video(CHANNELNAME, SERVER[serv], url, category, title, thumbnail, plot)
def youtubeplay(params,url,category): logger.info("[series21.py] youtubeplay") title = urllib.unquote_plus( params.get("title") ) thumbnail = urllib.unquote_plus( params.get("thumbnail") ) plot = "Ver Video" server = "Directo" id = youtube.Extract_id(url) # Abre el diálogo de selección opciones = [] opciones.append("(FLV) Baja calidad") opciones.append("(MP4) Alta calidad") dia = xbmcgui.Dialog() seleccion = dia.select("tiene 2 formatos elige uno", opciones) logger.info("seleccion=%d" % seleccion) if seleccion==-1: return("") if seleccion == 0: videourl,videoinfo = youtube.GetYoutubeVideoInfo(id) else: videourl = youtube.geturl(id) logger.info("link directo de youtube : "+videourl) xbmctools.play_video("Trailer",server,videourl,category,title,thumbnail,plot)
def play(params, url, category): xbmc.log("[skai_folders.py] play") title = unicode(xbmc.getInfoLabel("ListItem.Title"), "utf-8") thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = unicode(xbmc.getInfoLabel("ListItem.Plot"), "utf-8") server = "Directo" # -------------------------------------------------------- # DDownload page # -------------------------------------------------------- data = scrapertools.cachePage(url) pattern = "rtmp://cp67754.edgefcs.net/ondemand/mp4:content/Fakeloi/20.*?mp4" matches = re.compile(pattern, re.DOTALL).findall(data) if len(matches) == 0: xbmctools.alerterrorpagina() return url = matches[0] xbmc.log("url=" + url) xbmctools.play_video(CHANNELCODE, server, url, category, title, thumbnail, plot)
def youtubeplay(params, url, category): logger.info("[series21.py] youtubeplay") title = urllib.unquote_plus(params.get("title")) thumbnail = urllib.unquote_plus(params.get("thumbnail")) plot = "Ver Video" server = "Directo" id = youtube.Extract_id(url) # Abre el diálogo de selección opciones = [] opciones.append("(FLV) Baja calidad") opciones.append("(MP4) Alta calidad") dia = xbmcgui.Dialog() seleccion = dia.select("tiene 2 formatos elige uno", opciones) logger.info("seleccion=%d" % seleccion) if seleccion == -1: return ("") if seleccion == 0: videourl, videoinfo = youtube.GetYoutubeVideoInfo(id) else: videourl = youtube.geturl(id) logger.info("link directo de youtube : " + videourl) xbmctools.play_video("Trailer", server, videourl, category, title, thumbnail, plot)
def run(): logger.info("[launcher.py] run") # Test if all the required directories are created config.verify_directories_created() # Extract parameters from sys.argv params, fanart, channel_name, title, fulltitle, url, thumbnail, plot, action, server, extra, subtitle, viewmode, category, show, password = extract_parameters( ) logger.info( "[launcher.py] fanart=%s, channel_name=%s, title=%s, fulltitle=%s, url=%s, thumbnail=%s, plot=%s, action=%s, server=%s, extra=%s, subtitle=%s, category=%s, show=%s, password=%s" % (fanart, channel_name, title, fulltitle, url, thumbnail, plot, action, server, extra, subtitle, category, show, password)) try: # Accion por defecto - elegir canal if (action == "selectchannel"): # Borra el fichero de las cookies para evitar problemas con MV #ficherocookies = os.path.join( config.get_data_path(), 'cookies.lwp' ) #if os.path.exists(ficherocookies): # os.remove(ficherocookies) if config.get_setting("updatechannels") == "true": try: from core import updater actualizado = updater.updatechannel("channelselector") if actualizado: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("tvalacarta", config.get_localized_string(30064)) except: pass import channelselector as plugin plugin.mainlist() # Actualizar version elif (action == "update"): try: from core import updater updater.update(params) except ImportError: logger.info( "[launcher.py] Actualizacion automática desactivada") #import channelselector as plugin #plugin.listchannels(params, url, category) if config.get_system_platform() != "xbox": import xbmc xbmc.executebuiltin("Container.Refresh") # El resto de acciones vienen en el parámetro "action", y el canal en el parámetro "channel" else: if action == "mainlist" and config.get_setting( "updatechannels") == "true": try: from core import updater actualizado = updater.updatechannel(channel_name) if actualizado: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("plugin", channel_name, config.get_localized_string(30063)) except: pass # La acción puede estar en el core, o ser un canal regular. El buscador es un canal especial que está en pelisalacarta regular_channel_path = os.path.join(config.get_runtime_path(), PLUGIN_NAME, 'channels', channel_name + ".py") core_channel_path = os.path.join(config.get_runtime_path(), 'core', channel_name + ".py") logger.info("[launcher.py] regular_channel_path=%s" % regular_channel_path) logger.info("[launcher.py] core_channel_path=%s" % core_channel_path) if channel_name == "buscador": import pelisalacarta.buscador as channel elif os.path.exists(regular_channel_path): exec "import mywebtv.channels." + channel_name + " as channel" elif os.path.exists(regular_channel_path): exec "import tvalacarta.channels." + channel_name + " as channel" elif os.path.exists(core_channel_path): exec "from core import " + channel_name + " as channel" logger.info("[launcher.py] running channel %s %s" % (channel.__name__, channel.__file__)) generico = False # Esto lo he puesto asi porque el buscador puede ser generico o normal, esto estará asi hasta que todos los canales sean genericos if category == "Buscador_Generico": generico = True else: try: generico = channel.isGeneric() except: generico = False if not generico: logger.info("[launcher.py] xbmc native channel") if (action == "strm"): from platformcode.xbmc import xbmctools xbmctools.playstrm(params, url, category) else: exec "channel." + action + "(params, url, category)" else: logger.info("[launcher.py] multiplatform channel") from core.item import Item item = Item(channel=channel_name, title=title, fulltitle=fulltitle, url=url, thumbnail=thumbnail, plot=plot, server=server, category=category, extra=extra, subtitle=subtitle, viewmode=viewmode, show=show, password=password, fanart=fanart) ''' if item.subtitle!="": logger.info("[launcher.py] Downloading subtitle file "+item.subtitle) from core import downloadtools ficherosubtitulo = os.path.join( config.get_data_path() , "subtitulo.srt" ) if os.path.exists(ficherosubtitulo): os.remove(ficherosubtitulo) downloadtools.downloadfile(item.subtitle, ficherosubtitulo ) config.set_setting("subtitulo","true") else: logger.info("[launcher.py] No subtitle") ''' from platformcode.xbmc import xbmctools if action == "play": logger.info("[launcher.py] play") # Si el canal tiene una acción "play" tiene prioridad if hasattr(channel, 'play'): logger.info( "[launcher.py] executing channel 'play' method") itemlist = channel.play(item) if len(itemlist) > 0: item = itemlist[0] xbmctools.play_video(channel=channel_name, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password=item.password, fulltitle=item.fulltitle, Serie=item.show) else: import xbmcgui ventana_error = xbmcgui.Dialog() ok = ventana_error.ok( "plugin", "No hay nada para reproducir") else: logger.info( "[launcher.py] no channel 'play' method, executing core method" ) xbmctools.play_video(channel=channel_name, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password=item.password, fulltitle=item.fulltitle, Serie=item.show) elif action == "strm_detail" or action == "play_from_library": logger.info("[launcher.py] play_from_library") fulltitle = item.show + " " + item.title elegido = Item(url="") logger.info("item.server=#" + item.server + "#") # Ejecuta find_videos, del canal o común try: itemlist = channel.findvideos(item) except: from servers import servertools itemlist = servertools.find_video_items(item) if len(itemlist) > 0: #for item2 in itemlist: # logger.info(item2.title+" "+item2.subtitle) # El usuario elige el mirror opciones = [] for item in itemlist: opciones.append(item.title) import xbmcgui dia = xbmcgui.Dialog() seleccion = dia.select( config.get_localized_string(30163), opciones) elegido = itemlist[seleccion] if seleccion == -1: return else: elegido = item # Ejecuta el método play del canal, si lo hay try: itemlist = channel.play(elegido) item = itemlist[0] except: item = elegido logger.info("Elegido %s (sub %s)" % (item.title, item.subtitle)) from platformcode.xbmc import xbmctools logger.info("subtitle=" + item.subtitle) xbmctools.play_video(strmfile=True, channel=item.channel, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password=item.password, fulltitle=fulltitle) elif action == "add_pelicula_to_library": logger.info("[launcher.py] add_pelicula_to_library") from platformcode.xbmc import library # Obtiene el listado desde el que se llamó library.savelibrary(titulo=item.fulltitle, url=item.url, thumbnail=item.thumbnail, server=item.server, plot=item.plot, canal=item.channel, category="Cine", Serie=item.show.strip(), verbose=False, accion="play_from_library", pedirnombre=False, subtitle=item.subtitle) elif action == "add_serie_to_library": logger.info("[launcher.py] add_serie_to_library, show=" + item.show) from platformcode.xbmc import library import xbmcgui # Obtiene el listado desde el que se llamó action = item.extra # Esta marca es porque el item tiene algo más aparte en el atributo "extra" if "###" in item.extra: action = item.extra.split("###")[0] item.extra = item.extra.split("###")[1] exec "itemlist = channel." + action + "(item)" # Progreso pDialog = xbmcgui.DialogProgress() ret = pDialog.create('mywebtv', 'Añadiendo episodios...') pDialog.update(0, 'Añadiendo episodio...') totalepisodes = len(itemlist) logger.info("[launcher.py] Total Episodios:" + str(totalepisodes)) i = 0 errores = 0 nuevos = 0 for item in itemlist: i = i + 1 pDialog.update(i * 100 / totalepisodes, 'Añadiendo episodio...', item.title) if (pDialog.iscanceled()): return try: #(titulo="",url="",thumbnail="",server="",plot="",canal="",category="Cine",Serie="",verbose=True,accion="strm",pedirnombre=True): # Añade todos menos el último (el que dice "Añadir esta serie...") if i < len(itemlist): nuevos = nuevos + library.savelibrary( titulo=item.title, url=item.url, thumbnail=item.thumbnail, server=item.server, plot=item.plot, canal=item.channel, category="Series", Serie=item.show.strip(), verbose=False, accion="play_from_library", pedirnombre=False, subtitle=item.subtitle, extra=item.extra) except IOError: import sys for line in sys.exc_info(): logger.error("%s" % line) logger.info( "[launcher.py]Error al grabar el archivo " + item.title) errores = errores + 1 pDialog.close() # Actualizacion de la biblioteca itemlist = [] if errores > 0: itemlist.append( Item( title= "ERROR, la serie NO se ha añadido a la biblioteca o lo ha hecho incompleta" )) logger.info("[launcher.py] No se pudo añadir " + str(errores) + " episodios") else: itemlist.append( Item(title="La serie se ha añadido a la biblioteca" )) logger.info("[launcher.py] Ningún error al añadir " + str(errores) + " episodios") # FIXME:jesus Comentado porque no funciona bien en todas las versiones de XBMC #library.update(totalepisodes,errores,nuevos) xbmctools.renderItems(itemlist, params, url, category) #Lista con series para actualizar nombre_fichero_config_canal = os.path.join( config.get_data_path(), "series.xml") logger.info("nombre_fichero_config_canal=" + nombre_fichero_config_canal) if not os.path.exists(nombre_fichero_config_canal): f = open(nombre_fichero_config_canal, "w") else: f = open(nombre_fichero_config_canal, "r") contenido = f.read() f.close() f = open(nombre_fichero_config_canal, "w") f.write(contenido) f.write(item.show + "," + item.url + "," + item.channel + "\n") f.close() elif action == "download_all_episodes": download_all_episodes(item, channel) elif action == "search": logger.info("[launcher.py] search") import xbmc keyboard = xbmc.Keyboard("") keyboard.doModal() if (keyboard.isConfirmed()): tecleado = keyboard.getText() tecleado = tecleado.replace(" ", "+") itemlist = channel.search(item, tecleado) else: itemlist = [] xbmctools.renderItems(itemlist, params, url, category) else: logger.info("[launcher.py] executing channel '" + action + "' method") if action != "findvideos": exec "itemlist = channel." + action + "(item)" #for item in itemlist: # logger.info("viemode="+item.viewmode) else: # Intenta ejecutar una posible funcion "findvideos" del canal if hasattr(channel, 'findvideos'): exec "itemlist = channel." + action + "(item)" # Si no funciona, lanza el método genérico para detectar vídeos else: logger.info( "[launcher.py] no channel 'findvideos' method, executing core method" ) from servers import servertools itemlist = servertools.find_video_items(item) from core import subtitletools subtitletools.saveSubtitleName(item) # Activa el modo biblioteca para todos los canales genéricos, para que se vea el argumento import xbmcplugin import sys handle = sys.argv[1] xbmcplugin.setContent(int(handle), "movies") # Añade los items a la lista de XBMC xbmctools.renderItems(itemlist, params, url, category) except urllib2.URLError, e: import traceback, sys from pprint import pprint exc_type, exc_value, exc_tb = sys.exc_info() lines = traceback.format_exception(exc_type, exc_value, exc_tb) for line in lines: line_splits = line.split("\n") for line_split in line_splits: logger.error(line_split) import xbmcgui ventana_error = xbmcgui.Dialog() # Agarra los errores surgidos localmente enviados por las librerias internas if hasattr(e, 'reason'): logger.info("Razon del error, codigo: %d , Razon: %s" % (e.reason[0], e.reason[1])) texto = config.get_localized_string( 30050) # "No se puede conectar con el sitio web" ok = ventana_error.ok("plugin", texto) # Agarra los errores con codigo de respuesta del servidor externo solicitado elif hasattr(e, 'code'): logger.info("codigo de error HTTP : %d" % e.code) texto = ( config.get_localized_string(30051) % e.code ) # "El sitio web no funciona correctamente (error http %d)" ok = ventana_error.ok("plugin", texto)
def run(): logger.info("[launcher.py] run") # Test if all the required directories are created config.verify_directories_created() # Extract parameters from sys.argv params, channel_name, title, fulltitle, url, thumbnail, plot, action, server, extra, subtitle, category, show, password = extract_parameters() logger.info("[launcher.py] channel_name=%s, title=%s, fulltitle=%s, url=%s, thumbnail=%s, plot=%s, action=%s, server=%s, extra=%s, subtitle=%s, category=%s, show=%s, password=%s" % (channel_name, title, fulltitle, url, thumbnail, plot, action, server, extra, subtitle, category, show, password)) try: # Accion por defecto - elegir canal if ( action=="selectchannel" ): # Borra el fichero de las cookies para evitar problemas con MV #ficherocookies = os.path.join( config.get_data_path(), 'cookies.lwp' ) #if os.path.exists(ficherocookies): # os.remove(ficherocookies) if config.get_setting("updatechannels")=="true": try: from core import updater actualizado = updater.updatechannel("channelselector") if actualizado: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("tvalacarta",config.get_localized_string(30064)) except: pass import channelselector as plugin plugin.mainlist(params, url, category) # Actualizar version elif ( action=="update" ): try: from core import updater updater.update(params) except ImportError: logger.info("[launcher.py] Actualizacion automática desactivada") import channelselector as plugin plugin.listchannels(params, url, category) elif (action=="channeltypes"): import channelselector as plugin plugin.channeltypes(params,url,category) elif (action=="listchannels"): import channelselector as plugin plugin.listchannels(params,url,category) # El resto de acciones vienen en el parámetro "action", y el canal en el parámetro "channel" else: if action=="mainlist" and config.get_setting("updatechannels")=="true": try: from core import updater actualizado = updater.updatechannel(channel_name) if actualizado: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("plugin",channel_name,config.get_localized_string(30063)) except: pass # La acción puede estar en el core, o ser un canal regular. El buscador es un canal especial que está en pelisalacarta regular_channel_path = os.path.join( config.get_runtime_path(), PLUGIN_NAME , 'channels' , channel_name+".py" ) core_channel_path = os.path.join( config.get_runtime_path(), 'core' , channel_name+".py" ) logger.info("[launcher.py] regular_channel_path=%s" % regular_channel_path) logger.info("[launcher.py] core_channel_path=%s" % core_channel_path) if channel_name=="buscador": import pelisalacarta.buscador as channel elif os.path.exists( regular_channel_path ): exec "import "+PLUGIN_NAME+".channels."+channel_name+" as channel" elif os.path.exists( core_channel_path ): exec "from core import "+channel_name+" as channel" logger.info("[launcher.py] running channel %s %s" % (channel.__name__ , channel.__file__)) generico = False # Esto lo he puesto asi porque el buscador puede ser generico o normal, esto estará asi hasta que todos los canales sean genericos if category == "Buscador_Generico": generico = True else: try: generico = channel.isGeneric() except: generico = False if not generico: logger.info("[launcher.py] xbmc native channel") if (action=="strm"): from platformcode.xbmc import xbmctools xbmctools.playstrm(params, url, category) else: exec "channel."+action+"(params, url, category)" else: logger.info("[launcher.py] multiplatform channel") from core.item import Item item = Item(channel=channel_name, title=title , fulltitle=fulltitle, url=url, thumbnail=thumbnail , plot=plot , server=server, category=category, extra=extra, subtitle=subtitle, show=show, password=password) ''' if item.subtitle!="": logger.info("[launcher.py] Downloading subtitle file "+item.subtitle) from core import downloadtools ficherosubtitulo = os.path.join( config.get_data_path() , "subtitulo.srt" ) if os.path.exists(ficherosubtitulo): os.remove(ficherosubtitulo) downloadtools.downloadfile(item.subtitle, ficherosubtitulo ) config.set_setting("subtitulo","true") else: logger.info("[launcher.py] No subtitle") ''' from platformcode.xbmc import xbmctools if action=="play": logger.info("[launcher.py] play") # Si el canal tiene una acción "play" tiene prioridad if hasattr(channel, 'play'): logger.info("[launcher.py] executing channel 'play' method") itemlist = channel.play(item) if len(itemlist)>0: item = itemlist[0] xbmctools.play_video(channel=channel_name, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password = item.password, fulltitle=item.fulltitle) else: import xbmcgui ventana_error = xbmcgui.Dialog() ok = ventana_error.ok ("plugin", "No hay nada para reproducir") else: logger.info("[launcher.py] no channel 'play' method, executing core method") xbmctools.play_video(channel=channel_name, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password = item.password, fulltitle=item.fulltitle) elif action=="strm_detail" or action=="play_from_library": logger.info("[launcher.py] play_from_library") fulltitle = item.show + " " + item.title elegido = Item(url="") logger.info("item.server=#"+item.server+"#") # Ejecuta find_videos, del canal o común try: itemlist = channel.findvideos(item) except: from servers import servertools itemlist = servertools.find_video_items(item) if len(itemlist)>0: #for item2 in itemlist: # logger.info(item2.title+" "+item2.subtitle) # El usuario elige el mirror opciones = [] for item in itemlist: opciones.append(item.title) import xbmcgui dia = xbmcgui.Dialog() seleccion = dia.select(config.get_localized_string(30163), opciones) elegido = itemlist[seleccion] if seleccion==-1: return else: elegido = item # Ejecuta el método play del canal, si lo hay try: itemlist = channel.play(elegido) item = itemlist[0] except: item = elegido logger.info("Elegido %s (sub %s)" % (item.title,item.subtitle)) from platformcode.xbmc import xbmctools logger.info("subtitle="+item.subtitle) xbmctools.play_video(strmfile=True, channel=item.channel, server=item.server, url=item.url, category=item.category, title=item.title, thumbnail=item.thumbnail, plot=item.plot, extra=item.extra, subtitle=item.subtitle, video_password = item.password, fulltitle=fulltitle) elif action=="add_pelicula_to_library": logger.info("[launcher.py] add_pelicula_to_library") from platformcode.xbmc import library # Obtiene el listado desde el que se llamó library.savelibrary( titulo=item.fulltitle , url=item.url , thumbnail=item.thumbnail , server=item.server , plot=item.plot , canal=item.channel , category="Cine" , Serie=item.show.strip() , verbose=False, accion="play_from_library", pedirnombre=False, subtitle=item.subtitle ) elif action=="add_serie_to_library": logger.info("[launcher.py] add_serie_to_library") from platformcode.xbmc import library import xbmcgui # Obtiene el listado desde el que se llamó action = item.extra exec "itemlist = channel."+action+"(item)" # Progreso pDialog = xbmcgui.DialogProgress() ret = pDialog.create('pelisalacarta', 'Añadiendo episodios...') pDialog.update(0, 'Añadiendo episodio...') totalepisodes = len(itemlist) logger.info ("[launcher.py] Total Episodios:"+str(totalepisodes)) i = 0 errores = 0 nuevos = 0 for item in itemlist: i = i + 1 pDialog.update(i*100/totalepisodes, 'Añadiendo episodio...',item.title) if (pDialog.iscanceled()): return try: #(titulo="",url="",thumbnail="",server="",plot="",canal="",category="Cine",Serie="",verbose=True,accion="strm",pedirnombre=True): # Añade todos menos el último (el que dice "Añadir esta serie...") if i<len(itemlist): nuevos = nuevos + library.savelibrary( titulo=item.title , url=item.url , thumbnail=item.thumbnail , server=item.server , plot=item.plot , canal=item.channel , category="Series" , Serie=item.show.strip() , verbose=False, accion="play_from_library", pedirnombre=False, subtitle=item.subtitle ) except IOError: import sys for line in sys.exc_info(): logger.error( "%s" % line ) logger.info("[launcher.py]Error al grabar el archivo "+item.title) errores = errores + 1 pDialog.close() # Actualizacion de la biblioteca itemlist=[] if errores > 0: itemlist.append(Item(title="ERROR, la serie NO se ha añadido a la biblioteca o lo ha hecho incompleta")) logger.info ("[launcher.py] No se pudo añadir "+str(errores)+" episodios") else: itemlist.append(Item(title="La serie se ha añadido a la biblioteca")) logger.info ("[launcher.py] Ningún error al añadir "+str(errores)+" episodios") # FIXME:jesus Comentado porque no funciona bien en todas las versiones de XBMC #library.update(totalepisodes,errores,nuevos) xbmctools.renderItems(itemlist, params, url, category) #Lista con series para actualizar nombre_fichero_config_canal = os.path.join( config.get_data_path() , "series.xml" ) logger.info("nombre_fichero_config_canal="+nombre_fichero_config_canal) if not os.path.exists(nombre_fichero_config_canal): f = open( nombre_fichero_config_canal , "w" ) else: f = open( nombre_fichero_config_canal , "r" ) contenido = f.read() f.close() f = open( nombre_fichero_config_canal , "w" ) f.write(contenido) f.write(item.show+","+item.url+","+item.channel+"\n") f.close(); elif action=="download_all_episodes": download_all_episodes(item,channel) elif action=="search": logger.info("[launcher.py] search") import xbmc keyboard = xbmc.Keyboard("") keyboard.doModal() if (keyboard.isConfirmed()): tecleado = keyboard.getText() tecleado = tecleado.replace(" ", "+") itemlist = channel.search(item,tecleado) else: itemlist = [] xbmctools.renderItems(itemlist, params, url, category) else: logger.info("[launcher.py] executing channel '"+action+"' method") if action!="findvideos": exec "itemlist = channel."+action+"(item)" else: # Intenta ejecutar una posible funcion "findvideos" del canal try: exec "itemlist = channel."+action+"(item)" # Si no funciona, lanza el método genérico para detectar vídeos except: logger.info("[launcher.py] no channel 'findvideos' method, executing core method") from servers import servertools itemlist = servertools.find_video_items(item) from core import subtitletools subtitletools.saveSubtitleName(item) # Activa el modo biblioteca para todos los canales genéricos, para que se vea el argumento import xbmcplugin import sys handle = sys.argv[1] xbmcplugin.setContent(int( handle ),"movies") # Añade los items a la lista de XBMC xbmctools.renderItems(itemlist, params, url, category) except urllib2.URLError,e: import traceback import sys from pprint import pprint exc_type, exc_value, exc_tb = sys.exc_info() lines = traceback.format_exception(exc_type, exc_value, exc_tb) for line in lines: line_splits = line.split("\n") for line_split in line_splits: logger.error(line_split) import xbmcgui ventana_error = xbmcgui.Dialog() # Agarra los errores surgidos localmente enviados por las librerias internas if hasattr(e, 'reason'): logger.info("Razon del error, codigo: %d , Razon: %s" %(e.reason[0],e.reason[1])) texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web" ok = ventana_error.ok ("plugin", texto) # Agarra los errores con codigo de respuesta del servidor externo solicitado elif hasattr(e,'code'): logger.info("codigo de error HTTP : %d" %e.code) texto = (config.get_localized_string(30051) % e.code) # "El sitio web no funciona correctamente (error http %d)" ok = ventana_error.ok ("plugin", texto)
def playVideo_OLD(params,url,category,strmfile=False): '''Reproduce el video seleccionado En desuso desde los cambios de febrero 2011 ''' logger.info("[tvshack.py] playVideo") if params.has_key("Serie"): serie = params.get("Serie") else: serie = "" if (params.has_key("category")): category = params.get("category") title = urllib.unquote_plus( params.get("title") ) if params.has_key("thumbnail"): thumbnail = urllib.unquote_plus( params.get("thumbnail") ) else: thumbnail = '' if params.has_key("plot"): plot = params.get("plot") else: plot = xbmc.getInfoLabel( "ListItem.Plot" ) server = params["server"] if DEBUG: logger.info("[tvshack.py] url="+url) logger.info("[tvshack.py] title="+title) logger.info("[tvshack.py] plot="+plot) logger.info("[tvshack.py] thumbnail="+thumbnail) logger.info("[tvshack.py] server="+server) # Descarga la p�gina data = scrapertools.cachePage(url) #Averiguamos las partes del video (Puede tener m�s de una) partes = re.findall('<a href="javascript:changevid\(([0-9]+)\);"',data) # Y el path relativo de los v�deos #JUR CAMBIO EN WEB 01/04/2010 # patronpath = '''(?x) # Activa opci�n VERBOSE. # http://tvshack\.bz/report_video/ # Basura # ([^/]+/[^/]+) # $0 = Path relativo Ej. 'tv/716063' # /","report" # Basura # ''' patronpath = '''(?x) # Activa opci�n VERBOSE. http://tvshack\.bz/video_load/ # Basura ([^/]+/[^/]+) # $0 = Path relativo Ej. 'tv/716063' /'\+part # Basura ''' paths=re.findall(patronpath,data) #JUR-PROV: De momento voy a considerar los v�deos de 1 s�la parte. # Para los v�deos con m�s partes habr� que crear una funci�n especial que # pregunte una sola vez y meta todos los v�deos juntos. if len(partes) > 1: logger.info ("[tvshack] playVideo - Video multiparte - pendiente:" + str(len(partes))) dialog = xbmcgui.Dialog() dialog.ok('pelisalacarta - tvshack','Este video tiene varias partes.','En esta versi�n de pelisalacarta no est�n soportados.','Eliga otro video con una s�la parte.') # for parte in partes: elif len(partes) == 1: url = 'http://tvshack.bz/video_load/'+paths[0] + '/' + partes[0] #Esta URL sigue sin ser un enlace megaupload u otro servidor v�lido por lo que seguimos scrapeando # para evitar excesivas selecciones por parte del usuario. # Descarga la p�gina data2 = scrapertools.cachePage(url) if server == 'megavideo': dlog ("[tvshack.py]playVideo: Server= megavideo") # #Ej.<embed src="http://www.megavideo.com/v/5ZZHOM74... patronpath = '''(?x) # Activa opci�n VERBOSE. <embed\ src="http://www\.megavideo\.com/v/ # Basura (.{8}) # $0 = url megavideo Ej. '5ZZHOM74' ''' mediaurl=re.findall(patronpath,data2) if len (mediaurl) == 0: dlog ("[tvshack.py]playVideo: No se encontr� la url de megavideo en:") dlog (data2) dialog = xbmcgui.Dialog() dialog.ok('pelisalacarta - tvshack','No se encontr� el video en megavideo.','Eliga otro video.') return elif len (mediaurl) > 1: dlog ("[tvshack.py]playVideo: Hay m�s de un enlace de megavideo (y no deber�a)") for url in mediaurl: dlog (url) mediaurl = mediaurl[0] # xbmctools.play_video(CHANNELNAME,server,mediaurl,category,title,thumbnail,plot,Serie=Serie) dlog ("[tvshack.py]playVideo: Llamando al play. mediaurl= "+mediaurl) xbmctools.play_video(CHANNELNAME,'Megavideo',mediaurl,category,title,'','',Serie=serie,strmfile=strmfile) else: # Video de otro servidor (no megavideo) #Probamos si es flash... flashmatch = re.search('flashvars="file=(.+?)&type=flv',data2) if flashmatch != None: dlog ('[tvshack.py]playVideo: Video flash - url = ' + flashmatch.group(1)) xbmctools.play_video(CHANNELNAME,'Directo',flashmatch.group(1),category,title,'','',Serie=serie,strmfile=strmfile) return #Si no, buscamos otras fuentes de video othersmatch = re.search('src="([^"]+)"',data2) if othersmatch != None and server in ALLOWED_SERVERS: url = othersmatch.group(1).replace('&','&') xbmctools.play_video(CHANNELNAME,server,url,category,title,'','',Serie=serie,strmfile=strmfile) return dlog ("[tvshack.py]playVideo: Servidor no soportado: "+server) dialog = xbmcgui.Dialog() dialog.ok('pelisalacarta - tvshack - '+server,'El video seleccionado es de '+server,'Ese servidor a�n no est� soportado en TVShack.') return
def playVideo(params,url,category,strmfile=False): '''Reproduce el video seleccionado Actualizado a cambios de febrero 2011 ''' logger.info("[tvshack.py] playVideo") if params.has_key("Serie"): serie = params.get("Serie") else: serie = "" if (params.has_key("category")): category = params.get("category") title = urllib.unquote_plus( params.get("title") ) if params.has_key("thumbnail"): thumbnail = urllib.unquote_plus( params.get("thumbnail") ) else: thumbnail = '' if params.has_key("plot"): plot = params.get("plot") else: plot = xbmc.getInfoLabel( "ListItem.Plot" ) server = params["server"] if DEBUG: logger.info("[tvshack.py] url="+url) logger.info("[tvshack.py] title="+title) logger.info("[tvshack.py] plot="+plot) logger.info("[tvshack.py] thumbnail="+thumbnail) logger.info("[tvshack.py] server="+server) # Descarga la página data = scrapertools.cachePage(url) if server == 'megavideo' or server == 'megaupload': dlog ("[tvshack.py]playVideo: Server= megavideo") # #Ej. <param name="movie" value="http://wwwstatic.megavideo.com/mv_player.swf?image=http://tvshack.bz/images/splash.jpg&v=HEIFJJ0E"> patronpath = '''(?x) # Activa opción VERBOSE. &v= # Basura (.{8})"> # $0 = url megavideo Ej. '5ZZHOM74' or 'HEIFJJ0E' ''' mediaurl=re.findall(patronpath,data) if len (mediaurl) == 0: dlog ("[tvshack.py]playVideo: No se encontró la url de megavideo en:") dlog (data) dialog = xbmcgui.Dialog() dialog.ok('pelisalacarta - tvshack','No se encontr� el video en megavideo.','Eliga otro video.') return elif len (mediaurl) > 1: dlog ("[tvshack.py]playVideo: Hay más de un enlace de megavideo (y no debería)") for url in mediaurl: dlog (url) mediaurl = mediaurl[0] # xbmctools.play_video(CHANNELNAME,server,mediaurl,category,title,thumbnail,plot,Serie=Serie) dlog ("[tvshack.py]playVideo: Llamando al play. mediaurl= "+mediaurl) xbmctools.play_video(CHANNELNAME,'Megavideo',mediaurl,category,title,'','',Serie=serie,strmfile=strmfile) else: # Video de otro servidor (no megavideo) #Probamos si es flash... flashmatch = re.search('flashvars="file=(.+?)&type=flv',data) if flashmatch != None: dlog ('[tvshack.py]playVideo: Video flash - url = ' + flashmatch.group(1)) xbmctools.play_video(CHANNELNAME,'Directo',flashmatch.group(1),category,title,'','',Serie=serie,strmfile=strmfile) return #Si no, buscamos otras fuentes de video othersmatch = re.search('src="([^"]+)"',data) if othersmatch != None and server in ALLOWED_SERVERS: url = othersmatch.group(1).replace('&','&') xbmctools.play_video(CHANNELNAME,server,url,category,title,'','',Serie=serie,strmfile=strmfile) return dlog ("[tvshack.py]playVideo: Servidor no soportado: "+server) dialog = xbmcgui.Dialog() dialog.ok('pelisalacarta - tvshack - '+server,'El video seleccionado es de '+server,'Ese servidor aún no está soportado en TVShack.') return