[glide] Simplify
authorPhilipp Hagemeister <phihag@phihag.de>
Fri, 24 Oct 2014 13:34:19 +0000 (15:34 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Fri, 24 Oct 2014 13:34:19 +0000 (15:34 +0200)
youtube_dl/extractor/common.py
youtube_dl/extractor/glide.py

index e8366f7f91c663f1f7bdf70db0588016f49da3de..8849208de9c0a628ed5138e16f0072609c561c79 100644 (file)
@@ -618,7 +618,7 @@ class InfoExtractor(object):
         formats.sort(key=_formats_key)
 
     def http_scheme(self):
-        """ Either "https:" or "https:", depending on the user's preferences """
+        """ Either "http:" or "https:", depending on the user's preferences """
         return (
             'http:'
             if self._downloader.params.get('prefer_insecure', False)
index 175d85197c022ae3f2e499546b43ad79101e9753..9561ed5fbaa25404654303956a676b000da2af67 100644 (file)
@@ -14,20 +14,27 @@ class GlideIE(InfoExtractor):
             'id': 'UZF8zlmuQbe4mr+7dCiQ0w==',
             'ext': 'mp4',
             'title': 'Damon Timm\'s Glide message',
-            'thumbnail' : 'http://dk608k4lm7m9j.cloudfront.net/3ee7da5af87065a1eeb8c6c9a864ba5b_2.jpg'
+            'thumbnail': 're:^https?://.*?\.cloudfront\.net/.*\.jpg$',
         }
     }
 
     def _real_extract(self, url):
         video_id = self._match_id(url)
         webpage = self._download_webpage(url, video_id)
-        title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
-        video_url = self._search_regex(r'<source src="(.*?)" type="video/mp4">', webpage, 'video_url')
-        thumbnail_url = self._search_regex(r'<img id="video-thumbnail" src="(.*?)" alt="Video thumbnail">', webpage, 'thumbnail_url')
+        title = self._html_search_regex(
+            r'<title>(.*?)</title>', webpage, 'title')
+        video_url = self.http_scheme() + self._search_regex(
+            r'<source src="(.*?)" type="video/mp4">', webpage, 'video URL')
+        thumbnail_url = self._search_regex(
+            r'<img id="video-thumbnail" src="(.*?)"',
+            webpage, 'thumbnail url', fatal=False)
+        thumbnail = (
+            thumbnail_url if thumbnail_url is None
+            else self.http_scheme() + thumbnail_url)
 
         return {
             'id': video_id,
             'title': title,
-            'url' : 'http:' + video_url,
-            'thumbnail' : 'http:' + thumbnail_url
+            'url': video_url,
+            'thumbnail': thumbnail,
         }