def get_thumbnail(thumb_name=None): img_path = config.get_runtime_path() + '/resources/images/squares' if thumb_name: file_path = os.path.join(img_path, thumb_name) if os.path.isfile(file_path): thumb_path = file_path else: thumb_path = urlparse.urljoin(get_thumbnail_path(), thumb_name) else: thumb_path = urlparse.urljoin(get_thumbnail_path(), thumb_name) return thumb_path
def mainlist(item): logger.info("[pelisadicto.py] mainlist") thumb_buscar = get_thumbnail_path() + "thumb_buscar.png" itemlist = [] itemlist.append( Item(channel=item.channel, title="Últimas agregadas", action="agregadas", url="http://www.descargacineclasico.net/", viewmode="movie_with_plot")) itemlist.append( Item(channel=item.channel, title="Listado por género", action="porGenero", url="http://www.descargacineclasico.net/")) itemlist.append( Item(channel=item.channel, title="Buscar", action="search", url="http://www.descargacineclasico.net/", thumbnail=thumb_buscar)) return itemlist
def mainlist(item): logger.info("[pelisadicto.py] mainlist") thumb_buscar = get_thumbnail_path()+ "thumb_buscar.png" itemlist = [] itemlist.append( Item(channel=__channel__, title="Últimas agregadas" , action="agregadas", url="http://www.descargacineclasico.net/")) itemlist.append( Item(channel=__channel__, title="Listado por género" , action="porGenero", url="http://www.descargacineclasico.net/")) itemlist.append( Item(channel=__channel__, title="Buscar" , action="search", url="http://www.descargacineclasico.net/", thumbnail=thumb_buscar) ) return itemlist
def run(): logger.info("pelisalacarta.platformcode.launcher run") # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) # If no item, this is mainlist else: item = Item(action="selectchannel", viewmode="movie") logger.info("pelisalacarta.platformcode.launcher "+item.tostring()) # Set server filters server_white_list = [] server_black_list = [] if config.get_setting('filter_servers') == 'true': server_white_list, server_black_list = set_server_list() try: # If item has no action, stops here if item.action == "": logger.info("pelisalacarta.platformcode.launcher Item sin accion") return # Action for main menu in channelselector if ( item.action=="selectchannel" ): import channelselector itemlist = channelselector.getmainlist() # Check for updates only on first screen if config.get_setting("updatecheck2") == "true": logger.info("pelisalacarta.platformcode.launcher Check for plugin updates enabled") from core import updater try: version = updater.checkforupdates() if version: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("Versión "+version+" disponible","Ya puedes descargar la nueva versión del plugin\ndesde el listado principal") itemlist.insert(0,Item(title="Descargar version "+version, version=version, channel="updater", action="update", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png")) except: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("No se puede conectar","No ha sido posible comprobar","si hay actualizaciones") logger.info("cpelisalacarta.platformcode.launcher Fallo al verificar la actualización") else: logger.info("pelisalacarta.platformcode.launcher Check for plugin updates disabled") xbmctools.renderItems(itemlist, item) # Action for updating plugin elif (item.action=="update"): from core import updater updater.update(item) if config.get_system_platform()!="xbox": import xbmc xbmc.executebuiltin( "Container.Refresh" ) # Action for channel types on channelselector: movies, series, etc. elif (item.action=="channeltypes"): import channelselector itemlist = channelselector.getchanneltypes() xbmctools.renderItems(itemlist, item) # Action for channel listing on channelselector elif (item.action=="listchannels"): import channelselector itemlist = channelselector.filterchannels(item.category) xbmctools.renderItems(itemlist, item) # Action in certain channel specified in "action" and "channel" parameters else: # Entry point for a channel is the "mainlist" action, so here we check parental control if item.action=="mainlist": # Parental control can_open_channel = False # If it is an adult channel, and user has configured pin, asks for it if channeltools.is_adult(item.channel) and config.get_setting("adult_pin")!="": import xbmc keyboard = xbmc.Keyboard("","PIN para canales de adultos",True) keyboard.doModal() if (keyboard.isConfirmed()): tecleado = keyboard.getText() if tecleado==config.get_setting("adult_pin"): can_open_channel = True # All the other cases can open the channel else: can_open_channel = True if not can_open_channel: return # Checks if channel exists channel_file = os.path.join(config.get_runtime_path(), 'channels', item.channel+".py") logger.info("pelisalacarta.platformcode.launcher channel_file=%s" % channel_file) if item.channel in ["personal","personal2","personal3","personal4","personal5"]: import channels.personal as channel elif os.path.exists(channel_file): channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel]) logger.info("pelisalacarta.platformcode.launcher running channel {0} {1}".format(channel.__name__, channel.__file__)) # Special play action if item.action == "play": logger.info("pelisalacarta.platformcode.launcher play") # Mark as watched item on Library channel id_video = 0 category = '' if 'infoLabels' in item: if 'episodeid' in item.infoLabels and item.infoLabels['episodeid']: category = 'Series' id_video = item.infoLabels['episodeid'] elif 'movieid' in item.infoLabels and item.infoLabels['movieid']: category = 'Movies' id_video = item.infoLabels['movieid'] # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info("pelisalacarta.platformcode.launcher executing channel 'play' method") itemlist = channel.play(item) # Play should return a list of playable URLS if len(itemlist) > 0: item = itemlist[0] xbmctools.play_video(item) if id_video != 0: library.mark_as_watched(category, id_video) # If not, shows user an error message else: import xbmcgui ventana_error = xbmcgui.Dialog() ok = ventana_error.ok("plugin", "No hay nada para reproducir") # If player don't have a "play" function, not uses the standard play from xbmctools else: logger.info("pelisalacarta.platformcode.launcher executing core 'play' method") xbmctools.play_video(item) if id_video != 0: library.mark_as_watched(category, id_video) # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": # First checks if channel has a "findvideos" function if hasattr(channel, 'findvideos'): itemlist = getattr(channel, item.action)(item) if config.get_setting('filter_servers') == 'true': itemlist = filtered_servers(itemlist, server_white_list, server_black_list) # If not, uses the generic findvideos function else: logger.info("pelisalacarta.platformcode.launcher no channel 'findvideos' method, executing core method") from core import servertools itemlist = servertools.find_video_items(item) if config.get_setting('filter_servers') == 'true': itemlist = filtered_servers(itemlist, server_white_list, server_black_list) # Copy infolabels from parent item if 'infoLabels' in item: # All but title if 'title' in item.infoLabels: item.infoLabels.pop('title') new_itemlist = itemlist[:] itemlist = [] for i in new_itemlist: itemlist.append(i.clone(infoLabels=item.infoLabels)) from platformcode import subtitletools subtitletools.saveSubtitleName(item) # Show xbmc items as "movies", so plot is visible import xbmcplugin handle = sys.argv[1] xbmcplugin.setContent(int( handle ),"movies") # Add everything to XBMC item list if type(itemlist) == list and itemlist: xbmctools.renderItems(itemlist, item) # If not, it shows an empty list # FIXME: Aquí deberíamos mostrar alguna explicación del tipo "No hay elementos, esto pasa por bla bla bla" else: xbmctools.renderItems([], item) # Special action for playing a video from the library elif item.action == "play_from_library": play_from_library(item, channel, server_white_list, server_black_list) # Special action for adding a movie to the library elif item.action == "add_pelicula_to_library": library.add_pelicula_to_library(item) # Special action for adding a serie to the library elif item.action == "add_serie_to_library": library.add_serie_to_library(item, channel) # Special action for downloading all episodes from a serie elif item.action == "download_all_episodes": downloadtools.download_all_episodes(item, channel) # Special action for searching, first asks for the words then call the "search" function elif item.action=="search": logger.info("pelisalacarta.platformcode.launcher 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, item) # For all other actions else: logger.info("pelisalacarta.platformcode.launcher executing channel '"+item.action+"' method") itemlist = getattr(channel, item.action)(item) # Activa el modo biblioteca para todos los canales genéricos, para que se vea el argumento import xbmcplugin handle = sys.argv[1] xbmcplugin.setContent(int( handle ),"movies") # Añade los items a la lista de XBMC if type(itemlist) == list and itemlist: xbmctools.renderItems(itemlist, item) # If not, it shows an empty list # FIXME: Aquí deberíamos mostrar alguna explicación del tipo "No hay elementos, esto pasa por bla bla bla" else: xbmctools.renderItems([], item) except urllib2.URLError,e: import traceback logger.error("pelisalacarta.platformcode.launcher "+traceback.format_exc()) import xbmcgui ventana_error = xbmcgui.Dialog() # Grab inner and third party errors if hasattr(e, 'reason'): logger.info("pelisalacarta.platformcode.launcher Razon del error, codigo: {0}, Razon: {1}".format(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) # Grab server response errors elif hasattr(e,'code'): logger.info("pelisalacarta.platformcode.launcher 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("dss.platformcode.launcher run") # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) # If no item, this is mainlist else: item = Item(channel="channelselector", action="getmainlist", viewmode="movie") if item.action != "actualiza": logger.info("dss.platformcode.launcher " + item.tostring()) try: if item.action == "editor_keymap": from platformcode import editor_keymap return editor_keymap.start() # If item has no action, stops here if item.action == "": logger.info("dss.platformcode.launcher Item sin accion") return # Action for main menu in channelselector if item.action == "getmainlist": import channelselector itemlist = channelselector.getmainlist() # Check for updates only on first screen if config.get_setting("updatecheck") == "true": logger.info("Check for plugin updates enabled") from core import updater try: update, version_publicada, message, url_repo, serv = updater.check( ) if update: new_item = Item( title="Descargar versión " + version_publicada, channel="updater", action="actualiza", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png", version=version_publicada, url=url_repo, server=serv) if config.get_setting("updateauto") == "true": updater.actualiza(new_item) new_item = Item( title= "Info para ver los cambios en la nueva versión instalada", plot=message, action="", channel="", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png", text_color="red") itemlist.insert(0, new_item) else: platformtools.dialog_ok( "Versión " + version_publicada + " disponible", message) itemlist.insert(0, new_item) except: import traceback logger.info(traceback.format_exc()) logger.info( "dss.platformcode.launcher Fallo al verificar la actualización" ) else: logger.info( "dss.platformcode.launcher Check for plugin updates disabled" ) if not config.get_setting("primer_uso_matchcenter"): config.set_setting("primer_uso_matchcenter", "true") platformtools.dialog_ok( "MatchCenter activado", "Reinicia Kodi para usarlo (pulsar tecla U)", "La tecla, botones y otras opciones pueden cambiarse en Configuración -> Preferencias -> MatchCenter" ) file_keyboard = xbmc.translatePath( "special://profile/keymaps/deportesalacarta.xml") if config.get_setting( "matchcenter_enabled" ) == "true" and not os.path.exists(file_keyboard): tecla = "61525" tecla_guardada = config.get_setting("keymap_edit", "editor_keymap") if tecla_guardada: tecla = tecla_guardada from core import filetools data = '<keymap><global><keyboard><key id="%s">' % tecla + 'runplugin(plugin://plugin.video.dss/?ewogICAgImFjdGlvbiI6ICJzdGFydCIsIAogICAgImNoYW5uZWwiOiAibWF0Y2hjZW50ZXIiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D))</key></keyboard></global></keymap>' filetools.write(file_keyboard, data) elif config.get_setting( "matchcenter_enabled") == "false" and os.path.exists( file_keyboard): from core import filetools try: filetools.remove(file_keyboard) except: pass platformtools.render_items(itemlist, item) # Action for updating plugin elif item.action == "actualiza": from core import updater updater.actualiza(item) xbmc.executebuiltin("Container.Refresh") # Action for channel listing on channelselector elif item.action == "filterchannels": import channelselector itemlist = channelselector.filterchannels(item.channel_type) platformtools.render_items(itemlist, item) # Action in certain channel specified in "action" and "channel" parameters else: can_open_channel = True # Checks if channel exists channel_file = os.path.join(config.get_runtime_path(), 'channels', item.channel + ".py") logger.info("dss.platformcode.launcher channel_file=%s" % channel_file) channel = None if os.path.exists(channel_file): try: channel = __import__('channels.%s' % item.channel, None, None, ["channels.%s" % item.channel]) except ImportError: exec "import channels." + item.channel + " as channel" logger.info( "deportesalacarta.platformcode.launcher running channel " + channel.__name__ + " " + channel.__file__) # Special play action if item.action == "play": logger.info("dss.platformcode.launcher play") # logger.debug("item_toPlay: " + "\n" + item.tostring('\n')) # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info( "dss.platformcode.launcher executing channel 'play' method" ) itemlist = channel.play(item) b_favourite = item.isFavourite # Play should return a list of playable URLS if len(itemlist) > 0 and isinstance(itemlist[0], Item): item = itemlist[0] if b_favourite: item.isFavourite = True platformtools.play_video(item) #Permitir varias calidades desde play en el canal elif len(itemlist) > 0 and isinstance(itemlist[0], list): item.video_urls = itemlist platformtools.play_video(item) # If not, shows user an error message else: platformtools.dialog_ok("plugin", "There is nothing to play") # If player don't have a "play" function, not uses the standard play from platformtools else: logger.info( "dss.platformcode.launcher executing core 'play' method" ) platformtools.play_video(item) # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": # First checks if channel has a "findvideos" function if hasattr(channel, 'findvideos'): itemlist = getattr(channel, item.action)(item) # If not, uses the generic findvideos function else: logger.info( "dss.platformcode.launcher no channel 'findvideos' method, " "executing core method") from core import servertools itemlist = servertools.find_video_items(item) platformtools.render_items(itemlist, item) # Special action for searching, first asks for the words then call the "search" function elif item.action == "search": logger.info("dss.platformcode.launcher search") tecleado = platformtools.dialog_input("") if tecleado is not None: tecleado = tecleado.replace(" ", "+") # TODO revisar 'personal.py' porque no tiene función search y daría problemas itemlist = channel.search(item, tecleado) else: itemlist = [] platformtools.render_items(itemlist, item) # For all other actions else: logger.info("dss.platformcode.launcher executing channel '" + item.action + "' method") itemlist = getattr(channel, item.action)(item) platformtools.render_items(itemlist, item) except urllib2.URLError, e: import traceback logger.error("dss.platformcode.launcher " + traceback.format_exc()) # Grab inner and third party errors if hasattr(e, 'reason'): logger.info("dss.platformcode.launcher Razon del error, codigo: " + str(e.reason[0]) + ", Razon: " + str(e.reason[1])) texto = config.get_localized_string( 30050) # "No se puede conectar con el sitio web" platformtools.dialog_ok("plugin", texto) # Grab server response errors elif hasattr(e, 'code'): logger.info("dss.platformcode.launcher codigo de error HTTP : %d" % e.code) # "El sitio web no funciona correctamente (error http %d)" platformtools.dialog_ok( "plugin", config.get_localized_string(30051) % e.code)
def run(): logger.info("streamondemand.platformcode.launcher run") # The start() function is not always executed on old platforms (XBMC versions under 12.0) if config.OLD_PLATFORM: config.verify_directories_created() # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) # If no item, this is mainlist else: item = Item(action="selectchannel", viewmode="movie") logger.info("streamondemand.platformcode.launcher " + item.tostring()) # Set server filters server_white_list = [] server_black_list = [] if config.get_setting('filter_servers') == 'true': server_white_list, server_black_list = set_server_list() try: # If item has no action, stops here if item.action == "": logger.info("streamondemand.platformcode.launcher Item sin accion") return # Action for main menu in channelselector if (item.action == "selectchannel"): import channelselector itemlist = channelselector.getmainlist() # Check for updates only on first screen if config.get_setting("updatecheck2") == "true": logger.info( "streamondemand.platformcode.launcher Check for plugin updates enabled" ) from core import updater try: version = updater.checkforupdates() if version: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok( "Versione " + version + " disponible", "E' possibile fare il download della nuova versione\nselezionare la relativa voce nel menu principale" ) itemlist.insert( 0, Item( title="Download versione " + version, version=version, channel="updater", action="update", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png")) except: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("Impossibile connettersi", "Non è stato possibile verificare", "aggiornamenti") logger.info( "cstreamondemand.platformcode.launcher Fallo al verificar la actualización" ) else: logger.info( "streamondemand.platformcode.launcher Check for plugin updates disabled" ) xbmctools.renderItems(itemlist, item) # Action for updating plugin elif (item.action == "update"): from core import updater updater.update(item) if config.get_system_platform() != "xbox": import xbmc xbmc.executebuiltin("Container.Refresh") # Action for channel types on channelselector: movies, series, etc. elif (item.action == "channeltypes"): import channelselector itemlist = channelselector.getchanneltypes() xbmctools.renderItems(itemlist, item) # Action for channel listing on channelselector elif (item.action == "listchannels"): import channelselector itemlist = channelselector.filterchannels(item.category) xbmctools.renderItems(itemlist, item) # Action in certain channel specified in "action" and "channel" parameters else: # Entry point for a channel is the "mainlist" action, so here we check parental control if item.action == "mainlist": # Parental control can_open_channel = False # If it is an adult channel, and user has configured pin, asks for it if channeltools.is_adult(item.channel) and config.get_setting( "adult_pin") != "": import xbmc keyboard = xbmc.Keyboard("", "PIN para canales de adultos", True) keyboard.doModal() if (keyboard.isConfirmed()): tecleado = keyboard.getText() if tecleado == config.get_setting("adult_pin"): can_open_channel = True # All the other cases can open the channel else: can_open_channel = True if not can_open_channel: return # Checks if channel exists channel_file = os.path.join(config.get_runtime_path(), 'channels', item.channel + ".py") logger.info( "streamondemand.platformcode.launcher channel_file=%s" % channel_file) if item.channel in [ "personal", "personal2", "personal3", "personal4", "personal5" ]: import channels.personal as channel elif os.path.exists(channel_file): try: channel = __import__( 'channels.%s' % item.channel, fromlist=["channels.%s" % item.channel]) except: exec "import channels." + item.channel + " as channel" logger.info( "streamondemand.platformcode.launcher running channel {0} {1}". format(channel.__name__, channel.__file__)) # Special play action if item.action == "play": logger.info("streamondemand.platformcode.launcher play") # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info( "streamondemand.platformcode.launcher executing channel 'play' method" ) itemlist = channel.play(item) # Play should return a list of playable URLS if len(itemlist) > 0: item = itemlist[0] xbmctools.play_video(item) # If not, shows user an error message else: import xbmcgui ventana_error = xbmcgui.Dialog() ok = ventana_error.ok("plugin", "No hay nada para reproducir") # If player don't have a "play" function, not uses the standard play from xbmctools else: logger.info( "streamondemand.platformcode.launcher executing core 'play' method" ) xbmctools.play_video(item) # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": if item.strm: # Special action for playing a video from the library play_from_library(item, channel, server_white_list, server_black_list) # First checks if channel has a "findvideos" function if hasattr(channel, 'findvideos'): itemlist = getattr(channel, item.action)(item) # If not, uses the generic findvideos function else: logger.info( "streamondemand.platformcode.launcher no channel 'findvideos' method, " "executing core method") from core import servertools itemlist = servertools.find_video_items(item) if config.get_setting('filter_servers') == 'true': itemlist = filtered_servers(itemlist, server_white_list, server_black_list) from platformcode import subtitletools subtitletools.saveSubtitleName(item) # Show xbmc items as "movies", so plot is visible import xbmcplugin handle = sys.argv[1] xbmcplugin.setContent(int(handle), "movies") # Add everything to XBMC item list if type(itemlist) == list and itemlist: xbmctools.renderItems(itemlist, item) # If not, it shows an empty list # FIXME: Aquí deberíamos mostrar alguna explicación del tipo "No hay elementos, esto pasa por bla bla bla" else: xbmctools.renderItems([], item) # DrZ3r0 # Special action for play_from_library, where the plugin looks for known urls elif item.action == "play_from_library": # Special action for playing a video from the library play_from_library(item, channel, server_white_list, server_black_list) # Special action for adding a movie to the library elif item.action == "add_pelicula_to_library": library.add_pelicula_to_library(item) # Special action for adding a serie to the library elif item.action == "add_serie_to_library": library.add_serie_to_library(item, channel) # Special action for downloading all episodes from a serie elif item.action == "download_all_episodes": downloadtools.download_all_episodes(item, channel) # Special action for searching, first asks for the words then call the "search" function elif item.action == "search": logger.info("streamondemand.platformcode.launcher 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, item) # For all other actions else: logger.info( "streamondemand.platformcode.launcher executing channel '" + item.action + "' method") itemlist = getattr(channel, item.action)(item) # Activa el modo biblioteca para todos los canales genéricos, para que se vea el argumento import xbmcplugin handle = sys.argv[1] xbmcplugin.setContent(int(handle), "movies") # Añade los items a la lista de XBMC if type(itemlist) == list and itemlist: xbmctools.renderItems(itemlist, item) # If not, it shows an empty list # FIXME: Aquí deberíamos mostrar alguna explicación del tipo "No hay elementos, esto pasa por bla bla bla" else: xbmctools.renderItems([], item) except urllib2.URLError, e: import traceback logger.error("streamondemand.platformcode.launcher " + traceback.format_exc()) import xbmcgui ventana_error = xbmcgui.Dialog() # Grab inner and third party errors if hasattr(e, 'reason'): logger.info( "streamondemand.platformcode.launcher Razon del error, codigo: {0}, Razon: {1}" .format(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) # Grab server response errors elif hasattr(e, 'code'): logger.info( "streamondemand.platformcode.launcher 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(item=None): logger.info("tvalacarta.platformcode.launcher run") if item is None: # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) params = "" # If no item, this is mainlist else: item = Item(action="selectchannel") params = "" logger.info(item.tostring()) # If item has no action, stops here if item.action == "": logger.info("Item sin accion") return try: # Action for main menu in channelselector if item.action=="selectchannel": import channelselector # TODO: Que channelselector devuelva items, procesados por el mismo add_items_to_kodi_directory que el resto itemlist = channelselector.mainlist(params, item.url, item.category) # Check for updates only on first screen if config.get_setting("updatecheck2") == "true": logger.info("tvalacarta.platformcode.launcher Check for plugin updates enabled") from core import updater try: version = updater.checkforupdates() if version: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("Versión "+version+" disponible","Ya puedes descargar la nueva versión del plugin\ndesde el listado principal") itemlist.insert(0,Item(title="Descargar version "+version, version=version, channel="updater", action="update", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png")) except: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("No se puede conectar","No ha sido posible comprobar","si hay actualizaciones") logger.info("channelselector.mainlist Fallo al verificar la actualización") else: logger.info("tvalacarta.platformcode.launcher Check for plugin updates disabled") #xbmctools.add_items_to_kodi_directory(itemlist, item) # Action for updating plugin elif item.action=="update": from core import updater updater.update(item) if config.get_system_platform()!="xbox": import xbmc xbmc.executebuiltin( "Container.Refresh" ) # Action for channel types on channelselector: movies, series, etc. elif item.action=="channeltypes": import channelselector # TODO: Que channelselector devuelva items, procesados por el mismo add_items_to_kodi_directory que el resto itemlist = channelselector.channeltypes(params,item.url,item.category) #xbmctools.add_items_to_kodi_directory(itemlist, item) # Action for channel listing on channelselector elif item.action=="listchannels": import channelselector # TODO: Que channelselector devuelva items, procesados por el mismo add_items_to_kodi_directory que el resto itemlist = channelselector.listchannels(params,item.url,item.category) #xbmctools.add_items_to_kodi_directory(itemlist, item) elif item.action=="player_directo": from core import window_player_background from channels import directos import plugintools window = window_player_background.PlayerWindowBackground("player_background.xml",plugintools.get_runtime_path()) window.setItemlist(directos.build_channel_list()) window.setCurrentPosition(item.position) window.doModal() del window return # Action in certain channel specified in "action" and "channel" parameters else: # Checks if channel exists channel_file = os.path.join( config.get_runtime_path() , 'channels' , item.channel+".py" ) logger.info("tvalacarta.platformcode.launcher channel_file=%s" % channel_file) channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel]) logger.info("tvalacarta.platformcode.launcher running channel {0} {1}".format(channel.__name__, channel.__file__)) # Special play action if item.action == "play": logger.info("tvalacarta.platformcode.launcher play") # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info("tvalacarta.platformcode.launcher executing channel 'play' method") itemlist = channel.play(item) if len(itemlist)>0: item = itemlist[0] xbmctools.play_video(item) else: import xbmcgui ventana_error = xbmcgui.Dialog() ok = ventana_error.ok ("plugin", "No hay nada para reproducir") else: logger.info("tvalacarta.platformcode.launcher executing core 'play' method") xbmctools.play_video(item) elif item.action.startswith("serie_options##"): from core import suscription import xbmcgui dia = xbmcgui.Dialog() opciones = [] suscription_item = Item(channel=item.channel, title=item.show, url=item.url, action=item.action.split("##")[1], extra=item.extra, plot=item.plot, show=item.show, thumbnail=item.thumbnail) if not suscription.already_suscribed(suscription_item): opciones.append("Activar descarga automática") else: opciones.append("Cancelar descarga automática") #opciones.append("Añadir esta serie a favoritos") opciones.append("Descargar todos los episodios") seleccion = dia.select("Elige una opción", opciones) # "Elige una opción" if seleccion==0: if not suscription.already_suscribed(suscription_item): suscription.append_suscription(suscription_item) yes_pressed = xbmcgui.Dialog().yesno( "Descarga automática activada" , "A partir de ahora los nuevos vídeos que se publiquen de este programa se descargarán automáticamente, podrás encontrarlos en la sección 'Descargas'." ) if yes_pressed: download_all_episodes(suscription_item,channel) else: suscription.remove_suscription(suscription_item) xbmcgui.Dialog().ok( "Descarga automática cancelada" , "Los vídeos que hayas descargado se mantienen, pero los nuevos ya no se descargarán ellos solos." ) elif seleccion==1: downloadtools.download_all_episodes(item, channel) ''' elif seleccion==1: from core import favoritos from core import downloadtools import xbmc keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(item.show)+" ["+item.channel+"]") keyboard.doModal() if keyboard.isConfirmed(): title = keyboard.getText() favoritos.savebookmark(titulo=title,url=item.url,thumbnail=item.thumbnail,server="",plot=item.plot,fulltitle=title) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30102) , title , config.get_localized_string(30108)) # 'se ha añadido a favoritos' return ''' elif item.action=="search": logger.info("tvalacarta.platformcode.launcher search") import xbmc keyboard = xbmc.Keyboard("") keyboard.doModal() itemlist = [] if (keyboard.isConfirmed()): tecleado = keyboard.getText() #tecleado = tecleado.replace(" ", "+") itemlist = channel.search(item,tecleado) if itemlist is None: itemlist = [] xbmctools.add_items_to_kodi_directory(itemlist, item) else: logger.info("tvalacarta.platformcode.launcher executing channel '"+item.action+"' method") exec "itemlist = channel."+item.action+"(item)" if itemlist is None: itemlist = [] # Activa el modo biblioteca para todos los canales genéricos, para que se vea el argumento handle = sys.argv[1] xbmcplugin.setContent(int( handle ),"movies") # Añade los items a la lista de XBMC xbmctools.add_items_to_kodi_directory(itemlist, item) except UserException,e: import xbmcgui xbmcgui.Dialog().ok ("Se ha producido un error", e.value)
def run(item=None): logger.info("tvalacarta.platformcode.launcher run") if item is None: # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) params = "" # If no item, this is mainlist else: item = Item(action="selectchannel") params = "" logger.info(item.tostring()) # If item has no action, stops here if item.action == "": logger.info("Item sin accion") return try: # Action for main menu in channelselector if item.action == "selectchannel": import channelselector # TODO: Que channelselector devuelva items, procesados por el mismo add_items_to_kodi_directory que el resto itemlist = channelselector.mainlist(params, item.url, item.category) # Check for updates only on first screen if config.get_setting("updatecheck2") == "true": logger.info( "tvalacarta.platformcode.launcher Check for plugin updates enabled" ) from core import updater try: version = updater.checkforupdates() if version: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok( "Versión " + version + " disponible", "Ya puedes descargar la nueva versión del plugin\ndesde el listado principal" ) itemlist.insert( 0, Item( title="Descargar version " + version, version=version, channel="updater", action="update", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png")) except: import xbmcgui advertencia = xbmcgui.Dialog() advertencia.ok("No se puede conectar", "No ha sido posible comprobar", "si hay actualizaciones") logger.info( "channelselector.mainlist Fallo al verificar la actualización" ) else: logger.info( "tvalacarta.platformcode.launcher Check for plugin updates disabled" ) #xbmctools.add_items_to_kodi_directory(itemlist, item) # Action for updating plugin elif item.action == "update": from core import updater updater.update(item) if config.get_system_platform() != "xbox": import xbmc xbmc.executebuiltin("Container.Refresh") # Action for channel types on channelselector: movies, series, etc. elif item.action == "channeltypes": import channelselector # TODO: Que channelselector devuelva items, procesados por el mismo add_items_to_kodi_directory que el resto itemlist = channelselector.channeltypes(params, item.url, item.category) #xbmctools.add_items_to_kodi_directory(itemlist, item) # Action for channel listing on channelselector elif item.action == "listchannels": import channelselector # TODO: Que channelselector devuelva items, procesados por el mismo add_items_to_kodi_directory que el resto itemlist = channelselector.listchannels(params, item.url, item.category) #xbmctools.add_items_to_kodi_directory(itemlist, item) elif item.action == "player_directo": from core import window_player_background from channels import directos import plugintools window = window_player_background.PlayerWindowBackground( "player_background.xml", plugintools.get_runtime_path()) window.setItemlist(directos.build_channel_list()) window.setCurrentPosition(item.position) window.doModal() del window return # Action in certain channel specified in "action" and "channel" parameters else: # Checks if channel exists channel_file = os.path.join(config.get_runtime_path(), 'channels', item.channel + ".py") logger.info("tvalacarta.platformcode.launcher channel_file=%s" % channel_file) channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel]) logger.info( "tvalacarta.platformcode.launcher running channel {0} {1}". format(channel.__name__, channel.__file__)) # Special play action if item.action == "play": logger.info("tvalacarta.platformcode.launcher play") # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info( "tvalacarta.platformcode.launcher executing channel 'play' method" ) itemlist = channel.play(item) if len(itemlist) > 0: item = itemlist[0] xbmctools.play_video(item) else: import xbmcgui ventana_error = xbmcgui.Dialog() ok = ventana_error.ok("plugin", "No hay nada para reproducir") else: logger.info( "tvalacarta.platformcode.launcher executing core 'play' method" ) xbmctools.play_video(item) elif item.action.startswith("serie_options##"): from core import suscription import xbmcgui dia = xbmcgui.Dialog() opciones = [] suscription_item = Item(channel=item.channel, title=item.show, url=item.url, action=item.action.split("##")[1], extra=item.extra, plot=item.plot, show=item.show, thumbnail=item.thumbnail) if not suscription.already_suscribed(suscription_item): opciones.append("Activar descarga automática") else: opciones.append("Cancelar descarga automática") #opciones.append("Añadir esta serie a favoritos") opciones.append("Descargar todos los episodios") seleccion = dia.select("Elige una opción", opciones) # "Elige una opción" if seleccion == 0: if not suscription.already_suscribed(suscription_item): suscription.append_suscription(suscription_item) yes_pressed = xbmcgui.Dialog().yesno( "Descarga automática activada", "A partir de ahora los nuevos vídeos que se publiquen de este programa se descargarán automáticamente, podrás encontrarlos en la sección 'Descargas'." ) if yes_pressed: download_all_episodes(suscription_item, channel) else: suscription.remove_suscription(suscription_item) xbmcgui.Dialog().ok( "Descarga automática cancelada", "Los vídeos que hayas descargado se mantienen, pero los nuevos ya no se descargarán ellos solos." ) elif seleccion == 1: downloadtools.download_all_episodes(item, channel) ''' elif seleccion==1: from core import favoritos from core import downloadtools import xbmc keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(item.show)+" ["+item.channel+"]") keyboard.doModal() if keyboard.isConfirmed(): title = keyboard.getText() favoritos.savebookmark(titulo=title,url=item.url,thumbnail=item.thumbnail,server="",plot=item.plot,fulltitle=title) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30102) , title , config.get_localized_string(30108)) # 'se ha añadido a favoritos' return ''' elif item.action == "search": logger.info("tvalacarta.platformcode.launcher search") import xbmc keyboard = xbmc.Keyboard("") keyboard.doModal() itemlist = [] if (keyboard.isConfirmed()): tecleado = keyboard.getText() #tecleado = tecleado.replace(" ", "+") itemlist = channel.search(item, tecleado) if itemlist is None: itemlist = [] xbmctools.add_items_to_kodi_directory(itemlist, item) else: logger.info( "tvalacarta.platformcode.launcher executing channel '" + item.action + "' method") exec "itemlist = channel." + item.action + "(item)" if itemlist is None: itemlist = [] # Activa el modo biblioteca para todos los canales genéricos, para que se vea el argumento handle = sys.argv[1] xbmcplugin.setContent(int(handle), "movies") # Añade los items a la lista de XBMC xbmctools.add_items_to_kodi_directory(itemlist, item) except UserException, e: import xbmcgui xbmcgui.Dialog().ok("Se ha producido un error", e.value)
def render_items(self, itemlist, parent_item): """ Función encargada de mostrar el itemlist, se pasa como parametros el itemlist y el item del que procede @type itemlist: list @param itemlist: lista de elementos a mostrar @type parent_item: item @param parent_item: elemento padre """ # Si el itemlist no es un list salimos if not type(itemlist) == list: JsonData = {} JsonData["action"] = "HideLoading" JsonData["data"] = {} self.send_message(JsonData) return # Si no hay ningun item, mostramos un aviso if not len(itemlist): itemlist.append(Item(title="No hay elementos que mostrar")) if parent_item.channel == "channelselector" and not parent_item.action == "filterchannels": parent_item.viewmode = "banner" elif parent_item.channel == "channelselector" and parent_item.action == "filterchannels": parent_item.viewmode = "channel" if not parent_item.viewmode: parent_item.viewmode = "list" # Item Atrás if not (parent_item.channel == "channelselector" and parent_item.action == "mainlist") and not \ itemlist[0].action == "go_back": if parent_item.viewmode in ["banner", "channel"]: itemlist.insert(0, Item(title="Atrás", action="go_back", thumbnail=channelselector.get_thumb("back.png", "banner_"))) else: itemlist.insert(0, Item(title="Atrás", action="go_back", thumbnail=channelselector.get_thumb("back.png"))) JsonData = {} JsonData["action"] = "EndItems" JsonData["data"] = {} JsonData["data"]["itemlist"] = [] JsonData["data"]["viewmode"] = parent_item.viewmode JsonData["data"]["category"] = parent_item.category.capitalize() JsonData["data"]["host"] = self.controller.host if parent_item.url: JsonData["data"]["url"] = parent_item.url # Recorremos el itemlist for item in itemlist: if not item.thumbnail and item.action == "search": item.thumbnail = channelselector.get_thumb("search.png") if not item.thumbnail and item.folder == True: item.thumbnail = channelselector.get_thumb("folder.png", "banner") if not item.thumbnail and item.folder == False: item.thumbnail = channelselector.get_thumb("nofolder.png") if "http://media.xxxxx/" in item.thumbnail and not item.thumbnail.startswith( "http://media.xxxxxxxx/thumb_"): if parent_item.viewmode in ["banner", "channel"]: item.thumbnail = channelselector.get_thumbnail_path("banner") + os.path.basename(item.thumbnail) else: item.thumbnail = channelselector.get_thumbnail_path() + os.path.basename(item.thumbnail) # Estas imagenes no estan en banner, asi que si queremos banner, para que no se vean mal las quitamos elif parent_item.viewmode in ["banner", "channel"] and item.thumbnail.startswith( "http://media.xxxxx/thumb_"): item.thumbnail = "" # Si el item no contiene categoria,le ponemos la del item padre if item.category == "": item.category = parent_item.category # Si el item no contiene fanart,le ponemos la del item padre if item.fanart == "": item.fanart = parent_item.fanart title = item.title.replace(item.title.lstrip(), "").replace(" ", " ") + item.title.lstrip() # Formatear titulo if item.text_color: title = '[COLOR %s]%s[/COLOR]' % (item.text_color, title) if item.text_bold: title = '[B]%s[/B]' % title if item.text_italic: title = '[I]%s[/I]' % title title = self.kodi_labels_to_html(title) # Añade headers a las imagenes si estan en un servidor con cloudflare from core import httptools item.thumbnail = httptools.get_url_headers(item.thumbnail) item.fanart = httptools.get_url_headers(item.fanart) JsonItem = {} JsonItem["title"] = title JsonItem["thumbnail"] = item.thumbnail JsonItem["fanart"] = item.fanart JsonItem["plot"] = item.plot JsonItem["action"] = item.action JsonItem["url"] = item.tourl() JsonItem["context"] = [] if not item.action == "go_back": for Comando in self.set_context_commands(item, parent_item): JsonItem["context"].append({"title": Comando[0], "url": Comando[1]}) JsonData["data"]["itemlist"].append(JsonItem) ID = self.send_message(JsonData) self.get_data(ID)
def render_items(self, itemlist, parent_item): """ Función encargada de mostrar el itemlist, se pasa como parametros el itemlist y el item del que procede @type itemlist: list @param itemlist: lista de elementos a mostrar @type parent_item: item @param parent_item: elemento padre """ # Si el itemlist no es un list salimos if not type(itemlist) == list: JsonData = {} JsonData["action"]="HideLoading" JsonData["data"] = {} self.send_message(JsonData) return # Si no hay ningun item, mostramos un aviso if not len(itemlist): itemlist.append(Item(title="No hay elementos que mostrar")) if parent_item.channel == "channelselector" and not parent_item.action == "filterchannels": parent_item.viewmode = "banner" elif parent_item.channel == "channelselector" and parent_item.action == "filterchannels": parent_item.viewmode = "channel" if not parent_item.viewmode: parent_item.viewmode = "list" #Item Atrás if not (parent_item.channel=="channelselector" and parent_item.action=="mainlist") and not itemlist[0].action=="go_back": if parent_item.viewmode in ["banner", "channel"]: itemlist.insert(0,Item(title="Atrás", action="go_back",thumbnail=os.path.join(config.get_runtime_path(),"resources","images","bannermenu","thumb_atras.png"))) else: itemlist.insert(0,Item(title="Atrás", action="go_back",thumbnail=os.path.join(config.get_runtime_path(),"resources","images","squares","thumb_atras.png"))) JsonData = {} JsonData["action"] = "EndItems" JsonData["data"] = {} JsonData["data"]["itemlist"] = [] JsonData["data"]["viewmode"] = parent_item.viewmode JsonData["data"]["category"] = parent_item.category.capitalize() JsonData["data"]["host"] = self.controller.host # Recorremos el itemlist for item in itemlist: if not item.thumbnail and item.action == "search": item.thumbnail = channelselector.get_thumbnail_path() + "thumb_buscar.png" if not item.thumbnail and item.folder == True: item.thumbnail = "http://media.tvalacarta.info/pelisalacarta/thumb_folder.png" if not item.thumbnail and item.folder == False: item.thumbnail = "http://media.tvalacarta.info/pelisalacarta/thumb_nofolder.png" if "http://media.tvalacarta.info/" in item.thumbnail and not item.thumbnail.startswith("http://media.tvalacarta.info/pelisalacarta/thumb_"): if parent_item.viewmode in ["banner", "channel"]: item.thumbnail = channelselector.get_thumbnail_path("bannermenu") + os.path.basename(item.thumbnail) else: item.thumbnail = channelselector.get_thumbnail_path() + os.path.basename(item.thumbnail) #Estas imagenes no estan en bannermenu, asi que si queremos bannermenu, para que no se vean mal las quitamos elif parent_item.viewmode in ["banner", "channel"] and item.thumbnail.startswith("http://media.tvalacarta.info/pelisalacarta/thumb_"): item.thumbnail = "" # Si el item no contiene categoria,le ponemos la del item padre if item.category == "": item.category = parent_item.category # Si el item no contiene fanart,le ponemos la del item padre if item.fanart == "": item.fanart = parent_item.fanart title = item.title.replace(item.title.lstrip(), ""). replace(" ", " ") + item.title.lstrip() # Formatear titulo if item.text_color: title = '[COLOR %s]%s[/COLOR]' % (item.text_color, title) if item.text_blod: title = '[B]%s[/B]' % title if item.text_italic: title = '[I]%s[/I]' % title title = self.kodi_labels_to_html(title) #Añade headers a las imagenes si estan en un servidor con cloudflare from core import httptools item.thumbnail = httptools.get_url_headers(item.thumbnail) item.fanart = httptools.get_url_headers(item.fanart) JsonItem = {} JsonItem["title"]=title JsonItem["thumbnail"]= item.thumbnail JsonItem["fanart"]=item.fanart JsonItem["plot"]=item.plot JsonItem["action"]=item.action JsonItem["url"]=item.tourl() JsonItem["context"]=[] if not item.action == "go_back": for Comando in self.set_context_commands(item, parent_item): JsonItem["context"].append({"title":Comando[0],"url": Comando[1]}) JsonData["data"]["itemlist"].append(JsonItem) ID = self.send_message(JsonData) self.get_data(ID)
def run(): logger.info("pelisalacarta.platformcode.launcher run") # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) # If no item, this is mainlist else: item = Item(channel="channelselector", action="getmainlist", viewmode="movie") logger.info("pelisalacarta.platformcode.launcher "+item.tostring()) try: # If item has no action, stops here if item.action == "": logger.info("pelisalacarta.platformcode.launcher Item sin accion") return # Action for main menu in channelselector if item.action == "getmainlist": import channelselector itemlist = channelselector.getmainlist() # Check for updates only on first screen if config.get_setting("updatecheck2") == "true": logger.info("pelisalacarta.platformcode.launcher Check for plugin updates enabled") from core import updater try: version = updater.checkforupdates() if version: platformtools.dialog_ok("Versión "+version+" disponible", "Ya puedes descargar la nueva versión del plugin\n" "desde el listado principal") itemlist.insert(0, Item(title="Descargar version "+version, version=version, channel="updater", action="update", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png")) except: platformtools.dialog_ok("No se puede conectar", "No ha sido posible comprobar", "si hay actualizaciones") logger.info("cpelisalacarta.platformcode.launcher Fallo al verificar la actualización") else: logger.info("pelisalacarta.platformcode.launcher Check for plugin updates disabled") platformtools.render_items(itemlist, item) # Action for updating plugin elif item.action == "update": from core import updater updater.update(item) if config.get_system_platform() != "xbox": import xbmc xbmc.executebuiltin("Container.Refresh") # Action for channel types on channelselector: movies, series, etc. elif item.action == "getchanneltypes": import channelselector itemlist = channelselector.getchanneltypes() platformtools.render_items(itemlist, item) # Action for channel listing on channelselector elif item.action == "filterchannels": import channelselector itemlist = channelselector.filterchannels(item.channel_type) platformtools.render_items(itemlist, item) # Special action for playing a video from the library elif item.action == "play_from_library": play_from_library(item) return # Action in certain channel specified in "action" and "channel" parameters else: # Entry point for a channel is the "mainlist" action, so here we check parental control if item.action == "mainlist": # Parental control can_open_channel = False # If it is an adult channel, and user has configured pin, asks for it if channeltools.is_adult(item.channel) and config.get_setting("adult_pin") != "": tecleado = platformtools.dialog_input("", "PIN para canales de adultos", True) if tecleado is not None: if tecleado == config.get_setting("adult_pin"): can_open_channel = True # All the other cases can open the channel else: can_open_channel = True if not can_open_channel: return # Checks if channel exists channel_file = os.path.join(config.get_runtime_path(), 'channels', item.channel+".py") logger.info("pelisalacarta.platformcode.launcher channel_file=%s" % channel_file) channel = None if item.channel in ["personal", "personal2", "personal3", "personal4", "personal5"]: import channels.personal as channel elif os.path.exists(channel_file): try: channel = __import__('channels.%s' % item.channel, None, None, ["channels.%s" % item.channel]) except ImportError: exec "import channels."+item.channel+" as channel" logger.info("pelisalacarta.platformcode.launcher running channel "+channel.__name__+" "+channel.__file__) # Special play action if item.action == "play": logger.info("pelisalacarta.platformcode.launcher play") # logger.debug("item_toPlay: " + "\n" + item.tostring('\n')) # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info("pelisalacarta.platformcode.launcher executing channel 'play' method") itemlist = channel.play(item) b_favourite = item.isFavourite # Play should return a list of playable URLS if len(itemlist) > 0: item = itemlist[0] if b_favourite: item.isFavourite = True platformtools.play_video(item) # If not, shows user an error message else: platformtools.dialog_ok("plugin", "No hay nada para reproducir") # If player don't have a "play" function, not uses the standard play from platformtools else: logger.info("pelisalacarta.platformcode.launcher executing core 'play' method") platformtools.play_video(item) # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": # First checks if channel has a "findvideos" function if hasattr(channel, 'findvideos'): itemlist = getattr(channel, item.action)(item) # If not, uses the generic findvideos function else: logger.info("pelisalacarta.platformcode.launcher no channel 'findvideos' method, " "executing core method") from core import servertools itemlist = servertools.find_video_items(item) if config.get_setting('filter_servers') == 'true': itemlist = filtered_servers(itemlist) from platformcode import subtitletools subtitletools.saveSubtitleName(item) platformtools.render_items(itemlist, item) # Special action for adding a movie to the library elif item.action == "add_pelicula_to_library": library.add_pelicula_to_library(item) # Special action for adding a serie to the library elif item.action == "add_serie_to_library": library.add_serie_to_library(item, channel) # Special action for downloading all episodes from a serie elif item.action == "download_all_episodes": from channels import descargas item.action = item.extra del item.extra descargas.save_download(item) # Special action for searching, first asks for the words then call the "search" function elif item.action == "search": logger.info("pelisalacarta.platformcode.launcher search") tecleado = platformtools.dialog_input("") if tecleado is not None: tecleado = tecleado.replace(" ", "+") # TODO revisar 'personal.py' porque no tiene función search y daría problemas itemlist = channel.search(item, tecleado) else: itemlist = [] platformtools.render_items(itemlist, item) # For all other actions else: logger.info("pelisalacarta.platformcode.launcher executing channel '"+item.action+"' method") itemlist = getattr(channel, item.action)(item) platformtools.render_items(itemlist, item) except urllib2.URLError, e: import traceback logger.error("pelisalacarta.platformcode.launcher "+traceback.format_exc()) # Grab inner and third party errors if hasattr(e, 'reason'): logger.info("pelisalacarta.platformcode.launcher Razon del error, codigo: "+str(e.reason[0])+", Razon: " + str(e.reason[1])) texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web" platformtools.dialog_ok("plugin", texto) # Grab server response errors elif hasattr(e, 'code'): logger.info("pelisalacarta.platformcode.launcher codigo de error HTTP : %d" % e.code) # "El sitio web no funciona correctamente (error http %d)" platformtools.dialog_ok("plugin", config.get_localized_string(30051) % e.code)
def mainlist(item): logger.info("tvalacarta.channels.configuracion mainlist") itemlist = [] if config.get_setting("account_type_registered") == "0": itemlist.append( Item(channel=CHANNELNAME, title="Iniciar sesion", action="login", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="Crear nueva cuenta", action="register", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="Olvide mi contraseña", action="reset_password", folder=False)) else: itemlist.append( Item(channel=CHANNELNAME, title="Cuenta: " + config.get_setting("account_email"), action="", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="Cerrar sesion", action="logout", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="Cambiar contraseña", action="change_password", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="", action="", folder=False)) itemlist.append( Item(channel=CHANNELNAME, title="Preferencias", action="settings", folder=False)) itemlist.append( Item(channel="api_programas", title="Configurar programas ocultos", action="get_hidden_programs", folder=True)) title = "Descargar e instalar otras versiones" if config.get_setting("plugin_updates_available") == "0": nuevas = "" elif config.get_setting("plugin_updates_available") == "1": title = "[COLOR yellow]" + title + " (1 nueva)[/COLOR]" else: title = "[COLOR yellow]" + title + " (%s nuevas)" % str( config.get_setting("plugin_updates_available")) + "[/COLOR]" thumb_configuracion = "menu/settings_%s.png" % config.get_setting( "plugin_updates_available") import channelselector itemlist.append( Item( channel=CHANNELNAME, title=title, action="get_all_versions", folder=True, thumbnail=channelselector.get_thumbnail_path(thumb_configuracion))) return itemlist
def run(): logger.info("pelisalacarta.platformcode.launcher run") # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) # If no item, this is mainlist else: item = Item(channel="channelselector", action="getmainlist", viewmode="movie") logger.info("pelisalacarta.platformcode.launcher " + item.tostring()) try: # If item has no action, stops here if item.action == "": logger.info("pelisalacarta.platformcode.launcher Item sin accion") return # Action for main menu in channelselector if item.action == "getmainlist": import channelselector itemlist = channelselector.getmainlist() # Check for updates only on first screen if config.get_setting("updatecheck2") == "true": logger.info( "pelisalacarta.platformcode.launcher Check for plugin updates enabled" ) from core import updater try: version = updater.checkforupdates() if version: platformtools.dialog_ok( "Versión " + version + " disponible", "Ya puedes descargar la nueva versión del plugin\n" "desde el listado principal") itemlist.insert( 0, Item( title="Descargar version " + version, version=version, channel="updater", action="update", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png")) except: platformtools.dialog_ok("No se puede conectar", "No ha sido posible comprobar", "si hay actualizaciones") logger.info( "cpelisalacarta.platformcode.launcher Fallo al verificar la actualización" ) else: logger.info( "pelisalacarta.platformcode.launcher Check for plugin updates disabled" ) platformtools.render_items(itemlist, item) # Action for updating plugin elif item.action == "update": from core import updater updater.update(item) if config.get_system_platform() != "xbox": import xbmc xbmc.executebuiltin("Container.Refresh") # Action for channel types on channelselector: movies, series, etc. elif item.action == "getchanneltypes": import channelselector itemlist = channelselector.getchanneltypes() platformtools.render_items(itemlist, item) # Action for channel listing on channelselector elif item.action == "filterchannels": import channelselector itemlist = channelselector.filterchannels(item.channel_type) platformtools.render_items(itemlist, item) # Special action for playing a video from the library elif item.action == "play_from_library": play_from_library(item) return # Action in certain channel specified in "action" and "channel" parameters else: # Entry point for a channel is the "mainlist" action, so here we check parental control if item.action == "mainlist": # Parental control can_open_channel = False # If it is an adult channel, and user has configured pin, asks for it if channeltools.is_adult(item.channel) and config.get_setting( "adult_pin") != "": tecleado = platformtools.dialog_input( "", "PIN para canales de adultos", True) if tecleado is not None: if tecleado == config.get_setting("adult_pin"): can_open_channel = True # All the other cases can open the channel else: can_open_channel = True if not can_open_channel: return # Checks if channel exists channel_file = os.path.join(config.get_runtime_path(), 'channels', item.channel + ".py") logger.info("pelisalacarta.platformcode.launcher channel_file=%s" % channel_file) channel = None if item.channel in [ "personal", "personal2", "personal3", "personal4", "personal5" ]: import channels.personal as channel elif os.path.exists(channel_file): try: channel = __import__('channels.%s' % item.channel, None, None, ["channels.%s" % item.channel]) except ImportError: exec "import channels." + item.channel + " as channel" logger.info( "pelisalacarta.platformcode.launcher running channel " + channel.__name__ + " " + channel.__file__) # Special play action if item.action == "play": logger.info("pelisalacarta.platformcode.launcher play") # logger.debug("item_toPlay: " + "\n" + item.tostring('\n')) # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info( "pelisalacarta.platformcode.launcher executing channel 'play' method" ) itemlist = channel.play(item) b_favourite = item.isFavourite # Play should return a list of playable URLS if len(itemlist) > 0: item = itemlist[0] if b_favourite: item.isFavourite = True platformtools.play_video(item) # If not, shows user an error message else: platformtools.dialog_ok("plugin", "No hay nada para reproducir") # If player don't have a "play" function, not uses the standard play from platformtools else: logger.info( "pelisalacarta.platformcode.launcher executing core 'play' method" ) platformtools.play_video(item) # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": # First checks if channel has a "findvideos" function if hasattr(channel, 'findvideos'): itemlist = getattr(channel, item.action)(item) # If not, uses the generic findvideos function else: logger.info( "pelisalacarta.platformcode.launcher no channel 'findvideos' method, " "executing core method") from core import servertools itemlist = servertools.find_video_items(item) if config.get_setting('filter_servers') == 'true': itemlist = filtered_servers(itemlist) from platformcode import subtitletools subtitletools.saveSubtitleName(item) platformtools.render_items(itemlist, item) # Special action for adding a movie to the library elif item.action == "add_pelicula_to_library": library.add_pelicula_to_library(item) # Special action for adding a serie to the library elif item.action == "add_serie_to_library": library.add_serie_to_library(item, channel) # Special action for downloading all episodes from a serie elif item.action == "download_all_episodes": downloadtools.download_all_episodes(item, channel) # Special action for searching, first asks for the words then call the "search" function elif item.action == "search": logger.info("pelisalacarta.platformcode.launcher search") tecleado = platformtools.dialog_input("") if tecleado is not None: tecleado = tecleado.replace(" ", "+") # TODO revisar 'personal.py' porque no tiene función search y daría problemas itemlist = channel.search(item, tecleado) else: itemlist = [] platformtools.render_items(itemlist, item) # For all other actions else: logger.info( "pelisalacarta.platformcode.launcher executing channel '" + item.action + "' method") itemlist = getattr(channel, item.action)(item) platformtools.render_items(itemlist, item) except urllib2.URLError, e: import traceback logger.error("pelisalacarta.platformcode.launcher " + traceback.format_exc()) # Grab inner and third party errors if hasattr(e, 'reason'): logger.info( "pelisalacarta.platformcode.launcher Razon del error, codigo: " + str(e.reason[0]) + ", Razon: " + str(e.reason[1])) texto = config.get_localized_string( 30050) # "No se puede conectar con el sitio web" platformtools.dialog_ok("plugin", texto) # Grab server response errors elif hasattr(e, 'code'): logger.info( "pelisalacarta.platformcode.launcher codigo de error HTTP : %d" % e.code) # "El sitio web no funciona correctamente (error http %d)" platformtools.dialog_ok( "plugin", config.get_localized_string(30051) % e.code)
def run(): logger.info("deportesalacarta.platformcode.launcher run") # Extract item from sys.argv if sys.argv[2]: item = Item().fromurl(sys.argv[2]) # If no item, this is mainlist else: item = Item(channel="channelselector", action="getmainlist", viewmode="movie") logger.info("deportesalacarta.platformcode.launcher "+item.tostring()) try: # If item has no action, stops here if item.action == "": logger.info("deportesalacarta.platformcode.launcher Item sin accion") return # Action for main menu in channelselector if item.action == "getmainlist": import channelselector itemlist = channelselector.getmainlist() # Check for updates only on first screen if config.get_setting("updatecheck2") == "true": logger.info("deportesalacarta.platformcode.launcher Check for plugin updates enabled") from core import updater try: update, version_publicada, message = updater.check() if update: platformtools.dialog_ok("Versión "+version_publicada+" disponible", message) itemlist.insert(0, Item(title="Descargar versión "+version_publicada, channel="updater", action="actualiza", thumbnail=channelselector.get_thumbnail_path() + "Crystal_Clear_action_info.png", version=version_publicada)) except: import traceback logger.info(traceback.format_exc()) logger.info("deportesalacarta.platformcode.launcher Fallo al verificar la actualización") else: logger.info("deportesalacarta.platformcode.launcher Check for plugin updates disabled") platformtools.render_items(itemlist, item) # Action for updating plugin elif item.action == "actualiza": from core import updater updater.actualiza(item) import xbmc xbmc.executebuiltin("Container.Refresh") # Action for channel listing on channelselector elif item.action == "filterchannels": import channelselector itemlist = channelselector.filterchannels(item.channel_type) platformtools.render_items(itemlist, item) # Action in certain channel specified in "action" and "channel" parameters else: can_open_channel = True # Checks if channel exists channel_file = os.path.join(config.get_runtime_path(), 'channels', item.channel+".py") logger.info("deportesalacarta.platformcode.launcher channel_file=%s" % channel_file) channel = None if os.path.exists(channel_file): try: channel = __import__('channels.%s' % item.channel, None, None, ["channels.%s" % item.channel]) except ImportError: exec "import channels."+item.channel+" as channel" logger.info("deportesalacarta.platformcode.launcher running channel "+channel.__name__+" "+channel.__file__) # Special play action if item.action == "play": logger.info("deportesalacarta.platformcode.launcher play") # logger.debug("item_toPlay: " + "\n" + item.tostring('\n')) # First checks if channel has a "play" function if hasattr(channel, 'play'): logger.info("deportesalacarta.platformcode.launcher executing channel 'play' method") itemlist = channel.play(item) b_favourite = item.isFavourite # Play should return a list of playable URLS if len(itemlist) > 0: item = itemlist[0] if b_favourite: item.isFavourite = True platformtools.play_video(item) # If not, shows user an error message else: platformtools.dialog_ok("plugin", "No hay nada para reproducir") # If player don't have a "play" function, not uses the standard play from platformtools else: logger.info("deportesalacarta.platformcode.launcher executing core 'play' method") platformtools.play_video(item) # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": # First checks if channel has a "findvideos" function if hasattr(channel, 'findvideos'): itemlist = getattr(channel, item.action)(item) # If not, uses the generic findvideos function else: logger.info("deportesalacarta.platformcode.launcher no channel 'findvideos' method, " "executing core method") from core import servertools itemlist = servertools.find_video_items(item) platformtools.render_items(itemlist, item) # Special action for searching, first asks for the words then call the "search" function elif item.action == "search": logger.info("deportesalacarta.platformcode.launcher search") tecleado = platformtools.dialog_input("") if tecleado is not None: tecleado = tecleado.replace(" ", "+") # TODO revisar 'personal.py' porque no tiene función search y daría problemas itemlist = channel.search(item, tecleado) else: itemlist = [] platformtools.render_items(itemlist, item) # For all other actions else: logger.info("deportesalacarta.platformcode.launcher executing channel '"+item.action+"' method") itemlist = getattr(channel, item.action)(item) platformtools.render_items(itemlist, item) except urllib2.URLError, e: import traceback logger.error("deportesalacarta.platformcode.launcher "+traceback.format_exc()) # Grab inner and third party errors if hasattr(e, 'reason'): logger.info("deportesalacarta.platformcode.launcher Razon del error, codigo: "+str(e.reason[0])+", Razon: " + str(e.reason[1])) texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web" platformtools.dialog_ok("plugin", texto) # Grab server response errors elif hasattr(e, 'code'): logger.info("deportesalacarta.platformcode.launcher codigo de error HTTP : %d" % e.code) # "El sitio web no funciona correctamente (error http %d)" platformtools.dialog_ok("plugin", config.get_localized_string(30051) % e.code)