Ejemplo n.º 1
0
def run(item):
    logger.info()
    with futures.ThreadPoolExecutor() as executor:
        future = executor.submit(next_ep, item)
        item = future.result()
    if item.next_ep:
        return play_from_library(item)
Ejemplo n.º 2
0
def peliculas(item):
    itemlist = []
    if not item.args:
        json_file = current_session.get(item.url + 'channels', headers=headers, params=payload).json()
        names = [i['filter'] for i in json_file['data'] if 'filter' in i][0]
        with futures.ThreadPoolExecutor() as executor:
            json_file = [executor.submit(dl_pages, name, item,) for name in names]
            for res in futures.as_completed(json_file):
                if res.result():
                    itemlist += res.result()
        itemlist = sorted(itemlist, key=lambda it: it.fulltitle)

    elif ('=' not in item.args) and ('=' not in item.url):
        json_file = current_session.get(item.url + item.args, headers=headers, params=payload).json()
        make_itemlist(itemlist, item, json_file)

    elif '=' in item.args:
        json_file = current_session.get(item.url + 'channels', headers=headers, params=payload).json()
        Filter = support.match(item.args,r'\?([^=]+)=')[0][0]
        keys = [i[Filter] for i in json_file['data'] if Filter in i][0]
        for key in keys:
            if key not in ['1','2']:
                itemlist.append(
                    Item(channel = item.channel,
                        title = support.typo(key.upper() if Filter == 'filter' else key['name'], 'bold'),
                        url =  item.url + item.args + (key if Filter == 'filter' else str(key['id'])),
                        action = 'peliculas',
                        args = 'filters',
                        contentType = item.contentType))

    else :
        json_file = current_session.get(item.url, headers=headers, params=payload).json()
        make_itemlist(itemlist, item, json_file)
    if item.contentType != 'movie': autorenumber.renumber(itemlist)
    tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
    return itemlist
Ejemplo n.º 3
0
def return_item(item):
    logger.info()
    with futures.ThreadPoolExecutor() as executor:
        future = executor.submit(next_ep, item)
        item = future.result()
    return item
Ejemplo n.º 4
0
def channel_search(item):
    logger.info()

    start = time.time()
    searching = list()
    results = list()
    valid = list()
    ch_list = dict()
    to_temp = dict()
    mode = item.mode
    max_results = 10

    searched_id = item.infoLabels['tmdb_id']

    channel_list = get_channels(item)

    searching += channel_list
    cnt = 0

    progress = platformtools.dialog_progress(
        'Buscando %s ...' % item.title,
        "Restan %s canales" % len(channel_list), str(searching))
    config.set_setting('tmdb_active', False)

    with futures.ThreadPoolExecutor() as executor:
        c_results = [
            executor.submit(get_channel_results, ch, item)
            for ch in channel_list
        ]

        for res in futures.as_completed(c_results):
            cnt += 1
            finished = res.result()[0]
            if res.result()[1]:
                ch_list[res.result()[0]] = res.result()[1]

            if progress.iscanceled():
                break
            if finished in searching:
                searching.remove(finished)
                progress.update(
                    (cnt * 100) / len(channel_list),
                    "Restan %s canales" % str(len(channel_list) - cnt),
                    str(searching))

    progress.close()

    cnt = 0
    progress = platformtools.dialog_progress('Buscando %s ...' % item.title,
                                             "Preparando Resultados",
                                             'Por favor espere...')

    config.set_setting('tmdb_active', True)

    for key, value in ch_list.items():
        grouped = list()
        cnt += 1
        progress.update((cnt * 100) / len(ch_list), "Preparando Resultados",
                        'Por favor espere...')
        if len(value) <= max_results and item.mode != 'all':
            if len(value) == 1:
                if not value[0].action or 'siguiente' in value[0].title.lower(
                ):
                    continue
            tmdb.set_infoLabels_itemlist(value, True, forced=True)
            for elem in value:
                if not elem.infoLabels.get('year', ""):
                    elem.infoLabels['year'] = '-'
                    tmdb.set_infoLabels_item(elem, True)

                if elem.infoLabels['tmdb_id'] == searched_id:
                    elem.from_channel = key
                    if not config.get_setting('unify'):
                        elem.title += ' [%s]' % key
                    valid.append(elem)

        for it in value:
            if it.channel == item.channel:
                it.channel = key
            if it in valid:
                continue
            if mode == 'all' or (it.contentType and mode == it.contentType):
                grouped.append(it)
            elif (mode == 'movie'
                  and it.contentTitle) or (mode == 'tvshow' and
                                           (it.contentSerieName or it.show)):
                grouped.append(it)
            else:
                continue

        if not grouped:
            continue
        to_temp[key] = grouped

        if not config.get_setting('unify'):
            title = '[COLOR yellow](%s) RESULTADOS EN[/COLOR] [%s]' % (
                len(grouped), key)
        else:
            title = '[COLOR yellow](%s) RESULTADOS EN[/COLOR]' % (len(grouped))

        ch_thumb = channeltools.get_channel_parameters(key)['thumbnail']
        results.append(
            Item(channel='search',
                 title=title,
                 action='get_from_temp',
                 thumbnail=ch_thumb,
                 from_channel=key,
                 page=1))

    results = sorted(results, key=lambda it: it.from_channel)

    send_to_temp(to_temp)
    config.set_setting('tmdb_active', True)

    logger.debug('Finalizada en %s segs (%s canales)' %
                 (str(time.time() - start), str(len(channel_list))))

    return valid + results
