Skip to content

Commit

Permalink
Fix new breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
user234683 committed Apr 24, 2019
1 parent 0ecf3d0 commit ba3b10e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,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/rg3/youtube-dl/issues/7362,
Expand All @@ -1722,7 +1723,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 @@ -1731,7 +1733,8 @@ def extract_unavailable_message():
r'(?s)<h1[^>]+id="unavailable-message"[^>]*>(.+?)</h1>',
video_webpage, 'unavailable message', default=None)

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
9 changes: 6 additions & 3 deletions youtube_dl/extractor/youtube_unmodified_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,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/rg3/youtube-dl/issues/7362,
Expand All @@ -1658,7 +1659,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 @@ -1667,7 +1669,8 @@ def extract_unavailable_message():
r'(?s)<h1[^>]+id="unavailable-message"[^>]*>(.+?)</h1>',
video_webpage, 'unavailable message', default=None)

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

0 comments on commit ba3b10e

Please sign in to comment.