mirror of
https://gitlab.com/dstftw/youtube-dl.git
synced 2020-11-16 09:42:26 +00:00
[googledrive] Use redirect URLs for source format (closes #18877, closes #23919, closes #24689, closes #26565)
This commit is contained in:
parent
95c9810015
commit
da2069fb22
|
@ -220,19 +220,27 @@ class GoogleDriveIE(InfoExtractor):
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'export': 'download',
|
'export': 'download',
|
||||||
})
|
})
|
||||||
urlh = self._request_webpage(
|
|
||||||
source_url, video_id, note='Requesting source file',
|
def request_source_file(source_url, kind):
|
||||||
errnote='Unable to request source file', fatal=False)
|
return self._request_webpage(
|
||||||
|
source_url, video_id, note='Requesting %s file' % kind,
|
||||||
|
errnote='Unable to request %s file' % kind, fatal=False)
|
||||||
|
urlh = request_source_file(source_url, 'source')
|
||||||
if urlh:
|
if urlh:
|
||||||
def add_source_format(src_url):
|
def add_source_format(urlh):
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': src_url,
|
# Use redirect URLs as download URLs in order to calculate
|
||||||
|
# correct cookies in _calc_cookies.
|
||||||
|
# Using original URLs may result in redirect loop due to
|
||||||
|
# google.com's cookies mistakenly used for googleusercontent.com
|
||||||
|
# redirect URLs (see #23919).
|
||||||
|
'url': urlh.geturl(),
|
||||||
'ext': determine_ext(title, 'mp4').lower(),
|
'ext': determine_ext(title, 'mp4').lower(),
|
||||||
'format_id': 'source',
|
'format_id': 'source',
|
||||||
'quality': 1,
|
'quality': 1,
|
||||||
})
|
})
|
||||||
if urlh.headers.get('Content-Disposition'):
|
if urlh.headers.get('Content-Disposition'):
|
||||||
add_source_format(source_url)
|
add_source_format(urlh)
|
||||||
else:
|
else:
|
||||||
confirmation_webpage = self._webpage_read_content(
|
confirmation_webpage = self._webpage_read_content(
|
||||||
urlh, url, video_id, note='Downloading confirmation page',
|
urlh, url, video_id, note='Downloading confirmation page',
|
||||||
|
@ -242,9 +250,12 @@ class GoogleDriveIE(InfoExtractor):
|
||||||
r'confirm=([^&"\']+)', confirmation_webpage,
|
r'confirm=([^&"\']+)', confirmation_webpage,
|
||||||
'confirmation code', fatal=False)
|
'confirmation code', fatal=False)
|
||||||
if confirm:
|
if confirm:
|
||||||
add_source_format(update_url_query(source_url, {
|
confirmed_source_url = update_url_query(source_url, {
|
||||||
'confirm': confirm,
|
'confirm': confirm,
|
||||||
}))
|
})
|
||||||
|
urlh = request_source_file(confirmed_source_url, 'confirmed source')
|
||||||
|
if urlh and urlh.headers.get('Content-Disposition'):
|
||||||
|
add_source_format(urlh)
|
||||||
|
|
||||||
if not formats:
|
if not formats:
|
||||||
reason = self._search_regex(
|
reason = self._search_regex(
|
||||||
|
|
Loading…
Reference in a new issue