Merge pull request #726 from auouymous/fix-youtube-error_message-not-assigned

fix #722 youtube error_message referenced before assignment
This commit is contained in:
Eric Le Lay 2020-01-11 10:08:12 +01:00 committed by GitHub
commit 4ac4f230b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -150,6 +150,7 @@ def get_real_download_url(url, preferred_fmt_ids=None):
# streamingData.formats are the same as url_encoded_fmt_stream_map
# streamingData.adaptiveFormats are audio-only and video-only formats
x = parse_qs(page)
error_message = None
if 'reason' in x:
error_message = util.remove_html_tags(x['reason'][0])
@ -176,7 +177,7 @@ def get_real_download_url(url, preferred_fmt_ids=None):
yield int(f['itag']), [f['url'], f.get('approxDurationMs')]
return
if error_message:
if error_message is not None:
raise YouTubeError('Cannot download video: %s' % error_message)
r4 = re.search('url_encoded_fmt_stream_map=([^&]+)', page)