Ejemplo n.º 5
0
def channel_search(item):
    logger.info(item)

    start = time.time()
    searching = list()
    searching_titles = list()
    results = list()
    valid = list()
    ch_list = dict()
    mode = item.mode
    max_results = 10
    if item.infoLabels['title']:
        item.text = item.infoLabels['title']

    searched_id = item.infoLabels['tmdb_id']

    channel_list, channel_titles = get_channels(item)

    searching += channel_list
    searching_titles += channel_titles
    cnt = 0

    progress = platformtools.dialog_progress(
        config.get_localized_string(30993) % item.title,
        config.get_localized_string(70744) % len(channel_list),
        str(searching_titles))
    config.set_setting('tmdb_active', False)

    with futures.ThreadPoolExecutor(max_workers=set_workers()) as executor:
        c_results = [
            executor.submit(get_channel_results, ch, item)
            for ch in channel_list
        ]

        for res in futures.as_completed(c_results):
            cnt += 1
            finished = res.result()[0]
            if res.result()[1]:
                ch_list[res.result()[0]] = res.result()[1]

            if progress.iscanceled():
                break
            if finished in searching:
                searching_titles.remove(
                    searching_titles[searching.index(finished)])
                searching.remove(finished)
                progress.update(
                    old_div((cnt * 100), len(channel_list)),
                    config.get_localized_string(70744) %
                    str(len(channel_list) - cnt) + '\n' +
                    str(searching_titles) + '\n' + ' ' + '\n' + ' ' + '\n' +
                    ' ')

    progress.close()

    cnt = 0
    progress = platformtools.dialog_progress(
        config.get_localized_string(30993) % item.title,
        config.get_localized_string(60295), config.get_localized_string(60293))

    config.set_setting('tmdb_active', True)
    res_count = 0
    for key, value in list(ch_list.items()):
        ch_name = channel_titles[channel_list.index(key)]
        grouped = list()
        cnt += 1
        progress.update(old_div((cnt * 100), len(ch_list)), config.get_localized_string(60295) \
                        + '\n' + config.get_localized_string(60293))
        if len(value) <= max_results and item.mode != 'all':
            if len(value) == 1:
                if not value[0].action or config.get_localized_string(
                        70006).lower() in value[0].title.lower():
                    continue
            tmdb.set_infoLabels_itemlist(value, True, forced=True)
            for elem in value:
                if not elem.infoLabels.get('year', ""):
                    elem.infoLabels['year'] = '-'
                    tmdb.set_infoLabels_item(elem, True)

                if elem.infoLabels['tmdb_id'] == searched_id:
                    elem.from_channel = key

                    if not config.get_setting('unify'):
                        elem.title = '[%s] %s' % (key.capitalize(), elem.title)
                    valid.append(elem)

        for it in value:
            if it.channel == item.channel:
                it.channel = key
            if it in valid:
                continue
            if mode == 'all' or (it.contentType and mode == it.contentType):
                if not it.infoLabels or not item.text.lower(
                ) in it.title.lower():
                    continue
                if config.get_setting('result_mode', 'search') != 0:
                    if config.get_localized_string(30992) not in it.title:
                        it.title += " " + ch_name
                        results.append(it)
                else:
                    grouped.append(it)
            elif (mode == 'movie'
                  and it.contentTitle) or (mode == 'tvshow' and
                                           (it.contentSerieName or it.show)):
                grouped.append(it)
            else:
                continue

        if not grouped:
            continue
        # to_temp[key] = grouped
        if config.get_setting('result_mode', 'search') == 0:
            if not config.get_setting('unify'):
                title = ch_name + ' [COLOR yellow](' + str(
                    len(grouped)) + ')[/COLOR]'
            else:
                title = '[COLOR yellow](%s)[/COLOR]' % (len(grouped))
            res_count += len(grouped)
            plot = ''

            for it in grouped:
                plot += it.title + '\n'
            ch_thumb = channeltools.get_channel_parameters(key)['thumbnail']
            results.append(
                Item(channel='search',
                     title=title,
                     action='get_from_temp',
                     thumbnail=ch_thumb,
                     itemlist=[ris.tourl() for ris in grouped],
                     plot=plot,
                     page=1,
                     from_channel=key))

    # send_to_temp(to_temp)
    config.set_setting('tmdb_active', True)
    if item.mode == 'all':
        if config.get_setting('result_mode', 'search') != 0:
            res_count = len(results)
        results = sorted(results, key=lambda it: it.title)
        results_statistic = config.get_localized_string(59972) % (
            item.title, res_count, time.time() - start)
        results.insert(0, Item(title=results_statistic))
    # logger.debug(results_statistic)
    return valid + results
Ejemplo n.º 6
0
 def __init__(self, max_workers=10):
     pool = futures.ThreadPoolExecutor(int(max_workers))
     super(ThreadPoolExecutor, self).__init__(pool)