コード例 #1
0
ファイル: trakt_tools.py プロジェクト: x7r6xx/repo
def auth_trakt():
    item = Item()
    folder = (config.get_platform() == "plex")
    item.folder = folder
    # Autentificación de cuenta Trakt
    headers = {'Content-Type': 'application/json', 'trakt-api-key': client_id, 'trakt-api-version': '2'}
    try:
        post = {'client_id': client_id}
        post = jsontools.dump(post)
        # Se solicita url y código de verificación para conceder permiso a la app
        url = "http://api-v2launch.trakt.tv/oauth/device/code"
        data = httptools.downloadpage(url, post=post, headers=headers, replace_headers=True).data
        data = jsontools.load(data)
        item.verify_url = data["verification_url"]
        item.user_code = data["user_code"]
        item.device_code = data["device_code"]
        item.intervalo = data["interval"]
        if not item.folder:
            token_trakt(item)

        else:
            itemlist = []
            title = "Accede a esta página: %s" % item.verify_url
            itemlist.append(item.clone(title=title, action=""))
            title = "Ingresa este código y acepta: %s" % item.user_code
            itemlist.append(item.clone(title=title, action=""))
            title = "Una vez hecho, pulsa aquí!"
            itemlist.append(item.clone(title=title, action="token_trakt"))
            return itemlist
    except:
        import traceback
        logger.error(traceback.format_exc())
コード例 #2
0
ファイル: downloads.py プロジェクト: Jaloga/xiaomi
def mainlist(item):
    logger.info()
    item.category = 'Descargas'

    itemlist = []

    if download_path.startswith('smb://'):
        fichs = sorted(filetools.listdir(download_path))
        ficheros = [
            filetools.join(download_path, fit) for fit in fichs
            if fit.endswith('.json')
        ]
    else:
        path = filetools.join(download_path, '*.json')
        ficheros = glob.glob(path)
        ficheros.sort(key=os.path.getmtime, reverse=False)

    for down_path in ficheros:

        # ~ it = Item().fromjson(path=down_path) # falla con smb://
        it = Item().fromjson(filetools.read(down_path))

        it.from_channel = it.channel
        it.from_action = it.action
        it.channel = item.channel
        it.action = 'acciones_enlace'
        it.jsonfile = down_path
        it.folder = False

        if it.downloadStatus == STATUS_CODES.completed:
            it.title = '[B][COLOR gold][Ok] %s [%s][/COLOR][/B]' % (
                it.downloadFilename, config.format_bytes(it.downloadSize))

        elif it.downloadStatus == STATUS_CODES.canceled:
            it.title = '[COLOR red][%s%%] %s [%s de %s][/COLOR]' % (
                int(it.downloadProgress), it.downloadFilename,
                config.format_bytes(it.downloadCompleted),
                config.format_bytes(it.downloadSize))

        elif it.downloadStatus == STATUS_CODES.error:
            it.title = '[I][COLOR gray][Error] %s[/COLOR][/I]' % it.downloadFilename

        else:
            it.title = '[I][COLOR gray][???] %s[/COLOR][/I]' % it.downloadFilename

        itemlist.append(it)

    return itemlist
