Esempio n. 1
0
def controls(itemlist, item, AutoPlay=True, CheckLinks=True):
    from core import jsontools
    from platformcode.config import get_setting

    CL = get_setting('checklinks') or get_setting('checklinks', item.channel)
    autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
    channel_node = autoplay_node.get(item.channel, {})
    if not channel_node:  # non ha mai aperto il menu del canale quindi in autoplay_data.json non c'e la key
        channelFile = __import__('channels.' + item.channel,
                                 fromlist=["channels.%s" % item.channel])
        autoplay.init(item.channel, channelFile.list_servers,
                      channelFile.list_quality)

    autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
    channel_node = autoplay_node.get(item.channel, {})
    settings_node = channel_node.get('settings', {})
    AP = get_setting('autoplay') or settings_node['active']

    if CL and not AP:
        if get_setting('checklinks', item.channel):
            checklinks = get_setting('checklinks', item.channel)
        else:
            checklinks = get_setting('checklinks')
        if get_setting('checklinks_number', item.channel):
            checklinks_number = get_setting('checklinks_number', item.channel)
        else:
            checklinks_number = get_setting('checklinks_number')
        itemlist = servertools.check_list_links(itemlist, checklinks_number)

    if AutoPlay == True:
        autoplay.start(itemlist, item)

    videolibrary(itemlist, item, function_level=3)
    return itemlist
Esempio n. 2
0
def get_channel_AP_HS(item):
    autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
    channel_node = autoplay_node.get(item.channel, {})
    if not channel_node:  # non ha mai aperto il menu del canale quindi in autoplay_data.json non c'e la key
        try:
            channelFile = __import__('channels.' + item.channel,
                                     fromlist=["channels.%s" % item.channel])
        except:
            channelFile = __import__('specials.' + item.channel,
                                     fromlist=["specials.%s" % item.channel])
        if hasattr(channelFile, 'list_servers') and hasattr(
                channelFile, 'list_quality'):
            init(item.channel, channelFile.list_servers,
                 channelFile.list_quality)

    autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
    channel_node = autoplay_node.get(item.channel, {})
    settings_node = channel_node.get('settings', {})
    AP = get_setting('autoplay') or (settings_node['active']
                                     if 'active' in settings_node else False)
    HS = config.get_setting('hide_servers') or (settings_node['hide_servers']
                                                if 'hide_server'
                                                in settings_node else False)

    return AP, HS
Esempio n. 3
0
def controls(itemlist, item, AutoPlay=True, CheckLinks=True, down_load=True):
    from core import jsontools
    from platformcode.config import get_setting

    CL = get_setting('checklinks') or get_setting('checklinks', item.channel)
    autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
    channel_node = autoplay_node.get(item.channel, {})
    if not channel_node:  # non ha mai aperto il menu del canale quindi in autoplay_data.json non c'e la key
        channelFile = __import__('channels.' + item.channel,
                                 fromlist=["channels.%s" % item.channel])
        autoplay.init(item.channel, channelFile.list_servers,
                      channelFile.list_quality)

    autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
    channel_node = autoplay_node.get(item.channel, {})
    settings_node = channel_node.get('settings', {})
    AP = get_setting('autoplay') or settings_node['active']
    HS = config.get_setting('hide_servers')

    if CL and not AP:
        if get_setting('checklinks', item.channel):
            checklinks = get_setting('checklinks', item.channel)
        else:
            checklinks = get_setting('checklinks')
        if get_setting('checklinks_number', item.channel):
            checklinks_number = get_setting('checklinks_number', item.channel)
        else:
            checklinks_number = get_setting('checklinks_number')
        itemlist = servertools.check_list_links(itemlist, checklinks_number)

    if AutoPlay == True and not 'downloads' in inspect.stack(
    )[3][1] + inspect.stack()[4][1]:
        autoplay.start(itemlist, item)

    if item.contentChannel != 'videolibrary':
        videolibrary(itemlist, item, function_level=3)
    if get_setting('downloadenabled') and down_load == True:
        download(itemlist, item, function_level=3)

    VL = False
    try:
        if  'downloads' in inspect.stack()[3][1] + inspect.stack()[4][1] or \
            inspect.stack()[4][3] == 'play_from_library' or \
            inspect.stack()[5][3] == 'play_from_library' or \
            'videolibrary' in inspect.stack()[3][1] or \
            'videolibrary' in inspect.stack()[4][1]:
            VL = True
    except:
        pass
    if not AP or VL or not HS:
        return itemlist
