def canal(channel_name="", action="", caller_item_serialized=None): Log.Info("Entrando en canal para ejectuar " + channel_name + "." + action) 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.deserialize(caller_item_serialized) Log.Info("caller_item=" + str(caller_item)) Log.Info("Importando...") from servers import servertools channelmodule = servertools.get_channel_module(channel_name) Log.Info("Importado") Log.Info("Antes de hasattr") if hasattr(channelmodule, action): Log.Info("El módulo " + channel_name + " tiene una funcion " + action) itemlist = getattr(channelmodule, action)(caller_item) if action == "play" and len(itemlist) > 0: itemlist = play_video(itemlist[0]) else: Log.Info("El módulo " + channel_name + " *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) Log.Info("Tengo un itemlist con %d elementos" % len(itemlist)) for item in itemlist: try: Log.Info("item=" + unicode(item.tostring(), "utf-8", errors="replace")) except: pass try: item.title = unicode(item.title, "utf-8", errors="replace") except: pass if action != "play": oc.add( DirectoryObject( key=Callback( canal, channel_name=channel_name, action=item.action, caller_item_serialized=item.serialize(), ), title=item.title, thumb=item.thumbnail, ) ) else: Log.Info("Llamando a la funcion play comun") """ partObject = PartObject( key = Callback(resuelve, url=item.url) ) Log.Info("partObject="+str(partObject)) mediaObject = MediaObject( parts = [ partObject ] , container = 'mp4', video_codec = VideoCodec.H264, audio_codec = AudioCodec.AAC ) Log.Info("mediaObject="+str(mediaObject)) videoClipObject = VideoClipObject(title=item.title,thumb=item.thumbnail, url=item.url, key=item.url, rating_key=item.url, items = [ mediaObject ] ) Log.Info("videoClipObject="+str(mediaObject)) """ videoClipObject = VideoClipObject( title=item.title, 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()) return oc
def canal(channel_name="", action="", caller_item_serialized=None): Log.Info("Entrando en canal para ejectuar " + channel_name + "." + action) 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...") from servers import servertools channelmodule = servertools.get_channel_module(channel_name) Log.Info("Importado") Log.Info("Antes de hasattr") if hasattr(channelmodule, action): Log.Info("El módulo " + channel_name + " tiene una funcion " + action) itemlist = getattr(channelmodule, action)(caller_item) if action == "play" and len(itemlist) > 0: itemlist = play_video(itemlist[0]) else: Log.Info("El módulo " + channel_name + " *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) Log.Info("Tengo un itemlist con %d elementos" % len(itemlist)) for item in itemlist: try: Log.Info("item=" + unicode(item.tostring(), "utf-8", errors="replace")) except: pass try: item.title = unicode(item.title, "utf-8", errors="replace") except: pass if action != "play": oc.add( DirectoryObject(key=Callback( canal, channel_name=channel_name, action=item.action, caller_item_serialized=item.tourl()), title=item.title, thumb=item.thumbnail)) else: Log.Info("Llamando a la funcion play comun") ''' partObject = PartObject( key = Callback(resuelve, url=item.url) ) Log.Info("partObject="+str(partObject)) mediaObject = MediaObject( parts = [ partObject ] , container = 'mp4', video_codec = VideoCodec.H264, audio_codec = AudioCodec.AAC ) Log.Info("mediaObject="+str(mediaObject)) videoClipObject = VideoClipObject(title=item.title,thumb=item.thumbnail, url=item.url, key=item.url, rating_key=item.url, items = [ mediaObject ] ) Log.Info("videoClipObject="+str(mediaObject)) ''' videoClipObject = VideoClipObject(title=item.title, 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()) return oc