コード例 #3
0
ファイル: launcher.py プロジェクト: vdeku/xbmc-tvalacarta
def getitems(item):
    logger.info("getitems")
    itemlist = []
    
    # Extrae los parámetros
    channel = item.channel
    accion = item.action
    url = item.url
    if url!="none":
        if not "filenium" in url:
            url = urllib.unquote_plus(url)
    server = item.server
    title = item.title
    extra = item.extra
    category = item.category
    fulltitle = item.fulltitle

    try:
        if accion=="mainlist" and config.get_setting("updatechannels")=="true":
            try:
                logger.info("Verificando actualización del canal")
                from core import updater
                actualizado = updater.updatechannel(channel)
        
                if actualizado:
                    itemlist.append( Item(title="¡Canal descargado y actualizado!") )
            except:
                import sys
                for line in sys.exc_info():
                    logger.error( "%s" % line )
    
        # El item que invocó es importante para obtener el siguiente
        senderitem = Item( title=title , channel=channel, action=accion, url=url , server=server, extra=extra, category=category, fulltitle=fulltitle )
        if "|" in url:
            partes = urllib.unquote_plus(senderitem.url).split("|")
            refered_item = Item(title=partes[0],url=partes[2],thumbnail="",server=partes[1],plot="",extra=partes[3])
            logger.info( "refered_item title="+refered_item.title+", url="+refered_item.url+", server="+refered_item.server+", extra="+refered_item.extra)
    
        else:
            refered_item = Item()
    
        # Importa el canal y ejecuta la función
        try:
            exec "from pelisalacarta.channels import "+channel+" as channelmodule"
        except:
            import sys
            for line in sys.exc_info():
                logger.error( "%s" % line )
            try:
                exec "from pelisalacarta import "+channel+" as channelmodule"
            except:
                import sys
                for line in sys.exc_info():
                    logger.error( "%s" % line )
                try:
                    exec "from core import "+channel+" as channelmodule"
                except:
                    pass
    
        # play - es el menú de reproducción de un vídeo
        if accion=="play":
            logger.info("ACCION PLAY")
            if hasattr(channelmodule, 'play'):
                logger.info("[launcher.py] executing channel 'play' method")
                logger.info(channelmodule.__file__)
                itemlist = channelmodule.play(senderitem)
                senderitem = itemlist[0]
                senderitem.folder=False
            else:
                logger.info("[launcher.py] no channel 'play' method, executing core method")
            itemlist = menu_video(senderitem)
    
        # play_video - genera una playlist con una sola entrada para que wiimc la reproduzca
        elif accion=="play_video":
            logger.info("ACCION PLAY_VIDEO")
            logger.info("url="+senderitem.url)
            senderitem.folder=False
            itemlist.append( senderitem )
    
        # search - es el buscador
        elif channel=="buscador" and accion=="mainlist":
            logger.info("ACCION SEARCH (buscador)")
            texto = requestpath.split("plx")[1]
            exec "itemlist = buscador.do_search_results(texto)"
            
        elif accion=="search":
            logger.info("ACCION SEARCH")
            texto = requestpath.split("plx")[1]
            exec "itemlist = channelmodule."+accion+"(senderitem,texto)"
    
        # findvideos - debe encontrar videos reproducibles
        elif accion=="findvideos":
            logger.info("ACCION FINDVIDEOS")
            try:
                exec "itemlist = channelmodule."+accion+"(senderitem)"
            except:
                import sys
                for line in sys.exc_info():
                    logger.error( "%s" % line )
                itemlist = findvideos(senderitem,channel)
        
        elif accion=="descargar":
            itemlist = download_item(senderitem,refered_item)
        elif accion=="download_all":
            itemlist = download_all(senderitem,refered_item)
        elif accion=="add_to_favorites":
            itemlist = add_to_favorites(senderitem,refered_item)
        elif accion=="remove_from_favorites":
            itemlist = remove_from_favorites(senderitem,refered_item)
        elif accion=="add_to_downloads":
            itemlist = add_to_downloads(senderitem,refered_item)
        elif accion=="remove_from_downloads":
            itemlist = remove_from_downloads(senderitem,refered_item)
    
        elif accion=="remove_from_error_downloads":
            itemlist = remove_from_error_downloads(senderitem,refered_item)
        elif accion=="add_again_to_downloads":
            itemlist = add_again_to_downloads(senderitem,refered_item)
        elif accion=="send_to_jdownloader":
            itemlist = send_to_jdownloader(senderitem,refered_item)
        elif accion=="search_trailer":
            itemlist = search_trailer(senderitem,refered_item)
        elif accion=="add_serie_to_wiideoteca":
            itemlist = wiideoteca.AgregarSerie(senderitem)
        elif accion=="UltimoVisto":
            itemlist = wiideoteca.UltimoVisto(senderitem)
    
        else:
            if senderitem.url=="none":
                senderitem.url=""
            exec "itemlist.extend( channelmodule."+accion+"(senderitem) )"
        
        '''
        # Lo almacena en cache
        fichero = open( cached_file ,"wb")
        cerealizer.dump(itemlist,fichero)
        fichero.close()
        '''
    
        logger.info("Items devueltos")
        for item in itemlist:
            logger.info( " " + item.title + " | " + item.url + " | " + item.action)
    except:
        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)

    return itemlist,channel