Esempio n. 4
0
def renumber(itemlist, item='', typography=''):
    log()
    if 'fromchannel' in item:
        item.channel = item.fromchannel if item.fromchannel else item.channel
    # Seleziona la funzione Adatta, Menu Contestuale o Rinumerazione
    if item:
        settings_node = jsontools.get_node_from_file(item.channel, 'settings')
        # Controlla se la Serie è già stata rinumerata

        try:
            dict_series = jsontools.get_node_from_file(item.channel,
                                                       TAG_TVSHOW_RENUMERATE)
            TITLE = item.fulltitle.rstrip()
            ID = dict_series[TITLE][TAG_ID]

            exist = True
        except:
            exist = False

        if exist:
            ID = dict_series[TITLE][TAG_ID]
            SEASON = dict_series[TITLE][TAG_SEASON]
            EPISODE = dict_series[TITLE][TAG_EPISODE]
            MODE = dict_series[TITLE][TAG_MODE]
            renumeration(itemlist, item, typography, dict_series, ID, SEASON,
                         EPISODE, MODE, TITLE)
        else:
            # se non è stata rinumerata controlla se è attiva la rinumerazione automatica
            if 'autorenumber' not in settings_node: return itemlist
            if settings_node['autorenumber'] == True:
                config_item(item, itemlist, typography, True)
    else:
        for item in itemlist:
            try:
                dict_series = jsontools.get_node_from_file(
                    itemlist[0].channel, TAG_TVSHOW_RENUMERATE)
                TITLE = item.show.rstrip()
                ID = dict_series[TITLE][TAG_ID]
                exist = True
            except:
                exist = False
            if item.contentType != 'movie':
                if item.context:
                    context2 = item.context
                    item.show = TITLE
                    item.context = context(exist) + context2
                else:
                    item.show = TITLE
                    item.context = context(exist)
Esempio n. 5
0
def clear_cache(category):
    menu_cache_path = os.path.join(config.get_data_path(), "settings_channels", 'menu_cache_data.json')
    if os.path.exists(menu_cache_path):
        cache_node = jsontools.get_node_from_file('menu_cache_data.json', 'cached')
        cache_node = dict()
        cache_node[category] = list()
        jsontools.update_node(cache_node, 'menu_cache_data.json', "cached")
Esempio n. 6
0
def set_status(status):
    logger.info()
    # Obtiene el nodo AUTOPLAY desde el json
    autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
    autoplay_node['status'] = status

    result, json_data = jsontools.update_node(autoplay_node, 'autoplay', 'AUTOPLAY')
Esempio n. 7
0
def delete_from_context(item):
    """
    Delete the filter through the context menu

    @param item: item
    @type item: item
    """
    logger.info()

    # We come from get_links and no result has been obtained, in context menu and we delete
    if item.to_channel != "":
        item.from_channel = item.to_channel

    dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
    tvshow = item.show.strip().lower()

    lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
    dict_series.pop(tvshow, None)

    result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)

    sound = False
    if result:
        message = "FILTER REMOVED"
    else:
        message = "Error saving to disk"
        sound = True

    heading = "%s [%s]" % (item.show.strip(), lang_selected)
    platformtools.dialog_notification(heading, message, sound=sound)

    if item.from_action in ["findvideos", "play", "no_filter"]:  # 'no_filter' es el mismo caso que L#601
        platformtools.itemlist_refresh()
