This commit is contained in:
Avi Peretz 2020-01-22 23:41:49 +02:00
parent 97db5c0e68
commit b996efcb11

View File

@ -2,7 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import requests
import itertools import itertools
import json import json
import os.path import os.path
@ -1780,50 +1780,53 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
# manifest pointed by get_video_info's dashmpd). # manifest pointed by get_video_info's dashmpd).
# The general idea is to take a union of itags of both DASH manifests (for example # The general idea is to take a union of itags of both DASH manifests (for example
# video with such 'manifest behavior' see https://github.com/ytdl-org/youtube-dl/issues/6093) # video with such 'manifest behavior' see https://github.com/ytdl-org/youtube-dl/issues/6093)
self.report_video_info_webpage_download(video_id) if self._downloader.params.get('youtube_extend_dash_manifest', False):
for el in ('embedded', 'detailpage', 'vevo', ''): self.report_video_info_webpage_download(video_id)
query = { for el in ('embedded', 'detailpage', 'vevo', ''):
'video_id': video_id, query = {
'ps': 'default', 'video_id': video_id,
'eurl': '', 'ps': 'default',
'gl': 'US', 'eurl': '',
'hl': 'en', 'gl': 'US',
} 'hl': 'en',
if el: }
query['el'] = el if el:
if sts: query['el'] = el
query['sts'] = sts if sts:
video_info_webpage = self._download_webpage( query['sts'] = sts
'%s://www.youtube.com/get_video_info' % proto, video_info_webpage = self._download_webpage(
video_id, note=False, '%s://www.youtube.com/get_video_info' % proto,
errnote='unable to download video info webpage', video_id, note=False,
fatal=False, query=query) errnote='unable to download video info webpage',
if not video_info_webpage: fatal=False, query=query)
continue if not video_info_webpage:
get_video_info = compat_parse_qs(video_info_webpage) continue
if not player_response: get_video_info = compat_parse_qs(video_info_webpage)
pl_response = get_video_info.get('player_response', [None])[0] if not player_response:
player_response = extract_player_response(pl_response, video_id) pl_response = get_video_info.get('player_response', [None])[0]
add_dash_mpd(get_video_info) player_response = extract_player_response(pl_response, video_id)
if view_count is None: add_dash_mpd(get_video_info)
view_count = extract_view_count(get_video_info) if view_count is None:
if not video_info: view_count = extract_view_count(get_video_info)
video_info = get_video_info if not video_info:
get_token = extract_token(get_video_info)
if get_token:
# Different get_video_info requests may report different results, e.g.
# some may report video unavailability, but some may serve it without
# any complaint (see https://github.com/ytdl-org/youtube-dl/issues/7362,
# the original webpage as well as el=info and el=embedded get_video_info
# requests report video unavailability due to geo restriction while
# el=detailpage succeeds and returns valid data). This is probably
# due to YouTube measures against IP ranges of hosting providers.
# Working around by preferring the first succeeded video_info containing
# the token if no such video_info yet was found.
token = extract_token(video_info)
if not token:
video_info = get_video_info video_info = get_video_info
break get_token = extract_token(get_video_info)
if get_token:
# Different get_video_info requests may report different results, e.g.
# some may report video unavailability, but some may serve it without
# any complaint (see https://github.com/ytdl-org/youtube-dl/issues/7362,
# the original webpage as well as el=info and el=embedded get_video_info
# requests report video unavailability due to geo restriction while
# el=detailpage succeeds and returns valid data). This is probably
# due to YouTube measures against IP ranges of hosting providers.
# Working around by preferring the first succeeded video_info containing
# the token if no such video_info yet was found.
token = extract_token(video_info)
if not token:
video_info = get_video_info
break
else:
video_info = {'title': 'Unknown'}
def extract_unavailable_message(): def extract_unavailable_message():
messages = [] messages = []