コード例 #4
0
def getitems(item):
    logger.info("getitems")
    itemlist = []

    # Extrae los parámetros
    channel = item.channel
    accion = item.action
    url = item.url
    if url != "none":
        if not "filenium" in url:
            url = urllib.unquote_plus(url)
    server = item.server
    title = item.title
    extra = item.extra
    category = item.category
    fulltitle = item.fulltitle

    try:
        if accion == "mainlist" and config.get_setting(
                "updatechannels") == "true":
            try:
                logger.info("Verificando actualización del canal")
                from core import updater
                actualizado = updater.updatechannel(channel)

                if actualizado:
                    itemlist.append(
                        Item(title="¡Canal descargado y actualizado!"))
            except:
                import sys
                for line in sys.exc_info():
                    logger.error("%s" % line)

        # El item que invocó es importante para obtener el siguiente
        senderitem = Item(title=title,
                          channel=channel,
                          action=accion,
                          url=url,
                          server=server,
                          extra=extra,
                          category=category,
                          fulltitle=fulltitle)
        if "|" in url:
            partes = urllib.unquote_plus(senderitem.url).split("|")
            refered_item = Item(title=partes[0],
                                url=partes[2],
                                thumbnail="",
                                server=partes[1],
                                plot="",
                                extra=partes[3])
            logger.info("refered_item title=" + refered_item.title + ", url=" +
                        refered_item.url + ", server=" + refered_item.server +
                        ", extra=" + refered_item.extra)

        else:
            refered_item = Item()

        # Importa el canal y ejecuta la función
        try:
            exec "from pelisalacarta.channels import " + channel + " as channelmodule"
        except:
            import sys
            for line in sys.exc_info():
                logger.error("%s" % line)
            try:
                exec "from pelisalacarta import " + channel + " as channelmodule"
            except:
                import sys
                for line in sys.exc_info():
                    logger.error("%s" % line)
                try:
                    exec "from core import " + channel + " as channelmodule"
                except:
                    pass

        # play - es el menú de reproducción de un vídeo
        if accion == "play":
            logger.info("ACCION PLAY")
            if hasattr(channelmodule, 'play'):
                logger.info("[launcher.py] executing channel 'play' method")
                logger.info(channelmodule.__file__)
                itemlist = channelmodule.play(senderitem)
                senderitem = itemlist[0]
                senderitem.folder = False
            else:
                logger.info(
                    "[launcher.py] no channel 'play' method, executing core method"
                )
            itemlist = menu_video(senderitem)

        # play_video - genera una playlist con una sola entrada para que wiimc la reproduzca
        elif accion == "play_video":
            logger.info("ACCION PLAY_VIDEO")
            logger.info("url=" + senderitem.url)
            senderitem.folder = False
            itemlist.append(senderitem)

        # search - es el buscador
        elif channel == "buscador" and accion == "mainlist":
            logger.info("ACCION SEARCH (buscador)")
            texto = requestpath.split("plx")[1]
            exec "itemlist = buscador.do_search_results(texto)"

        elif accion == "search":
            logger.info("ACCION SEARCH")
            texto = requestpath.split("plx")[1]
            exec "itemlist = channelmodule." + accion + "(senderitem,texto)"

        # findvideos - debe encontrar videos reproducibles
        elif accion == "findvideos":
            logger.info("ACCION FINDVIDEOS")
            try:
                exec "itemlist = channelmodule." + accion + "(senderitem)"
            except:
                import sys
                for line in sys.exc_info():
                    logger.error("%s" % line)
                itemlist = findvideos(senderitem, channel)

        elif accion == "descargar":
            itemlist = download_item(senderitem, refered_item)
        elif accion == "download_all":
            itemlist = download_all(senderitem, refered_item)
        elif accion == "add_to_favorites":
            itemlist = add_to_favorites(senderitem, refered_item)
        elif accion == "remove_from_favorites":
            itemlist = remove_from_favorites(senderitem, refered_item)
        elif accion == "add_to_downloads":
            itemlist = add_to_downloads(senderitem, refered_item)
        elif accion == "remove_from_downloads":
            itemlist = remove_from_downloads(senderitem, refered_item)

        elif accion == "remove_from_error_downloads":
            itemlist = remove_from_error_downloads(senderitem, refered_item)
        elif accion == "add_again_to_downloads":
            itemlist = add_again_to_downloads(senderitem, refered_item)
        elif accion == "send_to_jdownloader":
            itemlist = send_to_jdownloader(senderitem, refered_item)
        elif accion == "search_trailer":
            itemlist = search_trailer(senderitem, refered_item)
        elif accion == "add_serie_to_wiideoteca":
            itemlist = wiideoteca.AgregarSerie(senderitem)
        elif accion == "UltimoVisto":
            itemlist = wiideoteca.UltimoVisto(senderitem)

        else:
            if senderitem.url == "none":
                senderitem.url = ""
            exec "itemlist.extend( channelmodule." + accion + "(senderitem) )"
        '''
        # Lo almacena en cache
        fichero = open( cached_file ,"wb")
        cerealizer.dump(itemlist,fichero)
        fichero.close()
        '''

        logger.info("Items devueltos")
        for item in itemlist:
            logger.info(" " + item.title + " | " + item.url + " | " +
                        item.action)
    except:
        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)

    return itemlist, channel