Esempio n. 8
0
def is_active():
    '''
    Devuelve un booleano q indica si esta activo o no autoplay en el canal desde el que se llama

    :return: True si esta activo autoplay para el canal desde el que se llama, False en caso contrario.
    '''
    logger.info()
    global autoplay_node

    if not config.is_xbmc():
        return False

    if not autoplay_node:
        # Obtiene el nodo AUTOPLAY desde el json
        autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')

        # Obtine el canal desde el q se hace la llamada
        import inspect
        module = inspect.getmodule(inspect.currentframe().f_back)
        canal = module.__name__.split('.')[1]
        logger.debug(canal)

        # Obtiene el nodo del canal desde autoplay_node
        channel_node = autoplay_node.get(canal, {})
        # Obtiene los ajustes des autoplay para este canal
        settings_node = channel_node.get('settings', {})

        return settings_node.get('active', False)
Esempio n. 9
0
def delete_from_context(item):
    """
    Elimina el filtro a través del menú contextual

    @param item: item
    @type item: item
    """
    logger.info()

    # venimos desde get_links y no se ha obtenido ningún resultado, en menu contextual y damos a borrar
    if item.to_channel != "":
        item.from_channel = item.to_channel

    dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
    tvshow = item.show.strip().lower()

    lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
    dict_series.pop(tvshow, None)

    result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)

    sound = False
    if result:
        message = "FILTRO ELIMINADO"
    else:
        message = "Error al guardar en disco"
        sound = True

    heading = "%s [%s]" % (item.show.strip(), lang_selected)
    platformtools.dialog_notification(heading, message, sound=sound)

    if item.from_action in ["findvideos", "play", "no_filter"]:  # 'no_filter' es el mismo caso que L#601
        platformtools.itemlist_refresh()
Esempio n. 10
0
    def __get_data(self, item, global_filter_lang_id):

        dict_filtered_shows = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_FILTER)
        tvshow = item.show.lower().strip()

        global_filter_language = config.get_setting(global_filter_lang_id, item.channel)

        if tvshow in list(dict_filtered_shows.keys()):

            self.result = ResultFilter({TAG_ACTIVE: dict_filtered_shows[tvshow][TAG_ACTIVE],
                                        TAG_LANGUAGE: dict_filtered_shows[tvshow][TAG_LANGUAGE],
                                        TAG_QUALITY_ALLOWED: dict_filtered_shows[tvshow][TAG_QUALITY_ALLOWED]})

        # general option "do not filter"
        elif global_filter_language != 0:
            from core import channeltools
            list_controls, dict_settings = channeltools.get_channel_controls_settings(item.channel)

            for control in list_controls:
                if control["id"] == global_filter_lang_id:

                    try:
                        language = control["lvalues"][global_filter_language]
                        # logger.debug("language %s" % language)
                    except:
                        logger.error("The value associated with the code was not found '%s': %s" % (global_filter_lang_id, global_filter_language))
                        break

                    self.result = ResultFilter({TAG_ACTIVE: True, TAG_LANGUAGE: language, TAG_QUALITY_ALLOWED: []})
                    break
Esempio n. 11
0
def delete(item, dict_values):
    logger.info()

    if item:
        dict_series = jsontools.get_node_from_file(item.from_channel,
                                                   TAG_TVSHOW_FILTER)
        tvshow = item.show.strip().lower()

        heading = "¿Está seguro que desea eliminar el filtro?"
        line1 = "Pulse 'Si' para eliminar el filtro de [COLOR %s]%s[/COLOR], pulse 'No' o cierre la ventana para " \
                "no hacer nada." % (COLOR.get("selected", "auto"), item.show.strip())

        if platformtools.dialog_yesno(heading, line1) == 1:
            lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
            dict_series.pop(tvshow, None)

            result, json_data = jsontools.update_node(dict_series,
                                                      item.from_channel,
                                                      TAG_TVSHOW_FILTER)

            sound = False
            if result:
                message = "FILTRO ELIMINADO"
            else:
                message = "Error al guardar en disco"
                sound = True

            heading = "%s [%s]" % (item.show.strip(), lang_selected)
            platformtools.dialog_notification(heading, message, sound=sound)

            if item.action in ["findvideos", "play"]:
                platformtools.itemlist_refresh()
