diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-01-20 02:45:49 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-01-20 02:45:51 +0100 |
commit | c91778f8c0ba120378cb806f694fdc3f94a5634c (patch) | |
tree | 438e1e23146d01f70b3b256e449151380a3e087c /youtube_dl | |
parent | 5016f3eac879455a08cf7df0282fe59af9f3facf (diff) |
[youtube] Fall back to header if playlist title is not available
Sometimes (in about 10% of requests), the og:title is missing for a weird reason.
See #2170 for an example
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/youtube.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index bf3fde610..248b30ffb 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -27,6 +27,7 @@ from ..utils import ( get_element_by_id, get_element_by_attribute, ExtractorError, + RegexNotFoundError, unescapeHTML, unified_strdate, orderedSet, @@ -1448,7 +1449,14 @@ class YoutubePlaylistIE(YoutubeBaseInfoExtractor): if re.search(self._MORE_PAGES_INDICATOR, page) is None: break - playlist_title = self._og_search_title(page) + try: + playlist_title = self._og_search_title(page) + except RegexNotFoundError: + self.report_warning( + u'Playlist page is missing OpenGraph title, falling back ...', + playlist_id) + playlist_title = self._html_search_regex( + r'<h1 class="pl-header-title">(.*?)</h1>', page, u'title') url_results = self._ids_to_results(ids) return self.playlist_result(url_results, playlist_id, playlist_title) |