コード例 #5
0
ファイル: rsstools.py プロジェクト: hmemar/xbmc-tvalacarta
def getitems(requestpath):
    logger.info("getitems")
    itemlist = []

    # La ruta empleada en la petición
    ruta = requestpath.split("?")[0]
    logger.info("ruta="+ruta)

    # Los parámetros son las partes de la ruta separadas por "/"
    rutas = ruta.split("/")
    cadena = " "
    
    # Las imprime en el log
    for linea in rutas:
        cadena = cadena + linea + " | "
    logger.info( cadena )

    # Extrae los parámetros
    channel = rutas[2]
    accion = rutas[3]
    url = rutas[4]
    if url!="none": url = urllib.unquote_plus(url)
    server = rutas[5].lower()
    title = urllib.unquote_plus(rutas[6])
    extra = urllib.unquote_plus(rutas[7])
    category = urllib.unquote_plus(rutas[8])
    fulltitle = urllib.unquote_plus(rutas[9])
    logger.info( "channel="+channel+", accion="+accion+", url="+url+", server="+server+", title="+title+", extra="+extra+", category="+category+" fulltitle="+fulltitle)
    print "channel="+channel+", accion="+accion+", url="+url+", server="+server+", title="+title+", extra="+extra+", category="+category

    if accion=="mainlist" and config.get_setting("updatechannels")=="true":
        logger.info("Verificando actualización del canal")
        from core import updater
        actualizado = updater.updatechannel(channel)

        if actualizado:
            itemlist.append( Item(title="¡Canal descargado y actualizado!") )

    # Obtiene un nombre válido para la cache
    hashed_url = binascii.hexlify(md5.new(requestpath).digest())
    cached_file = os.path.join( config.get_data_path() , "tmp" , "cache" , hashed_url )
    logger.info("cached_file="+cached_file)
    
    # Si el fichero está en cache
    if channel not in ("trailertools","buscador","configuracion","pyload","wiidoteca") and os.path.exists(cached_file): # <--
        logger.info( "Reading from cache" )
        fichero = open( cached_file ,"rb")
        itemlist = cerealizer.load(fichero)
        fichero.close()

    else:
        logger.info( "Not cached" )

### ESTUDIAR 
        #if accion not in ("play","findvideos","detail"): titulo = ""
### 
        # El item que invocó es importante para obtener el siguiente
        senderitem = Item( title=title , channel=channel, action=accion, url=url , server=server, extra=extra, category=category, fulltitle=fulltitle )
        if "|" in url:
            ## <-- unquote despues de split para no interferir cuando | aparece en algun campo
            partes = senderitem.url.split("|")
            decpartes = []
            for parte in partes:
               decpartes.append(urllib.unquote_plus(parte))
            partes = decpartes
            ## <--
            refered_item = Item(title=partes[0],url=partes[2],thumbnail=partes[5],server=partes[1],plot=partes[6],extra=partes[3], fulltitle=partes[4])
            logger.info( "refered_item title="+refered_item.title+", url="+refered_item.url+", server="+refered_item.server+", extra="+refered_item.extra)
    
        else:
            refered_item = Item()
    
        # Importa el canal y ejecuta la función
        if channel in ("configuracion", "trailertools", "buscador") :
           exec "import "+channel
        else:
            try:
               exec "from tvalacarta.channels import "+channel
            except:
               exec "from core import "+channel
    
        # play - es el menú de reproducción de un vídeo
        if accion=="play":
            logger.info("ACCION PLAY")
            print "ACCION PLAY"
            try:
                exec "itemlist = "+channel+".play(senderitem)"
                print "itemlist = "+channel+".play(senderitem)"
                senderitem = itemlist[0]
                senderitem.folder=False
            except:
                import sys
                for line in sys.exc_info():
                    logger.error( "%s" % line )
    
            itemlist = menu_video(senderitem)
    
        # play_video - genera una playlist con una sola entrada para que wiimc la reproduzca
        elif accion=="play_video":
            logger.info("ACCION PLAY_VIDEO")
            senderitem.folder=False
            itemlist.append( senderitem )
    
        # search - es el buscador
        elif accion == "search":
            logger.info("ACCION SEARCH")
            texto = requestpath.split(".rss")[1]
            exec "itemlist = "+channel+"."+accion+"(senderitem,texto)"    
    
        # findvideos - debe encontrar videos reproducibles
        elif accion=="findvideos":
            logger.info("ACCION FINDVIDEOS")
            try:
                exec "itemlist = "+channel+"."+accion+"(senderitem)"
            except:
                import sys
                for line in sys.exc_info():
                    logger.error( "%s" % line )
                itemlist = findvideos(senderitem,channel)
        
        elif accion=="descargar":
            itemlist = download_item(senderitem,refered_item)
        elif accion=="downloadall":                                ## <--
            itemlist = downloadall(senderitem,refered_item)        ## <--
        elif accion=="add_to_favorites":
            itemlist = add_to_favorites(senderitem,refered_item)
        elif accion=="remove_from_favorites":
            itemlist = remove_from_favorites(senderitem,refered_item)
        elif accion=="add_to_downloads":
            itemlist = add_to_downloads(senderitem,refered_item)
        elif accion=="remove_from_downloads":
            itemlist = remove_from_downloads(senderitem,refered_item)
    
        elif accion=="remove_from_error_downloads":
            itemlist = remove_from_error_downloads(senderitem,refered_item)
        elif accion=="add_again_to_downloads":
            itemlist = add_again_to_downloads(senderitem,refered_item)
        elif accion=="send_to_jdownloader":
            itemlist = send_to_jdownloader(senderitem,refered_item)
        elif accion=="send_to_pyload":
            itemlist = send_to_pyload(senderitem,refered_item)
        elif accion=="search_trailer":
            itemlist = search_trailer(senderitem,refered_item)
        elif accion=="add_serie_to_wiideoteca":
            itemlist = wiideoteca.AgregarSerie(senderitem)
        elif accion=="UltimoVisto":
            itemlist = wiideoteca.UltimoVisto(senderitem)
    
        else:
            if senderitem.url=="none":
                senderitem.url=""
            exec "itemlist.extend( "+channel+"."+accion+"(senderitem) )"
    
        # Lo almacena en cache
        fichero = open( cached_file ,"wb")
        cerealizer.dump(itemlist,fichero)
        fichero.close()
    
    logger.info("Items devueltos")
    for item in itemlist:
        logger.info( " " + item.title + " | " + item.url + " | " + item.action)

    return itemlist,channel