Esempio n. 12
0
def mainlist(channel):
    """
    Muestra una lista de las series renumeradas

    :param channel: nombre del canal para obtener las series renumeradas
    :type channel: str
    :return: lista de Item
    :rtype: list[Item]
    """
    logger.info()
    itemlist = []
    dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_RENUMERATE)

    idx = 0
    for tvshow in sorted(dict_series):
        tag_color = "0xff008000"
        if idx % 2 == 0:
            tag_color = "blue"

        idx += 1
        name = tvshow
        title = "Configurar [COLOR %s][%s][/COLOR]" % (tag_color, name)

        itemlist.append(Item(channel=__channel__, action="config_item", title=title, show=name, from_channel=channel))

    if len(itemlist) == 0:
        itemlist.append(Item(channel=channel, action="mainlist",
                             title="No se han encontrado series, busca una serie y pulsa en menú contextual "
                                   "'RENUMERAR'"))

    return itemlist
Esempio n. 13
0
def delete(item, dict_values):
    logger.info()

    if item:
        dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
        tvshow = item.show.strip().lower()

        heading = config.get_localized_string(60442)
        line1 = config.get_localized_string(60443) % (COLOR.get("selected", "auto"), item.show.strip())

        if platformtools.dialog_yesno(heading, line1) == 1:
            lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
            dict_series.pop(tvshow, None)

            result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)

            sound = False
            if result:
                message = config.get_localized_string(60444)
            else:
                message = config.get_localized_string(60445)
                sound = True

            heading = "%s [%s]" % (item.show.strip(), lang_selected)
            platformtools.dialog_notification(heading, message, sound=sound)

            if item.action in ["findvideos", "play"]:
                platformtools.itemlist_refresh()
Esempio n. 14
0
def save_from_context(item):
    """
    Save the filter through the context menu

    @param item: item
    @type item: item
    """
    logger.info()

    dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
    tvshow = item.show.strip().lower()

    dict_filter = {TAG_NAME: item.show, TAG_ACTIVE: True, TAG_LANGUAGE: item.language, TAG_QUALITY_ALLOWED: []}
    dict_series[tvshow] = dict_filter

    result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)

    sound = False
    if result:
        message = "SAVED FILTER"
    else:
        message = "Error saving to disk"
        sound = True

    heading = "%s [%s]" % (item.show.strip(), item.language)
    platformtools.dialog_notification(heading, message, sound=sound)

    if item.from_action in ["findvideos", "play"]:
        platformtools.itemlist_refresh()
Esempio n. 15
0
def write_data(channel, show, data):
    # OBTENEMOS LOS DATOS DEL JSON
    dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_RENUMERATE)
    tvshow = show.strip()
    list_season_episode = dict_series.get(tvshow, {}).get(TAG_SEASON_EPISODE, [])
    logger.debug("data %s" % list_season_episode)

    if data:
        # cambiamos el orden para que se vea en orden descendente y usarse bien en el _data.json
        data.sort(key=lambda el: int(el[0]), reverse=True)
        dict_renumerate = {TAG_SEASON_EPISODE: data}

        dict_series[tvshow] = dict_renumerate
    else:
        # hemos borrado todos los elementos, por lo que se borra la serie del fichero
        dict_series.pop(tvshow, None)

    result, json_data = jsontools.update_node(dict_series, channel, TAG_TVSHOW_RENUMERATE)

    if result:
        if data:
            message = "FILTRO GUARDADO"
        else:
            message = "FILTRO BORRADO"
    else:
        message = "Error al guardar en disco"

    heading = show.strip()
    platformtools.dialog_notification(heading, message)
