def get_input(query, dkitem): Log.Info(query) if type(dkitem) == str: caller_item_serialized = dkitem dkitem = Item() dkitem.fromurl(caller_item_serialized) Log.Info("#########################################################") Log.Info(dkitem.tostring()) if '.' in dkitem.channel: pack,modulo = dkitem.channel.split('.') #ejemplo: platformcode.platformtools channelmodule = channeltools.get_channel_module(modulo,pack) else: channelmodule = channeltools.get_channel_module(dkitem.channel) itemlist = getattr(channelmodule, dkitem.action)(dkitem, query) return canal(channel_name = dkitem.channel, action= "", itemlist = itemlist ) #return MessageContainer("Empty", "There aren't any speakers whose name starts with " + char) #return ObjectContainer(header="Empty", message="There aren't any items") #oc.add(SearchDirectoryObject(identifier='com.plexapp.plugins.amt', title='Search Trailers', prompt='Search for movie trailer', term=L('Trailers')))
def get_input(query, dkitem): Log.Info(query) if type(dkitem) == str: caller_item_serialized = dkitem dkitem = Item() dkitem.fromurl(caller_item_serialized) Log.Info("#########################################################") Log.Info(dkitem.tostring()) if '.' in dkitem.channel: pack, modulo = dkitem.channel.split( '.') #ejemplo: platformcode.platformtools channelmodule = channeltools.get_channel_module(modulo, pack) else: channelmodule = channeltools.get_channel_module(dkitem.channel) itemlist = getattr(channelmodule, dkitem.action)(dkitem, query) return canal(channel_name=dkitem.channel, action="", itemlist=itemlist) #return MessageContainer("Empty", "There aren't any speakers whose name starts with " + char) #return ObjectContainer(header="Empty", message="There aren't any items") #oc.add(SearchDirectoryObject(identifier='com.plexapp.plugins.amt', title='Search Trailers', prompt='Search for movie trailer', term=L('Trailers')))
def canal(channel_name="", action="", id=None, caller_item_serialized=None, itemlist=""): global LAST_ID global LAST_RESULT if id == LAST_ID and LAST_RESULT: return LAST_RESULT LAST_ID = id oc = ObjectContainer(view_group="List") try: if caller_item_serialized is None: Log.Info("caller_item_serialized=None") caller_item = Item() else: Log.Info("caller_item_serialized=" + caller_item_serialized) caller_item = Item() caller_item.fromurl(caller_item_serialized) Log.Info("caller_item=" + str(caller_item)) Log.Info("Importando...") channelmodule = channeltools.get_channel_module(channel_name) Log.Info("Importado") Log.Info("Antes de hasattr") if hasattr(channelmodule, action): Log.Info("El módulo " + caller_item.channel + " tiene una funcion " + action) itemlist = getattr(channelmodule, action)(caller_item) if action == "findvideos": itemlist = servertools.filter_servers(itemlist) if action == "play" and len(itemlist) > 0 and isinstance( itemlist[0], Item): itemlist = play_video(itemlist[0]) if action == "play" and len(itemlist) > 0 and isinstance( itemlist[0], list): item.video_urls = itemlist itemlist = play_video(item) else: Log.Info("El módulo " + caller_item.channel + " *NO* tiene una funcion " + action) if action == "findvideos": Log.Info("Llamando a la funcion findvideos comun") itemlist = findvideos(caller_item) elif action == "play": itemlist = play_video(caller_item) elif action == "menu_principal": LAST_RESULT = mainlist() return LAST_RESULT Log.Info("Tengo un itemlist con %d elementos" % len(itemlist)) for item in itemlist: if item.action == "search" and item.thumbnail == "": item.thumbnail = "http://media.tvalacarta.info/pelisalacarta/squares/thumb_buscar.png" try: Log.Info("item=" + unicode(item.tostring(), "utf-8", errors="replace")) except: pass if action != "play": #if "type" in item and item.type == "input": if item.action == "control_text_click" or item.action == "search": Log.Info("Canal: item tipo input") if 'value' in item: value = item.value else: value = "" if Client.Product in DumbKeyboard.clients: DumbKeyboard("/video/pelisalacarta", oc, get_input, dktitle=unicode(item.title, "utf-8", errors="replace"), dkitem=item, dkplaceholder=value, dkthumb=item.thumbnail) else: dkitem = item.tourl() oc.add( InputDirectoryObject(key=Callback(get_input, dkitem=dkitem), title=unicode( item.title, "utf-8", errors="replace"), prompt=value, thumb=item.thumbnail)) else: import random id = "%032x" % (random.getrandbits(128)) oc.add( DirectoryObject(key=Callback( canal, channel_name=item.channel, action=item.action, id=id, caller_item_serialized=item.tourl()), title=unicode(item.title, "utf-8", errors="replace"), thumb=item.thumbnail)) else: Log.Info("Llamando a la funcion play comun") videoClipObject = VideoClipObject( title=unicode(item.title, "utf-8", errors="replace"), thumb=item.thumbnail, url="pelisalacarta://" + item.url) oc.add(videoClipObject) except: Log.Info("Excepcion al ejecutar " + channel_name + "." + action) import traceback Log.Info("Detalles: " + traceback.format_exc()) LAST_RESULT = oc return oc