]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[ted] Improve playlist extraction (closes #21032)
authorSergey M․ <dstftw@gmail.com>
Fri, 7 Jun 2019 20:06:41 +0000 (03:06 +0700)
committerSergey M․ <dstftw@gmail.com>
Fri, 7 Jun 2019 20:07:08 +0000 (03:07 +0700)
youtube_dl/extractor/ted.py

index 17dc41a394f0106318a7104b56bcb5bd37bd6456..9b60cc462646da506f490ee1037d6dcf4d47fcbe 100644 (file)
@@ -157,16 +157,19 @@ class TEDIE(InfoExtractor):
                                          'Downloading playlist webpage')
 
         playlist_entries = []
-        for entry in re.findall(r'(?s)<[^>]+data-ga-context="playlist"[^>]*>', webpage):
+        for entry in re.findall(r'(?s)<[^>]+data-ga-context=["\']playlist["\'][^>]*>', webpage):
             attrs = extract_attributes(entry)
             entry_url = compat_urlparse.urljoin(url, attrs['href'])
             playlist_entries.append(self.url_result(entry_url, self.ie_key()))
 
-        final_url = self._og_search_url(webpage)
+        final_url = self._og_search_url(webpage, fatal=False)
+        playlist_id = (
+            re.match(self._VALID_URL, final_url).group('playlist_id')
+            if final_url else None)
+
         return self.playlist_result(
-            playlist_entries,
-            playlist_id=re.match(self._VALID_URL, final_url, re.VERBOSE).group('playlist_id'),
-            playlist_title=self._og_search_title(webpage),
+            playlist_entries, playlist_id=playlist_id,
+            playlist_title=self._og_search_title(webpage, fatal=False),
             playlist_description=self._og_search_description(webpage))
 
     def _talk_info(self, url, video_name):