[bbc] Use _search_json_ld
authorYen Chi Hsuan <yan12125@gmail.com>
Sat, 16 Jan 2016 12:46:28 +0000 (20:46 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Sat, 16 Jan 2016 12:46:28 +0000 (20:46 +0800)
youtube_dl/extractor/bbc.py

index ce99a34abf109a8d8daef6c23643281d079afa9c..1c493b72d9d4a08accaea8f8f7dc68fe693f3fe9 100644 (file)
@@ -718,19 +718,10 @@ class BBCIE(BBCCoUkIE):
 
         webpage = self._download_webpage(url, playlist_id)
 
-        timestamp = None
-        playlist_title = None
-        playlist_description = None
-
-        ld = self._parse_json(
-            self._search_regex(
-                r'(?s)<script type="application/ld\+json">(.+?)</script>',
-                webpage, 'ld json', default='{}'),
-            playlist_id, fatal=False)
-        if ld:
-            timestamp = parse_iso8601(ld.get('datePublished'))
-            playlist_title = ld.get('headline')
-            playlist_description = ld.get('articleBody')
+        json_ld_info = self._search_json_ld(webpage, playlist_id, default=None)
+        timestamp = json_ld_info.get('timestamp')
+        playlist_title = json_ld_info.get('title')
+        playlist_description = json_ld_info.get('description')
 
         if not timestamp:
             timestamp = parse_iso8601(self._search_regex(