From fe39d606a1869f8f28c83d247bc92308453172a1 Mon Sep 17 00:00:00 2001 From: rafinetiz Date: Wed, 27 May 2020 08:05:14 -0700 Subject: [PATCH] [weibo] Add fallback if first pattern fail --- youtube_dl/extractor/weibo.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/weibo.py b/youtube_dl/extractor/weibo.py index 621df5b54..67411c1c5 100644 --- a/youtube_dl/extractor/weibo.py +++ b/youtube_dl/extractor/weibo.py @@ -73,8 +73,18 @@ class WeiboIE(InfoExtractor): webpage = self._download_webpage( url, video_id, note='Revisiting webpage') - title = self._html_search_regex( - r'(.+?)', webpage, 'title') + def search_title(webpage): + # This may fail if page title contains a line breaks + # See #25401 + title = self._html_search_regex(r'(.+?)', 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'))