about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-05-04 11:42:44 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2013-05-04 11:42:44 +0200
commitdb8fd71ca976e9e4e79d79ca86fa359ca547f06b (patch)
tree3431a729949d4c225606ea2c0fdec39fdfbff2ef
parentf4f316881d6328aa235900eb9f8e5c853dc7781e (diff)
downloadyoutube-dl-db8fd71ca976e9e4e79d79ca86fa359ca547f06b.tar.gz
youtube-dl-db8fd71ca976e9e4e79d79ca86fa359ca547f06b.tar.xz
youtube-dl-db8fd71ca976e9e4e79d79ca86fa359ca547f06b.zip
twitch.tv chapters: Use API for title and other metadata
-rwxr-xr-xyoutube_dl/InfoExtractors.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py
index eacb5eb27..737bf7aa0 100755
--- a/youtube_dl/InfoExtractors.py
+++ b/youtube_dl/InfoExtractors.py
@@ -3368,10 +3368,6 @@ class JustinTVIE(InfoExtractor):
             if not m:
                 raise ExtractorError(u'Cannot find archive of a chapter')
             archive_id = m.group(1)
-            m = re.search(r"<h2 class='js-title'>([^<]*)</h2>", webpage)
-            if not m:
-                raise ExtractorError(u'Cannot find chapter title')
-            video_title = m.group(1)
 
             api = api_base + '/broadcast/by_chapter/%s.xml' % chapter_id
             chapter_info_xml = self._download_webpage(api, chapter_id,
@@ -3387,6 +3383,12 @@ class JustinTVIE(InfoExtractor):
             video_url = a.find('./video_file_url').text
             video_ext = video_url.rpartition('.')[2] or u'flv'
 
+            chapter_api_url = u'https://api.twitch.tv/kraken/videos/c' + chapter_id
+            chapter_info_json = self._download_webpage(chapter_api_url, video_id,
+                                   note='Downloading chapter metadata',
+                                   errnote='Download of chapter metadata failed')
+            chapter_info = json.loads(chapter_info_json)
+
             # TODO determine start (and probably fix up file)
             #  youtube-dl -v http://www.twitch.tv/firmbelief/c/1757457
             #video_url += u'?start=' + a.find('./start_timestamp').text
@@ -3396,7 +3398,9 @@ class JustinTVIE(InfoExtractor):
                 'id': u'c' + chapter_id,
                 'url': video_url,
                 'ext': video_ext,
-                'title': video_title,
+                'title': chapter_info['title'],
+                'thumbnail': chapter_info['preview'],
+                'description': chapter_info['description'],
             }
             return [info]
         else: