Skip to content

Commit

Permalink
minor code cleanup using python six
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmich committed Dec 25, 2024
1 parent e931a68 commit 6fcf192
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
14 changes: 5 additions & 9 deletions servers/dropload.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# -*- coding: utf-8 -*-

try:
import urllib.parse as urllib
except ImportError:
import urllib
from six.moves import urllib

from core import httptools, support
from core import scrapertools
from platformcode import logger, config

from lib import jsunpack
import re

def test_video_exists(page_url):
logger.debug("(page_url='%s')" % page_url)
Expand All @@ -24,15 +22,13 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
logger.debug(" url=" + page_url)

global data
# vres = scrapertools.find_multiple_matches(data, 'nowrap[^>]+>([^,]+)')
# if not vres: vres = scrapertools.find_multiple_matches(data, '<td>(\d+x\d+)')

data_pack = scrapertools.find_single_match(data, "</div>\n\s*<script[^>]+>(eval.function.p,a,c,k,e,.*?)\s*</script>")
if data_pack != "":
from lib import jsunpack
data = jsunpack.unpack(data_pack)
data = re.sub(r'\b([a-zA-Z]+):("[^"]+"[,\n}])', r'"\1":\2', data)

_headers = urllib.urlencode(httptools.default_headers)
_headers = urllib.parse.urlencode(httptools.default_headers)
video_urls = support.get_jwplayer_mediaurl(data, 'dropload')

return video_urls
16 changes: 7 additions & 9 deletions servers/streamingcommunityws.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
PY3 = False
if sys.version_info[0] >= 3: PY3 = True

if PY3:
import urllib.parse as urllib
else:
import urllib
from six.moves import urllib

import ast
import xbmc

from core import httptools, support, filetools
from platformcode import logger, config
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

Expand All @@ -28,21 +23,24 @@ def test_video_exists(page_url):
if not iframeParams or len(iframeParams) < 2:
return 'StreamingCommunity', 'Prossimamente'

urlParams = urllib.parse_qs(urllib.urlsplit(server_url).query)
urlParams = urllib.parse.parse_qs(urllib.parse.urlsplit(server_url).query)
return True, ""


def get_video_url(page_url, premium=False, user="", password="", video_password=""):
video_urls = list()

quality, params, url = iframeParams

split_url = urllib.parse.urlsplit(url)
url_params = urllib.parse.parse_qsl(split_url.query)
logger.debug(url_params)
masterPlaylistParams = ast.literal_eval(params)
if 'canPlayFHD' in urlParams:
masterPlaylistParams['h'] = 1
if 'b' in urlParams:
masterPlaylistParams['b'] = 1
url = '{}?{}'.format(url,urllib.urlencode(masterPlaylistParams))
masterPlaylistParams.update(url_params)
url = '{}://{}{}?{}'.format(split_url.scheme,split_url.netloc,split_url.path,urllib.parse.urlencode(masterPlaylistParams))

video_urls = [['hls [{}]'.format(quality), url]]

Expand Down

0 comments on commit 6fcf192

Please sign in to comment.