migliorati test per i server e alcuni fix

This commit is contained in:
marco
2020-07-18 17:38:27 +02:00
parent c41e4b9a3c
commit 7844ddaba7
9 changed files with 60 additions and 49 deletions
+8 -7
View File
@@ -56,7 +56,7 @@ HTTPTOOLS_DEFAULT_RANDOM_HEADERS = False
# with open(CF_LIST_PATH, "rb") as CF_File:
# CF_LIST = CF_File.read().splitlines()
FORCE_CLOUDSCRAPER_LIST = []
FORCE_CLOUDSCRAPER_LIST = ['akvideo.stream']
def get_user_agent():
# Returns the global user agent to be used when necessary for the url.
@@ -256,7 +256,7 @@ def downloadpage(url, **opt):
Parameter Type Description
-------------------------------------------------- -------------------------------------------------- ------------
HTTPResponse.sucess: bool True: Request successful | False: Error when making the request
HTTPResponse.success: bool True: Request successful | False: Error when making the request
HTTPResponse.code: int Server response code or error code if an error occurs
HTTPResponse.error: str Description of the error in case of an error
HTTPResponse.headers: dict Dictionary with server response headers
@@ -380,9 +380,10 @@ def downloadpage(url, **opt):
req = requests.Response()
if not opt.get('ignore_response_code', False) and not proxy_data.get('stat', ''):
response['data'] = ''
response['sucess'] = False
response['success'] = False
info_dict.append(('Success', 'False'))
response['code'] = str(e)
import traceback
response['code'] = traceback.format_exc()
info_dict.append(('Response code', str(e)))
info_dict.append(('Finished in', time.time() - inicio))
if not opt.get('alfa_s', False):
@@ -393,7 +394,7 @@ def downloadpage(url, **opt):
else:
response['data'] = ''
response['sucess'] = False
response['success'] = False
response['code'] = ''
return type('HTTPResponse', (), response)
@@ -476,10 +477,10 @@ def fill_fields_post(info_dict, req, response, req_headers, inicio):
if response['code'] == 200:
info_dict.append(('Success', 'True'))
response['sucess'] = True
response['success'] = True
else:
info_dict.append(('Success', 'False'))
response['sucess'] = False
response['success'] = False
info_dict.append(('Response data length', len(response['data'])))
+3 -3
View File
@@ -1336,9 +1336,9 @@ def addQualityTag(item, itemlist, data, patron):
else:
log('nessun tag qualità trovato')
def get_jwplayer_mediaurl(data, srvName):
def get_jwplayer_mediaurl(data, srvName, onlyHttp=False):
video_urls = []
block = scrapertools.find_single_match(data, r'sources: \[([^\]]+)\]')
block = scrapertools.find_single_match(data, r'sources:\s*\[([^\]]+)\]')
if 'file:' in block:
sources = scrapertools.find_multiple_matches(block, r'file:\s*"([^"]+)"(?:,label:\s*"([^"]+)")?')
elif 'src:' in block:
@@ -1348,7 +1348,7 @@ def get_jwplayer_mediaurl(data, srvName):
for url, quality in sources:
quality = 'auto' if not quality else quality
if url.split('.')[-1] != 'mpd':
video_urls.append(['.' + url.split('.')[-1] + ' [' + quality + '] [' + srvName + ']', url])
video_urls.append(['.' + url.split('.')[-1] + ' [' + quality + '] [' + srvName + ']', url if not onlyHttp else url.replace('https://', 'http://')])
video_urls.sort(key=lambda x: x[0].split()[1])
return video_urls