コード例 #6
0
def getitems(requestpath):
    logger.info("getitems")
    itemlist = []

    # La ruta empleada en la petición
    ruta = requestpath.split("?")[0]
    logger.info("ruta=" + ruta)

    # Los parámetros son las partes de la ruta separadas por "/"
    rutas = ruta.split("/")
    cadena = " "

    # Las imprime en el log
    for linea in rutas:
        cadena = cadena + linea + " | "
    logger.info(cadena)

    # Extrae los parámetros
    channel = rutas[2]
    accion = rutas[3]
    url = rutas[4]
    if url != "none": url = urllib.unquote_plus(url)
    server = rutas[5].lower()
    title = urllib.unquote_plus(rutas[6])
    extra = urllib.unquote_plus(rutas[7])
    category = urllib.unquote_plus(rutas[8])
    fulltitle = urllib.unquote_plus(rutas[9])
    logger.info("channel=" + channel + ", accion=" + accion + ", url=" + url +
                ", server=" + server + ", title=" + title + ", extra=" +
                extra + ", category=" + category + " fulltitle=" + fulltitle)
    print "channel=" + channel + ", accion=" + accion + ", url=" + url + ", server=" + server + ", title=" + title + ", extra=" + extra + ", category=" + category

    if accion == "mainlist" and config.get_setting("updatechannels") == "true":
        logger.info("Verificando actualización del canal")
        from core import updater
        actualizado = updater.updatechannel(channel)

        if actualizado:
            itemlist.append(Item(title="¡Canal descargado y actualizado!"))

    # Obtiene un nombre válido para la cache
    hashed_url = binascii.hexlify(md5.new(requestpath).digest())
    cached_file = os.path.join(config.get_data_path(), "tmp", "cache",
                               hashed_url)
    logger.info("cached_file=" + cached_file)

    # Si el fichero está en cache
    if channel not in ("trailertools", "buscador", "configuracion", "pyload",
                       "wiidoteca") and os.path.exists(cached_file):  # <--
        logger.info("Reading from cache")
        fichero = open(cached_file, "rb")
        itemlist = cerealizer.load(fichero)
        fichero.close()

    else:
        logger.info("Not cached")

        ### ESTUDIAR
        #if accion not in ("play","findvideos","detail"): titulo = ""
        ###
        # El item que invocó es importante para obtener el siguiente
        senderitem = Item(title=title,
                          channel=channel,
                          action=accion,
                          url=url,
                          server=server,
                          extra=extra,
                          category=category,
                          fulltitle=fulltitle)
        if "|" in url:
            ## <-- unquote despues de split para no interferir cuando | aparece en algun campo
            partes = senderitem.url.split("|")
            decpartes = []
            for parte in partes:
                decpartes.append(urllib.unquote_plus(parte))
            partes = decpartes
            ## <--
            refered_item = Item(title=partes[0],
                                url=partes[2],
                                thumbnail=partes[5],
                                server=partes[1],
                                plot=partes[6],
                                extra=partes[3],
                                fulltitle=partes[4])
            logger.info("refered_item title=" + refered_item.title + ", url=" +
                        refered_item.url + ", server=" + refered_item.server +
                        ", extra=" + refered_item.extra)

        else:
            refered_item = Item()

        # Importa el canal y ejecuta la función
        if channel in ("configuracion", "trailertools", "buscador"):
            exec "import " + channel
        else:
            try:
                exec "from tvalacarta.channels import " + channel
            except:
                exec "from core import " + channel

        # play - es el menú de reproducción de un vídeo
        if accion == "play":
            logger.info("ACCION PLAY")
            print "ACCION PLAY"
            try:
                exec "itemlist = " + channel + ".play(senderitem)"
                print "itemlist = " + channel + ".play(senderitem)"
                senderitem = itemlist[0]
                senderitem.folder = False
            except:
                import sys
                for line in sys.exc_info():
                    logger.error("%s" % line)

            itemlist = menu_video(senderitem)

        # play_video - genera una playlist con una sola entrada para que wiimc la reproduzca
        elif accion == "play_video":
            logger.info("ACCION PLAY_VIDEO")
            senderitem.folder = False
            itemlist.append(senderitem)

        # search - es el buscador
        elif accion == "search":
            logger.info("ACCION SEARCH")
            texto = requestpath.split(".rss")[1]
            exec "itemlist = " + channel + "." + accion + "(senderitem,texto)"

        # findvideos - debe encontrar videos reproducibles
        elif accion == "findvideos":
            logger.info("ACCION FINDVIDEOS")
            try:
                exec "itemlist = " + channel + "." + accion + "(senderitem)"
            except:
                import sys
                for line in sys.exc_info():
                    logger.error("%s" % line)
                itemlist = findvideos(senderitem, channel)

        elif accion == "descargar":
            itemlist = download_item(senderitem, refered_item)
        elif accion == "downloadall":  ## <--
            itemlist = downloadall(senderitem, refered_item)  ## <--
        elif accion == "add_to_favorites":
            itemlist = add_to_favorites(senderitem, refered_item)
        elif accion == "remove_from_favorites":
            itemlist = remove_from_favorites(senderitem, refered_item)
        elif accion == "add_to_downloads":
            itemlist = add_to_downloads(senderitem, refered_item)
        elif accion == "remove_from_downloads":
            itemlist = remove_from_downloads(senderitem, refered_item)

        elif accion == "remove_from_error_downloads":
            itemlist = remove_from_error_downloads(senderitem, refered_item)
        elif accion == "add_again_to_downloads":
            itemlist = add_again_to_downloads(senderitem, refered_item)
        elif accion == "send_to_jdownloader":
            itemlist = send_to_jdownloader(senderitem, refered_item)
        elif accion == "send_to_pyload":
            itemlist = send_to_pyload(senderitem, refered_item)
        elif accion == "search_trailer":
            itemlist = search_trailer(senderitem, refered_item)
        elif accion == "add_serie_to_wiideoteca":
            itemlist = wiideoteca.AgregarSerie(senderitem)
        elif accion == "UltimoVisto":
            itemlist = wiideoteca.UltimoVisto(senderitem)

        else:
            if senderitem.url == "none":
                senderitem.url = ""
            exec "itemlist.extend( " + channel + "." + accion + "(senderitem) )"

        # Lo almacena en cache
        fichero = open(cached_file, "wb")
        cerealizer.dump(itemlist, fichero)
        fichero.close()

    logger.info("Items devueltos")
    for item in itemlist:
        logger.info(" " + item.title + " | " + item.url + " | " + item.action)

    return itemlist, channel