Esempio n. 16
0
def config_item(item):
    """
    muestra una serie renumerada para su configuración

    :param item: item
    :type item: Item
    """
    logger.info("item %s" % item.tostring("\n"))

    dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_RENUMERATE)
    data = dict_series.get(item.show, {})

    if data:
        data = data.get(TAG_SEASON_EPISODE, [])

        ventana = RenumberWindow(show=item.show, channel=item.from_channel, data=data)
        del ventana
    else:
        # tenemos información y devolvemos los datos añadidos para que se muestre en la ventana
        if data:
            return add_season(data)
        # es la primera vez que se añaden datos (usando menú contextual) por lo que no devolvemos nada
        # para evitar error al listar los items
        else:
            data = add_season(data)
            write_data(item.from_channel, item.show, data)
Esempio n. 17
0
def save(item, dict_data_saved):
    '''
    Guarda los datos de la ventana de configuracion

    :param item: item
    :param dict_data_saved: dict
    :return:
    '''
    logger.info()
    global autoplay_node

    if not autoplay_node:
        # Obtiene el nodo AUTOPLAY desde el json
        autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')

    new_config = dict_data_saved
    if not new_config['active']:
        new_config['language'] = 0
    channel_node = autoplay_node.get(item.from_channel)
    config.set_setting("filter_languages", dict_data_saved.pop("language"),
                       item.from_channel)
    channel_node['settings'] = dict_data_saved

    result, json_data = jsontools.update_node(autoplay_node, 'autoplay',
                                              'AUTOPLAY')

    return result
Esempio n. 18
0
def write_data(channel, show, data):
    log()
    dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_RENUMERATE)
    tvshow = show.strip()
    list_season_episode = dict_series.get(tvshow,
                                          {}).get(TAG_SEASON_EPISODE, [])

    if data:
        dict_renumerate = {TAG_SEASON_EPISODE: data}
        dict_series[tvshow] = dict_renumerate
    else:
        dict_series.pop(tvshow, None)

    result, json_data = jsontools.update_node(dict_series, channel,
                                              TAG_TVSHOW_RENUMERATE)

    if result:
        if data:
            message = config.get_localized_string(60446)
        else:
            message = config.get_localized_string(60444)
    else:
        message = config.get_localized_string(70593)

    heading = show.strip()
    platformtools.dialog_notification(heading, message)
Esempio n. 19
0
def update_trakt_data(mediatype, trakt_data):
    logger.info()

    sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt')
    if os.path.exists(sync_path):
        trakt_node = jsontools.get_node_from_file('trakt', "TRAKT")
        trakt_node[mediatype] = trakt_data
        jsontools.update_node(trakt_node, 'trakt', 'TRAKT')
Esempio n. 20
0
def set_menu_settings(item):
    if os.path.exists(menu_settings_path):
        menu_node = jsontools.get_node_from_file('menu_settings_data.json', 'menu')
    else:
        menu_node = {}
    menu_node['categoria actual'] = item.extra

    jsontools.update_node(menu_node, 'menu_settings_data.json', "menu")
Esempio n. 21
0
def get_trakt_watched(id_type, mediatype, update=False):
    logger.info()

    id_list = []
    id_dict = dict()

    token_auth = config.get_setting("token_trakt", "trakt")

    if token_auth:
        sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt')

        if os.path.exists(sync_path) and not update:
            trakt_node = jsontools.get_node_from_file('trakt', "TRAKT")
            if mediatype == 'shows':
                return trakt_node['shows']
            if mediatype == 'movies':
                return trakt_node['movies']

        else:
            token_auth = config.get_setting("token_trakt", "trakt")
            if token_auth:
                try:
                    token_auth = config.get_setting("token_trakt", "trakt")
                    headers = [['Content-Type', 'application/json'], ['trakt-api-key', client_id],
                               ['trakt-api-version', '2']]
                    if token_auth:
                        headers.append(['Authorization', "Bearer %s" % token_auth])
                        url = "https://api.trakt.tv/sync/watched/%s" % mediatype
                        #data = httptools.downloadpage(url, headers=headers, replace_headers=True).data
                        data = httptools.downloadpage(url, headers=headers).data
                        watched_dict = jsontools.load(data)

                        if mediatype == 'shows':

                            dict_show = dict()
                            for item in watched_dict:
                                temp = []
                                id_ = str(item['show']['ids']['tmdb'])
                                season_dict = dict()
                                for season in item['seasons']:
                                    ep = []
                                    number = str(season['number'])
                                    # season_dict = dict()
                                    for episode in season['episodes']:
                                        ep.append(str(episode['number']))
                                    season_dict[number] = ep
                                    temp.append(season_dict)
                                dict_show[id_] = season_dict
                                id_dict = dict_show
                            return id_dict

                        elif mediatype == 'movies':
                            for item in watched_dict:
                                id_list.append(str(item['movie']['ids'][id_type]))
                except:
                    pass

    return id_list
