1
0
Fork 0
mirror of https://github.com/blackjack4494/yt-dlc.git synced 2024-12-27 02:09:06 +00:00

[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
This commit is contained in:
Philipp Hagemeister 2014-01-20 02:45:49 +01:00
parent 5016f3eac8
commit c91778f8c0

View file

@ -27,6 +27,7 @@ from ..utils import (
get_element_by_id, get_element_by_id,
get_element_by_attribute, get_element_by_attribute,
ExtractorError, ExtractorError,
RegexNotFoundError,
unescapeHTML, unescapeHTML,
unified_strdate, unified_strdate,
orderedSet, orderedSet,
@ -1448,7 +1449,14 @@ class YoutubePlaylistIE(YoutubeBaseInfoExtractor):
if re.search(self._MORE_PAGES_INDICATOR, page) is None: if re.search(self._MORE_PAGES_INDICATOR, page) is None:
break break
try:
playlist_title = self._og_search_title(page) 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) url_results = self._ids_to_results(ids)
return self.playlist_result(url_results, playlist_id, playlist_title) return self.playlist_result(url_results, playlist_id, playlist_title)