Skip to content

Commit

Permalink
[youtube] Improve unavailable message extraction (refs #22117)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw authored and pareronia committed Jun 22, 2020
1 parent 678c861 commit 074b87e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,10 +1809,15 @@ def extract_player_response(player_response, video_id):
break

def extract_unavailable_message():
return self._html_search_regex(
(r'(?s)<div[^>]+id=["\']unavailable-submessage["\'][^>]+>(.+?)</div',
r'(?s)<h1[^>]+id=["\']unavailable-message["\'][^>]*>(.+?)</h1>'),
video_webpage, 'unavailable message', default=None)
messages = []
for tag, kind in (('h1', 'message'), ('div', 'submessage')):
msg = self._html_search_regex(
r'(?s)<{tag}[^>]+id=["\']unavailable-{kind}["\'][^>]*>(.+?)</{tag}>'.format(tag=tag, kind=kind),
video_webpage, 'unavailable %s' % kind, default=None)
if msg:
messages.append(msg)
if messages:
return '\n'.join(messages)

if not video_info:
unavailable_message = extract_unavailable_message()
Expand Down

0 comments on commit 074b87e

Please sign in to comment.