From d723f0552b08ae4c569b213ac691051f8a4f5a8f Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Mon, 26 Sep 2022 19:44:46 +0200 Subject: [PATCH] Fix SC e AU --- channels/animeunity.py | 10 ++++++---- channels/streamingcommunity.py | 5 +++-- core/support.py | 5 +++-- platformcode/platformtools.py | 4 +++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/channels/animeunity.py b/channels/animeunity.py index 424463eb..0ab27981 100644 --- a/channels/animeunity.py +++ b/channels/animeunity.py @@ -222,16 +222,18 @@ def findvideos(item): from time import time from base64 import b64encode from hashlib import md5 + # support.dbg() # Calculate Token - client_ip = support.httptools.downloadpage('https://scws.work/videos/{}'.format(item.scws_id)).json.get('client_ip') + # client_ip = support.httptools.downloadpage('https://scws.work/videos/{}'.format(item.scws_id)).json.get('client_ip') + client_ip = support.httptools.downloadpage('http://ip-api.com/json/').json.get('query') logger.debug(client_ip) expires = int(time() + 172800) token = b64encode(md5('{}{} Yc8U6r8KjAKAepEA'.format(expires, client_ip).encode('utf-8')).digest()).decode('utf-8').replace('=', '').replace('+', '-').replace('/', '_') url = 'https://scws.work/master/{}?token={}&expires={}&n=1'.format(item.scws_id, token, expires) - itemlist = [item.clone(title=support.config.get_localized_string(30137), url=url, server='directo', action='play', manifest='hls')] + itemlist = [item.clone(title=support.config.get_localized_string(30137), url=url, server='directo', action='play', manifest='hls',referer=False)] else: - itemlist = [item.clone(title=support.config.get_localized_string(30137), url=item.video_url, server='directo', action='play')] - return support.server(item, itemlist=itemlist) + itemlist = [item.clone(title=support.config.get_localized_string(30137), url=item.video_url, server='directo', action='play',referer=False)] + return support.server(item, itemlist=itemlist, referer=False) diff --git a/channels/streamingcommunity.py b/channels/streamingcommunity.py index cc47ab26..0abf1529 100644 --- a/channels/streamingcommunity.py +++ b/channels/streamingcommunity.py @@ -252,7 +252,8 @@ def play(item): return [] # Calculate Token - client_ip = support.httptools.downloadpage('https://scws.work/videos/{}'.format(scws_id)).json.get('client_ip') + # client_ip = support.httptools.downloadpage('https://scws.work/videos/{}'.format(scws_id)).json.get('client_ip') + client_ip = support.httptools.downloadpage('http://ip-api.com/json/').json.get('query') expires = int(time() + 172800) token = b64encode(md5('{}{} Yc8U6r8KjAKAepEA'.format(expires, client_ip).encode('utf-8')).digest()).decode('utf-8').replace('=', '').replace('+', '-').replace('/', '_') @@ -261,7 +262,7 @@ def play(item): subs = [] urls = [] - info = support.match(url, patron=r'LANGUAGE="([^"]+)",\s*URI="([^"]+)|RESOLUTION=\d+x(\d+).*?(http[^"\s]+)').matches + info = support.match(url, patron=r'LANGUAGE="([^"]+)",\s*URI="([^"]+)|RESOLUTION=\d+x(\d+).*?(http[^"\s]+)', headers=headers).matches if info: for lang, sub, res, url in info: if sub and not logger.testMode: # ai test non piace questa parte diff --git a/core/support.py b/core/support.py index 0ab9b60a..e4766614 100755 --- a/core/support.py +++ b/core/support.py @@ -1260,7 +1260,7 @@ def pagination(itemlist, item, page, perpage, function_level=1): return itemlist -def server(item, data='', itemlist=[], headers='', CheckLinks=True, Download=True, patronTag=None, Videolibrary=True, Sorted=True): +def server(item, data='', itemlist=[], headers='', CheckLinks=True, Download=True, patronTag=None, Videolibrary=True, Sorted=True, referer=True): logger.debug() if not data and not itemlist: @@ -1310,7 +1310,8 @@ def server(item, data='', itemlist=[], headers='', CheckLinks=True, Download=Tru if videoitem.title: vi.serverName = videoitem.title if videoitem.quality: vi.quality = videoitem.quality - if not vi.referer: vi.referer = item.url + if referer == False: vi.referer = False + elif referer and not vi.referer: vi.referer = item.url vi.contentFanart = item.infoLabels['fanart'] vi.contentThumb = item.infoLabels['fanart'] if videoitem.forcethumb: diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index ab16f242..8cf1e9e8 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -1105,7 +1105,9 @@ def play_video(item, strm=False, force_direct=False, autoplay=False): # headers['Host'] = domain # except: # logger.error('Failed to resolve hostname, fallback to normal dns') - if '|' not in mediaurl: + from core import support + support.dbg() + if '|' not in mediaurl and item.referer != False: mediaurl = mediaurl + '|' + urllib.urlencode(headers) # video information is obtained.