[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( webpage = self._download_webpage(
url, video_id, note='Revisiting webpage') url, video_id, note='Revisiting webpage')
title = self._html_search_regex( def search_title(webpage):
r'<title>(.+?)</title>', webpage, 'title') # 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( video_formats = compat_parse_qs(self._search_regex(
r'video-sources=\\\"(.+?)\"', webpage, 'video_sources')) r'video-sources=\\\"(.+?)\"', webpage, 'video_sources'))