1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2025-02-18 10:07:55 +01:00

when url_or_request isn't request

Cloudscrape has problem with urls: `http://example.com//double-slash`
This commit is contained in:
bato3 2019-04-01 23:45:05 +02:00
parent ba2623208c
commit af778e165f
2 changed files with 10 additions and 4 deletions

View File

@ -18,7 +18,7 @@ from ..utils import (
class CDAIE(InfoExtractor):
_VALID_URL = r'https?://(?:(?:www\.)?cda\.pl/video|ebd\.cda\.pl/[0-9]+x[0-9]+)/(?P<id>[0-9a-z]+)'
_BASE_URL = 'http://www.cda.pl/'
_BASE_URL = 'https://www.cda.pl'
_TESTS = [{
'url': 'http://www.cda.pl/video/5749950c',
'md5': '6f844bf51b15f31fae165365707ae970',

View File

@ -644,9 +644,15 @@ class InfoExtractor(object):
tokens = scraper.get_tokens(err.geturl(), std_headers['User-Agent'], cookies=cookies)
except ValueError as e:
raise ExtractorError('cfscrape error: %s' % e, expected=True)
cookie = url_or_request.get_header('Cookie')
cookie += '; cf_clearance=' + tokens[0]['cf_clearance']
url_or_request = update_Request(url_or_request, headers={'Cookie': cookie})
cookie = 'cf_clearance=' + tokens[0]['cf_clearance']
for c in self._downloader.cookiejar:
cookie += '; %s=%s' % (c.name, c.value)
if not isinstance(url_or_request, compat_urllib_request.Request):
self._set_cookie(compat_urlparse.urlparse(err.geturl()).netloc, 'cf_clearance', tokens[0]['cf_clearance'])
url_or_request = sanitized_Request(url_or_request, data, {'Cookie': cookie})
else:
url_or_request = update_Request(url_or_request, headers={'Cookie': cookie})
self.to_screen('Redownload webpage')
try:
return self._downloader.urlopen(url_or_request)