Fix StreamingCommunity e AnimeUnity

This commit is contained in:
Alhaziel01
2022-09-28 10:32:28 +02:00
parent e57e4410f7
commit a499bd7cf1
5 changed files with 69 additions and 73 deletions

View File

@@ -195,6 +195,7 @@ def episodios(item):
support.info()
itemlist = []
title = 'Parte ' if item.type.lower() == 'movie' else 'Episodio '
for it in item.episodes:
itemlist.append(
item.clone(title=support.typo(title + it['number'], 'bold'),
@@ -218,20 +219,6 @@ def episodios(item):
def findvideos(item):
if item.scws_id:
from time import time
from base64 import b64encode
from hashlib import md5
# Calculate Token
client_ip = support.httptools.downloadpage('https://scws.work/videos/{}'.format(item.scws_id)).json.get('client_ip')
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')]
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), server='streamingcommunityws', url=str(item.scws_id))]
return support.server(item, itemlist=itemlist, referer=False)

View File

@@ -221,8 +221,7 @@ def episodios(item):
action='findvideos',
contentType='episode',
contentSerieName=item.fulltitle,
url=host + '/watch/' + str(episodes['title_id']),
episodeid= '?e=' + str(it['id'])))
url=host + '/watch/' + str(episodes['title_id']) + '?e=' + str(it['id'])))
if config.get_setting('episode_info') and not support.stackCheck(['add_tvshow', 'get_newest']):
support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
@@ -233,45 +232,46 @@ def episodios(item):
def findvideos(item):
itemlist = [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='directo')]
return support.server(item, itemlist=itemlist)
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
# 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()
# 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 '<strong>Prossimamente' in data:
platformtools.dialog_ok('StreamingCommunity', 'Il sito notifica che il contenuto sarà disponibile prossimamente')
platformtools.play_canceled = True
return []
# if not scws_id:
# if '<strong>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')
# # 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('/', '_')
# 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 = []
# 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]+)').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])
# 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='directo', video_urls=urls, subtitle=subs, manifest='hls')]
else:
return [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='directo', url=url, manifest='hls')]
# 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)]

View File

@@ -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:

View File

@@ -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.

View File

@@ -1,30 +1,36 @@
# -*- coding: utf-8 -*-
import sys
PY3 = False
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
from core import httptools, support
from platformcode import logger, config
import json
import random
from core import httptools, support, scrapertools
from platformcode import platformtools, logger
from lib.streamingcommunity import Client as SCClient
files = None
def test_video_exists(page_url):
global scws_id
logger.debug('page url=', page_url)
# page_url is the {VIDEO_ID}. Es: 5957
if page_url.isdigit():
scws_id = page_url
else:
scws_id = support.match(page_url, patron=r'scws_id[^:]+:(\d+)').match
if not scws_id:
return False, config.get_localized_string(70449) % 'StreamingCommunityWS'
return True, ""
def get_video_url(page_url, premium=False, user="", password="", video_password=""):
from time import time
from base64 import b64encode
from hashlib import md5
video_urls = []
global scws_id
video_urls = list()
global c
c = SCClient("",video_id=page_url, is_playing_fnc=platformtools.is_playing)
media_url = c.get_manifest_url()
video_urls.append([scrapertools.get_filename_from_url(media_url)[-4:] + " [Streaming Community]", media_url])
# clientIp = httptools.downloadpage(f'https://scws.work/videos/{scws_id}').json.get('client_ip')
clientIp = httptools.downloadpage('http://ip-api.com/json/').json.get('query')
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'.format(scws_id, token, expires)
video_urls.append(['hls', url])
return video_urls