From 7f8c9f8db499f01f04de9660eb448d314bb958f5 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Wed, 13 Jan 2021 18:40:46 +0100 Subject: [PATCH] Fix StreamingCommunity --- channels/streamingcommunity.json | 2 +- channels/streamingcommunity.py | 71 ++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/channels/streamingcommunity.json b/channels/streamingcommunity.json index 26139adb..c26b106e 100644 --- a/channels/streamingcommunity.json +++ b/channels/streamingcommunity.json @@ -1,6 +1,6 @@ { "id": "streamingcommunity", - "name": "Streaming Community", + "name": "StreamingCommunity", "active": true, "language": ["ita"], "thumbnail": "streamingcommunity.png", diff --git a/channels/streamingcommunity.py b/channels/streamingcommunity.py index dc1cfee4..9fdd5d68 100644 --- a/channels/streamingcommunity.py +++ b/channels/streamingcommunity.py @@ -3,9 +3,13 @@ # Canale per StreamingCommunity # ------------------------------------------------------------ -import json, requests +import json, requests, sys from core import support from platformcode import logger +if sys.version_info[0] >= 3: + from concurrent import futures +else: + from concurrent_py2 import futures host = support.config.get_channel_url() session = requests.Session() @@ -117,42 +121,49 @@ def peliculas(item): js += record else: js = records + # support.dbg() + with futures.ThreadPoolExecutor() as executor: + for i, it in enumerate(js): + itm = executor.submit(makeItem, i, it, item).result() + itemlist.append(itm) + # for i, it in enumerate(js): + # itm = makeItem(i, it, item) + # itemlist.append(itm) - for it in js: - title, lang = support.match(it['name'], patron=r'([^\[|$]+)(?:\[([^\]]+)\])?').match - if not lang: - lang = 'ITA' - itm = item.clone(title=support.typo(title,'bold') + support.typo(lang,'_ [] color kod bold')) - itm.type = it['type'] - itm.thumbnail = 'https://image.tmdb.org/t/p/w500' + it['images'][0]['url'] - itm.fanart = 'https://image.tmdb.org/t/p/w1280' + it['images'][2]['url'] - itm.plot = it['plot'] - itm.infoLabels['tmdb_id'] = it['tmdb_id'] - itm.language = lang - - - if itm.type == 'movie': - itm.contentType = 'movie' - itm.fulltitle = itm.show = itm.contentTitle = title - itm.contentSerieName = '' - itm.action = 'findvideos' - itm.url = host + '/watch/%s' % it['id'] - - else: - itm.contentType = 'tvshow' - itm.contentTitle = '' - itm.fulltitle = itm.show = itm.contentSerieName = title - itm.action = 'episodios' - itm.season_count = it['seasons_count'] - itm.url = host + '/titles/%s-%s' % (it['id'], it['slug']) - - itemlist.append(itm) + itemlist.sort(key=lambda item: item.n, reverse = True) if len(itemlist) >= 60: itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), page=page + 1)) support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) return itemlist +def makeItem(n, it, item): + info = session.post(host + '/api/titles/preview/{}'.format(it['id']), headers=headers).json() + title, lang = support.match(info['name'], patron=r'([^\[|$]+)(?:\[([^\]]+)\])?').match + if not lang: + lang = 'ITA' + itm = item.clone(title=support.typo(title,'bold') + support.typo(lang,'_ [] color kod bold')) + itm.type = info['type'] + itm.language = lang + + + if itm.type == 'movie': + itm.contentType = 'movie' + itm.fulltitle = itm.show = itm.contentTitle = title + itm.contentTitle = '' + itm.action = 'findvideos' + itm.url = host + '/watch/%s' % it['id'] + + else: + itm.contentType = 'tvshow' + itm.contentTitle = '' + itm.fulltitle = itm.show = itm.contentSerieName = title + itm.action = 'episodios' + itm.season_count = info['seasons_count'] + itm.url = host + '/titles/%s-%s' % (it['id'], it['slug']) + item.n = n + return itm + def episodios(item): getHeaders() support.info()