Esempio n. 22
0
def config_item(item, itemlist=[], typography='', active=False):
    log()
    # Configurazione Automatica, Tenta la numerazione Automatica degli episodi
    title = item.fulltitle

    dict_series = jsontools.get_node_from_file(item.channel,
                                               TAG_TVSHOW_RENUMERATE)
    try:
        ID = dict_series[item.show.rstrip()][TAG_ID]
    except:
        ID = ''

    # Pulizia del Titolo
    if any(word in title.lower() for word in ['specials', 'speciali']):
        item.show = re.sub(r'\sspecials|\sspeciali', '', item.show.lower())
        log('ITEM SHOW= ', item.show)
        tvdb.find_and_set_infoLabels(item)
    elif not item.infoLabels['tvdb_id']:
        item.show = title.rstrip('123456789 ')
        tvdb.find_and_set_infoLabels(item)

    if not ID and active:
        if item.infoLabels['tvdb_id']:
            ID = item.infoLabels['tvdb_id']
            dict_renumerate = {TAG_ID: ID}
            dict_series[title] = dict_renumerate
            # Trova La Stagione
            if any(word in title.lower() for word in ['specials', 'speciali']):
                dict_renumerate[TAG_SEASON] = '0'
            elif RepresentsInt(title.split()[-1]):
                dict_renumerate[TAG_SEASON] = title.split()[-1]
            else:
                dict_renumerate[TAG_SEASON] = '1'
            dict_renumerate[TAG_EPISODE] = ''
            settings_node = jsontools.get_node_from_file(
                item.channel, 'settings')
            dict_renumerate[TAG_MODE] = settings_node['autorenumber_mode']
            jsontools.update_node(dict_series, item.channel,
                                  TAG_TVSHOW_RENUMERATE)[0]
            return renumber(itemlist, item, typography)
        else:
            return itemlist

    else:
        return renumber(itemlist, item, typography)
Esempio n. 23
0
def renumber(itemlist, item='', typography=''):
    log()

    if item:
        try:
            dict_series = jsontools.get_node_from_file(item.channel,
                                                       TAG_TVSHOW_RENUMERATE)
            SERIES = dict_series[item.show.rstrip()]['season_episode']
            S = SERIES[0]
            E = SERIES[1]
            SP = SERIES[2]
            ID = SERIES[3]

            page = 1
            epList = []
            exist = True
            item.infoLabels['tvdb_id'] = ID
            tvdb.set_infoLabels_item(item)

            while exist:
                data = tvdb.otvdb_global.get_list_episodes(ID, page)
                if data:
                    for episodes in data['data']:
                        if episodes['airedSeason'] >= S:
                            if E == 0:
                                epList.append([0, SP])
                                E = 1
                            if episodes['airedEpisodeNumber'] >= E:
                                epList.append([
                                    episodes['airedSeason'],
                                    episodes['airedEpisodeNumber']
                                ])
                    page = page + 1
                else:
                    exist = False

            epList.sort()
            ep = 0

            for item in itemlist:
                s = str(epList[ep][0])
                e = str(epList[ep][1])
                item.title = typo(s + 'x' + e + ' - ', typography) + item.title
                ep = ep + 1

        except:
            return itemlist
    else:
        for item in itemlist:
            if item.contentType != 'movie':
                if item.context:
                    context2 = item.context
                    item.context = context() + context2
                else:
                    item.context = context()

    return itemlist
