1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-12-18 04:27:54 +01:00

[youtube] Improve unavailable message extraction (refs #22117)

This commit is contained in:
Sergey M․ 2019-08-16 23:36:23 +07:00
parent 0326bcb6c1
commit 0add33abcb
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -1809,10 +1809,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
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()