From 0109888967e89817c03ce640193c13ce0422a22d Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sat, 18 Jul 2020 11:26:27 +0200 Subject: [PATCH] canali live in thread --- specials/filmontv.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/specials/filmontv.py b/specials/filmontv.py index ba309844..cf5f8a34 100644 --- a/specials/filmontv.py +++ b/specials/filmontv.py @@ -3,10 +3,13 @@ # Canale film in tv # ------------------------------------------------------------ from datetime import datetime -import glob, time, gzip, xbmc +import glob, time, gzip, xbmc, sys from core import filetools, downloadtools, support, scrapertools from core.item import Item +if sys.version_info[0] >= 3: from concurrent import futures +else: from concurrent_py2 import futures + host = "http://epg-guide.com/kltv.gz" blacklisted_genres = ['attualita', 'scienza', 'religione', 'cucina', 'notiziario', 'altro', 'soap opera', 'viaggi', 'economia', 'tecnologia', 'magazine', 'show', 'reality show', 'lifestyle', 'societa', 'wrestling', 'azione', 'Musica', 'real life', 'real adventure', 'dplay original', 'natura', 'news', 'food', 'sport', 'moda', 'arte e cultura', 'crime', 'box set e serie tv', 'casa', 'storia', 'talk show', 'motori', 'attualit\xc3\xa0 e inchiesta', 'documentari', 'musica', 'spettacolo', 'medical', 'talent show', 'sex and love', 'beauty and style', 'news/current affairs', "children's/youth programmes", 'leisure hobbies', 'social/political issues/economics', 'education/science/factual topics', 'undefined content', 'show/game show', 'music/ballet/dance', 'sports', 'arts/culture', 'biografico', 'informazione', 'documentario'] @@ -308,8 +311,22 @@ def new_search(item): def live(item): itemlist = [] - from channels import raiplay, mediasetplay, la7 - itemlist += raiplay.live(raiplay.mainlist(Item())[0]) - itemlist += mediasetplay.live(mediasetplay.mainlist(Item())[0]) - itemlist += la7.live(la7.mainlist(Item())[0]) + channels_dict = {} + channels = ['raiplay', 'mediasetplay', 'la7'] + + with futures.ThreadPoolExecutor() as executor: + itlist = [executor.submit(load_live, channel) for channel in channels] + for res in futures.as_completed(itlist): + if res.result(): + channel_name, itlist = res.result() + channels_dict[channel_name] = itlist + + for channel in channels: + itemlist += channels_dict[channel] return itemlist + + +def load_live(channel_name): + channel = __import__('%s.%s' % ('channels', channel_name), None, None, ['%s.%s' % ('channels', channel_name)]) + itemlist = channel.live(channel.mainlist(Item())[0]) + return channel_name, itemlist \ No newline at end of file