Esempio n. 24
0
def mainlist(channel, list_language, list_quality):
    """
    Muestra una lista de las series filtradas

    @param channel: nombre del canal para obtener las series filtradas
    @type channel: str
    @param list_language: lista de idiomas del canal
    @type list_language: list[str]
    @param list_quality: lista de calidades del canal
    @type list_quality: list[str]
    @return: lista de Item
    @rtype: list[Item]
    """
    logger.info()
    itemlist = []
    dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_FILTER)

    idx = 0
    for tvshow in sorted(dict_series):

        if idx % 2 == 0:
            if dict_series[tvshow][TAG_ACTIVE]:
                tag_color = COLOR.get("striped_even_active", "auto")
            else:
                tag_color = COLOR.get("striped_even_inactive", "auto")
        else:
            if dict_series[tvshow][TAG_ACTIVE]:
                tag_color = COLOR.get("striped_odd_active", "auto")
            else:
                tag_color = COLOR.get("striped_odd_inactive", "auto")

        idx += 1
        name = dict_series.get(tvshow, {}).get(TAG_NAME, tvshow)
        activo = " (desactivado)"
        if dict_series[tvshow][TAG_ACTIVE]:
            activo = ""
        title = "Configurar [COLOR %s][%s][/COLOR]%s" % (tag_color, name,
                                                         activo)

        itemlist.append(
            Item(channel=__channel__,
                 action="config_item",
                 title=title,
                 show=name,
                 list_language=list_language,
                 list_quality=list_quality,
                 from_channel=channel))

    if len(itemlist) == 0:
        itemlist.append(
            Item(channel=channel,
                 action="mainlist",
                 title="No existen filtros, busca una serie y "
                 "pulsa en menú contextual 'FILTRO: Configurar'"))

    return itemlist
Esempio n. 25
0
def check(item):
    try:
        dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
        TITLE = item.fulltitle.rstrip()
        dict_series[TITLE][TAG_ID]
        dict_series[TITLE][TAG_EPISODE]
        exist = True
    except:
        exist = False
    return exist
Esempio n. 26
0
def get_sync_from_file():
    logger.info()
    sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt')
    trakt_node = {}
    if os.path.exists(sync_path):
        trakt_node = jsontools.get_node_from_file('trakt', "TRAKT")

    trakt_node['movies'] = get_trakt_watched('tmdb', 'movies')
    trakt_node['shows'] = get_trakt_watched('tmdb', 'shows')
    jsontools.update_node(trakt_node, 'trakt', 'TRAKT')
Esempio n. 27
0
def numbered_for_tratk(channel, show, season, episode):
    """
    Devuelve la temporada y episodio convertido para que se marque correctamente en tratk.tv

    @param channel: Nombre del canal
    @type channel: str
    @param show: Nombre de la serie a comprobar
    @type show: str
    @param season: Temporada que devuelve el scrapper
    @type season: int
    @param episode: Episodio que devuelve el scrapper
    @type episode: int
    @return: season, episode
    @rtype: int, int
    """
    logger.info()

    if access():
        show = show.lower()

        new_season = season
        new_episode = episode
        dict_series = jsontools.get_node_from_file(channel,
                                                   TAG_TVSHOW_RENUMERATE)

        # ponemos en minusculas el key, ya que previamente hemos hecho lo mismo con show.
        for key in list(dict_series.keys()):
            new_key = key.lower()
            if new_key != key:
                dict_series[new_key] = dict_series[key]
                del dict_series[key]

        if show in dict_series:
            logger.debug(
                config.get_localized_string(70589) + " %s" % dict_series[show])

            if len(dict_series[show]['season_episode']) > 1:
                for row in dict_series[show]['season_episode']:

                    if new_episode > row[1]:
                        new_episode -= row[1]
                        new_season = row[0]
                        break

            else:
                new_season = dict_series[show]['season_episode'][0][0]
                new_episode += dict_series[show]['season_episode'][0][1]

        logger.debug("%s:%s" % (new_season, new_episode))
    else:
        # no se tiene acceso se devuelven los datos.
        new_season = season
        new_episode = episode

    return new_season, new_episode
