From 1e1327da904841196d29f6e50362b1d025d821dc Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sun, 24 Jan 2021 17:08:06 +0100 Subject: [PATCH] Fix Streaming Community --- channels/streamingcommunity.py | 48 +++++++++++++--------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/channels/streamingcommunity.py b/channels/streamingcommunity.py index 2891b180..8476fd56 100644 --- a/channels/streamingcommunity.py +++ b/channels/streamingcommunity.py @@ -4,7 +4,7 @@ # ------------------------------------------------------------ import json, requests, sys -from core import support, channeltools +from core import support from platformcode import logger if sys.version_info[0] >= 3: from concurrent import futures @@ -19,7 +19,7 @@ def getHeaders(): global headers if not headers: headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'} - response = session.get(host) + response = session.get(host, headers=headers) csrf_token = support.match(response.text, patron='name="csrf-token" content="([^"]+)"').match headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', 'content-type': 'application/json;charset=UTF-8', @@ -100,12 +100,14 @@ def peliculas(item): getHeaders() logger.debug() itemlist = [] + recordlist = [] videoType = 'movie' if item.contentType == 'movie' else 'tv' page = item.page if item.page else 0 offset = page * 60 - - if type(item.args) == int: + if item.records: + records = item.records + elif type(item.args) == int: data = support.scrapertools.decodeHtmlentities(support.match(item).data) records = json.loads(support.match(data, patron=r'slider-title titles-json="(.*?)" slider-name="').matches[item.args]) elif not item.search: @@ -122,15 +124,17 @@ def peliculas(item): else: js = records - with futures.ThreadPoolExecutor() as executor: - itlist = [executor.submit(makeItem, i, it, item) for i, it in enumerate(js)] - for res in futures.as_completed(itlist): - itemlist.append(res.result()) - + for i, it in enumerate(js): + if i < 20: + itemlist.append(makeItem(i, it, item)) + else: + recordlist.append(it) + itemlist.sort(key=lambda item: item.n) - - 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)) + if recordlist: + itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), page=page, records=recordlist)) + elif len(itemlist) >= 20: + itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), records=[], page=page + 1)) support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) return itemlist @@ -190,21 +194,5 @@ def episodios(item): def findvideos(item): - video_urls = [] - headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', - 'content-type': 'application/json;charset=UTF-8', - 'Referer': 'https://streamingcommunity.net'} - data = support.match(item, headers=headers).data.replace('"','"').replace('\\','') - url = support.match(data, patron=r'video_url"\s*:\s*"([^"]+)"').match - def videourls(res): - newurl = '{}/{}'.format(url, res) - if requests.head(newurl, headers=headers).status_code == 200: - video_urls.append(["m3u8 {} [StreamingCommunity]".format(res), newurl]) - - with futures.ThreadPoolExecutor() as executor: - for res in ['480p', '720p', '1080p']: - executor.submit(videourls, res) - if not video_urls: video_urls = [["m3u8 [StreamingCommunity]", url]] - else: video_urls.sort(key=lambda url: int(support.match(url[0], patron=r'(\d+)p').match)) - itemlist = [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='directo', video_urls=video_urls, thumbnail=channeltools.get_channel_parameters(item.channel)["thumbnail"], forcethumb=True)] - return support.server(item, itemlist=itemlist) \ No newline at end of file + itemlist = [item.clone(title = 'StreamingCommunity', server='streamingcommunity_server')] + return support.server(item, item.url) \ No newline at end of file