1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-05-19 11:39:28 +00:00

[weibo] Add fallback if first pattern fail

This commit is contained in:
rafinetiz 2020-05-27 08:05:14 -07:00
parent 1db5ab6b34
commit fe39d606a1

View file

@ -73,8 +73,18 @@ class WeiboIE(InfoExtractor):
webpage = self._download_webpage(
url, video_id, note='Revisiting webpage')
title = self._html_search_regex(
r'<title>(.+?)</title>', webpage, 'title')
def search_title(webpage):
# This may fail if page title contains a line breaks
# See #25401
title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title', default=None)
if title is None:
# Fallback if first pattern fail
title = self._search_regex(r'(?:\$CONFIG\[\'title_value\'\]=\'(.+?)\';)', webpage, 'title')
return title
title = search_title(webpage)
video_formats = compat_parse_qs(self._search_regex(
r'video-sources=\\\"(.+?)\"', webpage, 'video_sources'))