Esempio n. 28
0
def mainlist(channel, list_language, list_quality):
    """
    Shows a list of the leaked series

    @param channel: channel name to get filtered series
    @type channel: str
    @param list_language: channel language list
    @type list_language: list[str]
    @param list_quality: channel quality list
    @type list_quality: list[str]
    @return: Item list
    @rtype: list[Item]
    """
    logger.debug()
    itemlist = []
    dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_FILTER)

    idx = 0
    for tvshow in sorted(dict_series):

        if idx % 2 == 0:
            if dict_series[tvshow][TAG_ACTIVE]:
                tag_color = COLOR.get("striped_even_active", "auto")
            else:
                tag_color = COLOR.get("striped_even_inactive", "auto")
        else:
            if dict_series[tvshow][TAG_ACTIVE]:
                tag_color = COLOR.get("striped_odd_active", "auto")
            else:
                tag_color = COLOR.get("striped_odd_inactive", "auto")

        idx += 1
        name = dict_series.get(tvshow, {}).get(TAG_NAME, tvshow)
        activo = config.get_localized_string(60433)
        if dict_series[tvshow][TAG_ACTIVE]:
            activo = ""
        title = config.get_localized_string(60434) % (tag_color, name, activo)

        itemlist.append(
            Item(channel=__channel__,
                 action="config_item",
                 title=title,
                 show=name,
                 list_language=list_language,
                 list_quality=list_quality,
                 from_channel=channel))

    if len(itemlist) == 0:
        itemlist.append(
            Item(channel=channel,
                 action="mainlist",
                 title=config.get_localized_string(60435)))

    return itemlist
Esempio n. 29
0
def save(item, dict_data_saved):
    """
    Guarda los valores configurados en la ventana

    @param item: item
    @type item: Item
    @param dict_data_saved: diccionario con los datos salvados
    @type dict_data_saved: dict
    """
    logger.info()

    if item and dict_data_saved:
        logger.debug('item: %s\ndatos: %s' %
                     (item.tostring(), dict_data_saved))

        if item.from_channel == "videolibrary":
            item.from_channel = item.contentChannel
        dict_series = jsontools.get_node_from_file(item.from_channel,
                                                   TAG_TVSHOW_FILTER)
        tvshow = item.show.strip().lower()

        logger.info("Se actualiza los datos")

        list_quality = []
        for _id, value in dict_data_saved.items():
            if _id in item.list_quality and value:
                list_quality.append(_id.lower())

        lang_selected = item.list_language[dict_data_saved[TAG_LANGUAGE]]
        dict_filter = {
            TAG_NAME: item.show,
            TAG_ACTIVE: dict_data_saved.get(TAG_ACTIVE, True),
            TAG_LANGUAGE: lang_selected,
            TAG_QUALITY_ALLOWED: list_quality
        }
        dict_series[tvshow] = dict_filter

        result, json_data = jsontools.update_node(dict_series,
                                                  item.from_channel,
                                                  TAG_TVSHOW_FILTER)

        sound = False
        if result:
            message = "FILTRO GUARDADO"
        else:
            message = "Error al guardar en disco"
            sound = True

        heading = "%s [%s]" % (item.show.strip(), lang_selected)
        platformtools.dialog_notification(heading, message, sound=sound)

        if item.from_action in ["findvideos", "play"]:
            platformtools.itemlist_refresh()
Esempio n. 30
0
def load_results(item):

    cache_node = jsontools.get_node_from_file('menu_cache_data.json', 'cached')
    itemlist = list()

    for cached_item in cache_node[item.news]:
        new_item = Item()
        new_item = new_item.fromurl(cached_item)
        itemlist.append(new_item)
    itemlist = group_results(itemlist)

    return itemlist