From c38097efdef698246b0221eb5928ad6fc89bafef Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sat, 1 Oct 2022 15:57:16 +0200 Subject: [PATCH] Fix SC e AU --- channels/animeunity.py | 3 ++- channels/streamingcommunity.py | 45 +++------------------------------ servers/streamingcommunityws.py | 10 +++++--- 3 files changed, 12 insertions(+), 46 deletions(-) diff --git a/channels/animeunity.py b/channels/animeunity.py index 0236890b..a5b75c97 100644 --- a/channels/animeunity.py +++ b/channels/animeunity.py @@ -219,6 +219,7 @@ def episodios(item): def findvideos(item): - itemlist = [item.clone(title=support.config.get_localized_string(30137), server='streamingcommunityws', url=str(item.scws_id))] + itemlist = [item.clone(title='StreamingCommunityWS', server='streamingcommunityws', url=str(item.scws_id)), + item.clone(title=support.config.get_localized_string(30137), server='directo', url=item.video_url)] return support.server(item, itemlist=itemlist, referer=False) diff --git a/channels/streamingcommunity.py b/channels/streamingcommunity.py index 6836c3eb..d3e8a9c1 100644 --- a/channels/streamingcommunity.py +++ b/channels/streamingcommunity.py @@ -221,7 +221,7 @@ def episodios(item): action='findvideos', contentType='episode', contentSerieName=item.fulltitle, - url=host + '/watch/' + str(episodes['title_id']) + '?e=' + str(it['id']))) + url= '{}/watch/{}?e={}'.format(host, episodes['title_id'], it['id']))) if config.get_setting('episode_info') and not support.stackCheck(['add_tvshow', 'get_newest']): support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) @@ -232,46 +232,9 @@ def episodios(item): def findvideos(item): + # Fix for old items in videolibrary + if item.episodeid and not item.episodeid in item.url: + item.url += item.episodeid itemlist = [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], url=item.url, server='streamingcommunityws')] return support.server(item, itemlist=itemlist, referer=False) -# def play(item): -# from time import time -# from base64 import b64encode -# from hashlib import md5 - -# data = support.httptools.downloadpage(item.url + item.episodeid, headers=headers).data.replace('"','"').replace('\\','') -# scws_id = support.match(data, patron=r'scws_id"\s*:\s*(\d+)').match -# # support.dbg() - -# if not scws_id: -# if 'Prossimamente' in data: -# platformtools.dialog_ok('StreamingCommunity', 'Il sito notifica che il contenuto sarĂ  disponibile prossimamente') -# platformtools.play_canceled = True -# return [] - -# # Calculate Token -# # 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('/', '_') - -# url = 'https://scws.work/master/{}?token={}&expires={}&n=1'.format(scws_id, token, expires) -# subs = [] -# urls = [] - -# 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 -# if lang == 'auto': lang = 'ita-forced' -# s = config.get_temp_file(lang +'.srt') -# subs.append(s) -# filetools.write(s, support.vttToSrt(httptools.downloadpage(support.match(sub, patron=r'(http[^\s\n]+)').match).data)) -# elif url: -# urls.append(['hls [{}]'.format(res), url]) - -# return [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='stt', video_urls=urls, subtitle=subs, manifest='hls', referer=False)] -# else: -# return [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='directo', url=url, manifest='hls', referer=False)] diff --git a/servers/streamingcommunityws.py b/servers/streamingcommunityws.py index 768e8e63..40258f7a 100755 --- a/servers/streamingcommunityws.py +++ b/servers/streamingcommunityws.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- +from wsgiref import headers from core import httptools, support, filetools from platformcode import logger, config +UA = httptools.random_useragent() def test_video_exists(page_url): @@ -30,9 +32,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if clientIp: expires = int(time() + 172800) token = b64encode(md5('{}{} Yc8U6r8KjAKAepEA'.format(expires, clientIp).encode('utf-8')).digest()).decode('utf-8').replace('=', '').replace('+', '-').replace('/', '_') - url = 'https://scws.work/master/{}?token={}&expires={}&n=1|User-Agent={}'.format(scws_id, token, expires, httptools.random_useragent()) + url = 'https://scws.work/master/{}?token={}&expires={}&n=1'.format(scws_id, token, expires) if page_url.isdigit(): - video_urls.append(['m3u8', url]) + video_urls.append(['m3u8', '{}|User-Agent={}'.format(url, UA)]) else: video_urls = compose(url) @@ -41,7 +43,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= def compose(url): subs = [] video_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={'User-Agent':UA}).matches if info: for lang, sub, res, url in info: if sub and not logger.testMode: # ai test non piace questa parte @@ -50,5 +52,5 @@ def compose(url): subs.append(s) filetools.write(s, support.vttToSrt(httptools.downloadpage(support.match(sub, patron=r'(http[^\s\n]+)').match).data)) elif url: - video_urls.append(['m3u8 [{}]'.format(res), url, 0, subs]) + video_urls.append(['m3u8 [{}]'.format(res), '{}|User-Agent={}'.format(url, UA), 0, subs]) return video_urls \ No newline at end of file