Skip to content

Commit

Permalink
[youtube] Fix extraction (closes #20758, closes #20759, closes #20761,
Browse files Browse the repository at this point in the history
…closes #20762, closes #20764, closes #20766, closes #20767, closes #20769, closes #20771, closes #20768, closes #20770)
  • Loading branch information
dstftw committed Apr 24, 2019
1 parent 50d6604 commit 56667d6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,8 @@ def extract_view_count(v_info):
view_count = extract_view_count(get_video_info)
if not video_info:
video_info = get_video_info
if 'token' in get_video_info:
get_token = get_video_info.get('token') or get_video_info.get('account_playback_token')
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,
Expand All @@ -1662,7 +1663,8 @@ def extract_view_count(v_info):
# 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.
if 'token' not in video_info:
token = video_info.get('token') or video_info.get('account_playback_token')
if not token:
video_info = get_video_info
break

Expand All @@ -1678,7 +1680,8 @@ def extract_unavailable_message():
raise ExtractorError(
'YouTube said: %s' % unavailable_message, expected=True, video_id=video_id)

if 'token' not in video_info:
token = video_info.get('token') or video_info.get('account_playback_token')
if not token:
if 'reason' in video_info:
if 'The uploader has not made this video available in your country.' in video_info['reason']:
regions_allowed = self._html_search_meta(
Expand Down

3 comments on commit 56667d6

@rolandheymanns
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the new version. Works perfect.

@mzso
Copy link

@mzso mzso commented on 56667d6 Apr 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awww. YT found a way to make downloads super slow again...
But at least I can download, thanks!

@frostu8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hell yeah. Thanks.

Please sign in to comment.