コード例 #7
0
ファイル: globalsearch.py プロジェクト: aandroide/addon
    def onClick(self, control_id):
        global close_action

        if self.RESULTS.getSelectedItem(): search = self.RESULTS.getSelectedItem().getProperty('search')
        else: search = None
        if control_id in [CHANNELS]:
            items = []
            name = self.CHANNELS.getSelectedItem().getLabel()
            subpos = int(self.CHANNELS.getSelectedItem().getProperty('position'))
            channelResults = self.CHANNELS.getListItem(self.results[name]).getProperty('items').split('|')
            for result in channelResults:
                if result: items.append(self.makeItem(result))
            self.RESULTS.reset()
            self.RESULTS.addItems(items)
            self.RESULTS.selectItem(subpos)
            self.CHANNELS.getSelectedItem().setProperty('position', str(subpos))

        elif control_id in [BACK]:
            self.Back()

        elif control_id in [CLOSE]:
            self.Close()
            close_action = True

        elif control_id in [MENU]:
            self.context()

        elif search:
            pos = self.RESULTS.getSelectedPosition()
            if search == 'next':
                self.page += 1
                self.actors()
            elif search == 'previous':
                self.page -= 1
                self.actors()
            elif search == 'persons':
                item = Item().fromurl(self.RESULTS.getSelectedItem().getProperty('item')).clone(mode='person_', discovery=self.persons[pos], text=True, folder=False)
                Search(item, self.thActions)
                if close_action:
                    self.close()
            else:
                item = Item().fromurl(self.RESULTS.getSelectedItem().getProperty('item'))
                if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
                else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
                item.folder = False

                logger.debug(item)
                Search(item, self.thActions)
                if close_action:
                    self.close()

        elif control_id in [RESULTS, EPISODESLIST]:
            busy(True)
            if control_id in [RESULTS]:
                name = self.CHANNELS.getSelectedItem().getLabel()
                self.pos = self.RESULTS.getSelectedPosition()
                item = Item().fromurl(self.RESULTS.getSelectedItem().getProperty('item'))
            else:
                item_url = self.EPISODESLIST.getSelectedItem().getProperty('item')
                if item_url:
                    item = Item().fromurl(item_url)
                else:  # no results  item
                    busy(False)
                    return

                if item.action in ['add_pelicula_to_library', 'add_serie_to_library','save_download']:  # special items (add to videolibrary, download ecc.)
                    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item_url + ")")
                    busy(False)
                    return

            try:
                self.channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
                self.itemsResult = getattr(self.channel, item.action)(item)
            except:
                import traceback
                logger.error('error importing/getting search items of ' + item.channel)
                logger.error(traceback.format_exc())
                self.itemsResult = []

            if self.itemsResult and self.itemsResult[0].action in ['play', '']:

                if config.get_setting('checklinks') and not config.get_setting('autoplay'):
                    self.itemsResult = servertools.check_list_links(self.itemsResult, config.get_setting('checklinks_number'))
                servers = self.itemsResult if self.itemsResult else []
                self.itemsResult = []
                uhd = []
                fhd = []
                hd = []
                sd = []
                unknown = []
                other = []
                for i, item in enumerate(servers):
                    if item.server:
                        it = self.makeItem(item.tourl())
                        it.setProperty('index', str(i))
                        if item.quality.lower() in ['4k', '2160p', '2160', '4k2160p', '4k2160', '4k 2160p', '4k 2160', '2k']:
                            it.setProperty('quality', 'uhd.png')
                            uhd.append(it)
                        elif item.quality.lower() in ['fullhd', 'fullhd 1080', 'fullhd 1080p', 'full hd', 'full hd 1080', 'full hd 1080p', 'hd1080', 'hd1080p', 'hd 1080', 'hd 1080p', '1080', '1080p']:
                            it.setProperty('quality', 'Fhd.png')
                            fhd.append(it)
                        elif item.quality.lower() in ['hd', 'hd720', 'hd720p', 'hd 720', 'hd 720p', '720', '720p', 'hdtv']:
                            it.setProperty('quality', 'hd.png')
                            hd.append(it)
                        elif item.quality.lower() in ['sd', '480p', '480', '360p', '360', '240p', '240']:
                            it.setProperty('quality', 'sd.png')
                            sd.append(it)
                        else:
                            it.setProperty('quality', '')
                            unknown.append(it)
                    elif not item.action:
                        self.getControl(QUALITYTAG).setText(item.fulltitle)
                    else:
                        it = self.makeItem(item.tourl())
                        other.append(it)

                uhd.sort(key=lambda it: it.getProperty('index'))
                fhd.sort(key=lambda it: it.getProperty('index'))
                hd.sort(key=lambda it: it.getProperty('index'))
                sd.sort(key=lambda it: it.getProperty('index'))
                unknown.sort(key=lambda it: it.getProperty('index'))

                serverlist = uhd + fhd + hd + sd + unknown + other
                if not serverlist:
                    serverlist = [xbmcgui.ListItem(config.get_localized_string(60347))]
                    serverlist[0].setProperty('thumb', channelselector.get_thumb('nofolder.png'))

                self.Focus(SERVERS)
                self.SERVERLIST.reset()
                self.SERVERLIST.addItems(serverlist)
                self.setFocusId(SERVERLIST)

                if config.get_setting('autoplay'):
                    busy(False)

            else:
                self.episodes = self.itemsResult if self.itemsResult else []
                self.itemsResult = []
                ep = []
                for item in self.episodes:
                    it = xbmcgui.ListItem(item.title)
                    it.setProperty('item', item.tourl())
                    ep.append(it)

                if not ep:
                    ep = [xbmcgui.ListItem(config.get_localized_string(60347))]
                    ep[0].setProperty('thumb', channelselector.get_thumb('nofolder.png'))

                self.Focus(EPISODES)
                self.EPISODESLIST.reset()
                self.EPISODESLIST.addItems(ep)
                self.setFocusId(EPISODESLIST)

            busy(False)

        elif control_id in [SERVERLIST]:
            server = Item().fromurl(self.getControl(control_id).getSelectedItem().getProperty('item'))
            return self.play(server)
