Fix alternativo a redirect

This commit is contained in:
marco
2022-05-04 19:57:21 +02:00
parent 5484fcc661
commit 7ab66fbb8a
3 changed files with 16 additions and 12 deletions

View File

@@ -32,7 +32,7 @@
"raiplay": "https://www.raiplay.it",
"serietvu": "https://www.serietvu.live",
"streamingcommunity": "https://streamingcommunity.top",
"streamingita": "https://eurostreaming.vote",
"streamingita": "https://www.streamingita.life",
"streamtime": "https://t.me/s/StreamTime",
"tantifilm": "https://www.tantifilm.zone",
"toonitalia": "https://toonitalia.co",

View File

@@ -17,8 +17,6 @@ else:
host = support.config.get_channel_url()
session = requests.Session()
session.request = functools.partial(session.request, timeout=httptools.HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT)
headers = {}
@@ -28,10 +26,10 @@ def getHeaders(forced=False):
if not headers:
# try:
headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'}
response = session.get(host, headers=headers)
response = httptools.downloadpage(host, headers=headers)
# if not response.url.startswith(host):
# host = support.config.get_channel_url(findhost, forceFindhost=True)
csrf_token = support.match(response.text, patron='name="csrf-token" content="([^"]+)"').match
csrf_token = support.match(response.data, patron='name="csrf-token" content="([^"]+)"').match
headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14',
'content-type': 'application/json;charset=UTF-8',
'Referer': host,
@@ -92,10 +90,10 @@ def newest(category):
item.args = 1
item.newest = True
if category == 'peliculas':
item.contentType == 'movie'
item.contentType = 'movie'
item.url = host + '/film'
else:
item.contentType == 'tvshow'
item.contentType = 'tvshow'
item.url = host + '/serie-tv'
try:
@@ -133,10 +131,10 @@ def peliculas(item):
records = json.loads(support.match(data, patron=r'slider-title titles-json="(.*?)"\s*slider-name="').matches[item.args])
elif not item.search:
payload = json.dumps({'type': videoType, 'offset':offset, 'genre':item.args})
records = session.post(host + '/api/browse', headers=headers, data=payload).json()['records']
records = httptools.downloadpage(host + '/api/browse', headers=headers, post=payload).json['records']
else:
payload = json.dumps({'q': item.search})
records = session.post(host + '/api/search', headers=headers, data=payload).json()['records']
records = httptools.downloadpage(host + '/api/search', headers=headers, post=payload).json['records']
if records and type(records[0]) == list:
@@ -171,8 +169,8 @@ def peliculas(item):
return itemlist
def makeItem(n, it, item):
info = session.post(host + '/api/titles/preview/{}'.format(it['id']), headers=headers).json()
logger.debug(jsontools.dump(it))
info = httptools.downloadpage(host + '/api/titles/preview/{}'.format(it['id']), headers=headers, post={}).json
logger.debug(it)
title = info['name']
lang = 'Sub-ITA' if 'sub-ita' in title.lower() else 'ITA'
title = support.cleantitle(re.sub('\[|\]|[Ss][Uu][Bb]-[Ii][Tt][Aa]', '', title))

View File

@@ -375,8 +375,14 @@ def downloadpage(url, **opt):
timeout=opt['timeout'])
else:
# Makes the request with POST method
req = session.post(url, data=payload, allow_redirects=opt.get('follow_redirects', True),
req = session.post(url, data=payload, allow_redirects=False,
files=files, timeout=opt['timeout'])
# Make sure it follows redirects
i = 10
while opt.get('follow_redirects', True) and i > 0 and req.status_code == 301:
req = session.post(req.headers['Location'], data=payload, allow_redirects=False,
files=files, timeout=opt['timeout'])
i -= 1
elif opt.get('only_headers', False):
info_dict = fill_fields_pre(url, opt, proxy_data, file_name)