Streamingcommunity nuovo player

This commit is contained in:
marco
2023-06-17 11:44:03 +02:00
parent 14488c4c54
commit 769306faa3
2 changed files with 29 additions and 36 deletions

View File

@@ -1,56 +1,51 @@
# -*- coding: utf-8 -*-
import urllib.parse
from core import httptools, support, filetools
from platformcode import logger, config
UA = httptools.random_useragent()
import ast
UA = httptools.get_user_agent()
def test_video_exists(page_url):
global scws_id
logger.debug('page url=', page_url)
scws_id = ''
if page_url.isdigit():
scws_id = page_url
else:
page = httptools.downloadpage(page_url)
if page.url == page_url: # se non esiste, reindirizza all'ultimo url chiamato esistente
scws_id = support.scrapertools.find_single_match(page.data, r'scws_id[^:]+:(\d+)')
else:
return 'StreamingCommunity', 'Prossimamente'
if not scws_id:
return False, config.get_localized_string(70449) % 'StreamingCommunityWS'
# logger.debug('page url=', page_url)
# scws_id = ''
#
# if page_url.isdigit():
# scws_id = page_url
# else:
# page = httptools.downloadpage(page_url)
# if page.url == page_url: # se non esiste, reindirizza all'ultimo url chiamato esistente
# scws_id = support.scrapertools.find_single_match(page.data, r'scws_id[^:]+:(\d+)')
# else:
# return 'StreamingCommunity', 'Prossimamente'
#
# 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
global scws_id
from urllib.parse import urlparse
video_urls = list()
iframe = support.scrapertools.decodeHtmlentities(support.match(page_url, patron='<iframe [^>]+src="([^"]+)').match)
scws_id = urlparse(iframe).path.split('/')[-1]
masterPlaylistParams = ast.literal_eval(support.match(iframe, patron='window\.masterPlaylistParams\s=\s({.*?})').match)
# 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)
if page_url.isdigit():
video_urls.append(['m3u8', '{}|User-Agent={}'.format(url, UA)])
else:
video_urls = compose(url)
url = 'https://scws.work/v2/playlist/{}?{}&n=1'.format(scws_id, urllib.parse.urlencode(masterPlaylistParams))
video_urls.append(['m3u8', '{}|User-Agent={}'.format(url, UA)])
return video_urls
def compose(url):
subs = []
video_urls = []
info = support.match(url, patron=r'LANGUAGE="([^"]+)",\s*URI="([^"]+)|RESOLUTION=\d+x(\d+).*?(http[^"\s]+)', headers={'User-Agent':UA}).matches
if info and not logger.testMode: # ai test non piace questa parte
for lang, sub, res, url in info:
if sub:
if sub:
while True:
match = support.match(sub, patron=r'(http[^\s\n]+)').match
if match: