about summary refs log tree commit diff
path: root/youtube_dl/extractor/crackle.py
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2016-08-26 19:58:17 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2016-08-26 19:58:47 +0800
commit906b87cf5f6ccf28ebd75d6a92367d7c238f2ad9 (patch)
tree8a738042c975b28d2c21bd57384cbfbf332341f5 /youtube_dl/extractor/crackle.py
parent6b18a24e6ee39ab2fdb5e3d9e1cf2eec547ca3f9 (diff)
downloadyoutube-dl-906b87cf5f6ccf28ebd75d6a92367d7c238f2ad9.tar.gz
youtube-dl-906b87cf5f6ccf28ebd75d6a92367d7c238f2ad9.tar.xz
youtube-dl-906b87cf5f6ccf28ebd75d6a92367d7c238f2ad9.zip
[crackle] Revert to template-based thumbnail extraction
To reduce to number of HTTP requests
Diffstat (limited to 'youtube_dl/extractor/crackle.py')
-rw-r--r--youtube_dl/extractor/crackle.py23
1 files changed, 4 insertions, 19 deletions
diff --git a/youtube_dl/extractor/crackle.py b/youtube_dl/extractor/crackle.py
index 21f94d33c..cc68f1c00 100644
--- a/youtube_dl/extractor/crackle.py
+++ b/youtube_dl/extractor/crackle.py
@@ -1,8 +1,6 @@
 # coding: utf-8
 from __future__ import unicode_literals, division
 
-import re
-
 from .common import InfoExtractor
 from ..utils import int_or_none
 
@@ -34,6 +32,7 @@ class CrackleIE(InfoExtractor):
     }
 
     # extracted from http://legacyweb-us.crackle.com/flash/ReferrerRedirect.ashx
+    _THUMBNAIL_TEMPLATE = 'http://images-us-am.crackle.com/%stnl_1920x1080.jpg?ts=20140107233116?c=635333335057637614'
     _MEDIA_FILE_SLOTS = {
         'c544.flv': {
             'width': 544,
@@ -69,8 +68,10 @@ class CrackleIE(InfoExtractor):
         formats = self._extract_m3u8_formats(
             'http://content.uplynk.com/ext/%s/%s.m3u8' % (config_doc.attrib['strUplynkOwnerId'], video_id),
             video_id, 'mp4', m3u8_id='hls', fatal=None)
+        thumbnail = None
         path = item.attrib.get('p')
         if path:
+            thumbnail = self._THUMBNAIL_TEMPLATE % path
             http_base_url = 'http://ahttp.crackle.com/' + path
             for mfs_path, mfs_info in self._MEDIA_FILE_SLOTS.items():
                 formats.append({
@@ -91,22 +92,6 @@ class CrackleIE(InfoExtractor):
                     }]
         self._sort_formats(formats, ('width', 'height', 'tbr', 'format_id'))
 
-        media_details = self._download_json(
-            'https://web-api-us.crackle.com/Service.svc/details/media/%s/TW?format=json' % video_id,
-            video_id, fatal=False)
-        thumbnails = []
-        if media_details:
-            for key, value in media_details.items():
-                mobj = re.match('^Thumbnail_(\d+)x(\d+)$', key)
-                if mobj:
-                    width, height = list(map(int, mobj.groups()))
-                    thumbnails.append({
-                        'id': '%dp' % height,
-                        'url': value,
-                        'width': width,
-                        'height': height,
-                    })
-
         return {
             'id': video_id,
             'title': title,
@@ -115,7 +100,7 @@ class CrackleIE(InfoExtractor):
             'series': item.attrib.get('sn'),
             'season_number': int_or_none(item.attrib.get('se')),
             'episode_number': int_or_none(item.attrib.get('ep')),
-            'thumbnails': thumbnails,
+            'thumbnail': thumbnail,
             'subtitles': subtitles,
             'formats': formats,
         }