From f1e7263a07a5a62ee2301c9c2983a8b53aa8fb34 Mon Sep 17 00:00:00 2001 From: Pasquale Pizzuti Date: Fri, 5 Jan 2024 13:59:17 +0100 Subject: [PATCH] Update streamingcommunity.py old python compatibility (#450) --- channels/streamingcommunity.py | 14 ++++++++------ servers/streamingcommunityws.py | 12 +++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/channels/streamingcommunity.py b/channels/streamingcommunity.py index 7d8e8dd1..80dd60b5 100644 --- a/channels/streamingcommunity.py +++ b/channels/streamingcommunity.py @@ -4,15 +4,17 @@ # ------------------------------------------------------------ import json, re, sys -import urllib.parse +PY3 = False +if sys.version_info[0] >= 3: PY3 = True + +if PY3: import urllib.parse as urllib_parse +else: import urlparse as urllib_parse from core import support, channeltools, httptools, jsontools from platformcode import logger, config -if sys.version_info[0] >= 3: - from concurrent import futures -else: - from concurrent_py2 import futures +if PY3: from concurrent import futures +else: from concurrent_py2 import futures # def findhost(url): # return 'https://' + support.match(url, patron='var domain\s*=\s*"([^"]+)').match @@ -66,7 +68,7 @@ def genres(item): data_page = get_data(item.url) args = data_page['props']['genres'] for arg in args: - itemlist.append(item.clone(title=support.typo(arg['name'], 'bold'), url=host+'/browse/genre?g='+urllib.parse.quote(arg['name']), action='peliculas', genre=True)) + itemlist.append(item.clone(title=support.typo(arg['name'], 'bold'), url=host+'/browse/genre?g='+urllib_parse.quote(arg['name']), action='peliculas', genre=True)) support.thumb(itemlist, genre=True) return itemlist diff --git a/servers/streamingcommunityws.py b/servers/streamingcommunityws.py index ba4d44ff..26cf6435 100755 --- a/servers/streamingcommunityws.py +++ b/servers/streamingcommunityws.py @@ -1,11 +1,17 @@ # -*- coding: utf-8 -*- -import urllib.parse +import sys +PY3 = False +if sys.version_info[0] >= 3: PY3 = True + +if PY3: import urllib.parse as urllib +else: import urllib import ast import xbmc from core import httptools, support, filetools from platformcode import logger, config -from concurrent import futures +if PY3: from concurrent import futures +else: from concurrent_py2 import futures vttsupport = False if int(xbmc.getInfoLabel('System.BuildVersion').split('.')[0]) < 20 else True @@ -35,7 +41,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= # scws_id = urlparse(server_url).path.split('/')[-1] masterPlaylistParams = ast.literal_eval(iframeParams[0]) - url = iframeParams[1] + '?{}&n=1'.format(urllib.parse.urlencode(masterPlaylistParams)) + url = iframeParams[1] + '?{}&n=1'.format(urllib.urlencode(masterPlaylistParams)) # info = support.match(url, patron=r'LANGUAGE="([^"]+)",\s*URI="([^"]+)|(http.*?rendition=(\d+)[^\s]+)').matches #