コード例 #8
0
ファイル: globalsearch.py プロジェクト: rrosajp/addon
    def onClick(self, control_id):
        global close_action

        if self.RESULTS.getSelectedItem():
            search = self.RESULTS.getSelectedItem().getProperty('search')
        else:
            search = None
        if control_id in [CHANNELS]:
            items = []
            name = self.CHANNELS.getSelectedItem().getLabel()
            subpos = int(
                self.CHANNELS.getSelectedItem().getProperty('position'))
            channelResults = self.CHANNELS.getListItem(
                self.results[name]).getProperty('items').split('|')
            for result in channelResults:
                if result: items.append(self.makeItem(result))
            self.RESULTS.reset()
            self.RESULTS.addItems(items)
            self.RESULTS.selectItem(subpos)
            self.CHANNELS.getSelectedItem().setProperty(
                'position', str(subpos))

        elif control_id in [BACK]:
            self.Back()

        elif control_id in [CLOSE]:
            self.Close()
            close_action = True

        elif control_id in [MENU]:
            self.context()

        elif search:
            pos = self.RESULTS.getSelectedPosition()
            if search == 'next':
                self.page += 1
                self.actors()
            elif search == 'previous':
                self.page -= 1
                self.actors()
            elif search == 'persons':
                item = Item().fromurl(
                    self.RESULTS.getSelectedItem().getProperty('item')).clone(
                        mode='person_',
                        discovery=self.persons[pos],
                        text=True,
                        folder=False)
                Search(item, self.thActions)
                if close_action:
                    self.close()
            else:
                item = Item().fromurl(
                    self.RESULTS.getSelectedItem().getProperty('item'))
                if self.item.mode == 'movie':
                    item.contentTitle = self.RESULTS.getSelectedItem(
                    ).getLabel()
                else:
                    item.contentSerieName = self.RESULTS.getSelectedItem(
                    ).getLabel()
                item.folder = False

                logger.debug(item)
                Search(item, self.thActions)
                if close_action:
                    self.close()

        elif control_id in [RESULTS, EPISODESLIST]:
            busy(True)
            if control_id in [RESULTS]:
                name = self.CHANNELS.getSelectedItem().getLabel()
                self.pos = self.RESULTS.getSelectedPosition()
                item = Item().fromurl(
                    self.RESULTS.getSelectedItem().getProperty('item'))
            else:
                item_url = self.EPISODESLIST.getSelectedItem().getProperty(
                    'item')
                if item_url:
                    item = Item().fromurl(item_url)
                else:  # no results  item
                    busy(False)
                    return

                if item.action != 'episodios':
                    xbmc.executebuiltin(
                        "RunPlugin(plugin://plugin.video.kod/?" + item_url +
                        ")")
                    busy(False)
                    return

            try:
                self.channel = __import__(
                    'channels.%s' % item.channel,
                    fromlist=["channels.%s" % item.channel])
                self.itemsResult = getattr(self.channel, item.action)(item)
                if self.itemsResult and self.itemsResult[0].server:
                    from platformcode.launcher import findvideos
                    findvideos(self.item, self.itemsResult)
                    return
            except:
                import traceback
                logger.error('error importing/getting search items of ' +
                             item.channel)
                logger.error(traceback.format_exc())
                self.itemsResult = []

            self.episodes = self.itemsResult if self.itemsResult else []
            self.itemsResult = []
            ep = []
            for item in self.episodes:
                it = xbmcgui.ListItem(item.title)
                it.setProperty('item', item.tourl())
                ep.append(it)

            if not ep:
                ep = [xbmcgui.ListItem(config.get_localized_string(60347))]
                ep[0].setProperty('thumb',
                                  channelselector.get_thumb('nofolder.png'))

            self.Focus(EPISODES)
            self.EPISODESLIST.reset()
            self.EPISODESLIST.addItems(ep)
            self.setFocusId(EPISODESLIST)

            busy(False)

        elif control_id in [SERVERLIST]:
            server = Item().fromurl(
                self.getControl(control_id).getSelectedItem().getProperty(
                    'item'))
            return self.play(server)