[CSpan] Add detection for Senate ISVP. Closes #5302
[youtube-dl] / youtube_dl / extractor / senateisvp.py
index 807979d13c90fd2766be20b8f74049248a5981c3..23e1cd944aa717ec2306f3b1b6022f8582c081af 100644 (file)
@@ -3,7 +3,10 @@ from __future__ import unicode_literals
 
 import re
 from .common import InfoExtractor
-from ..utils import ExtractorError
+from ..utils import (
+    ExtractorError,
+    unsmuggle_url,
+)
 from ..compat import (
     compat_parse_qs,
     compat_urlparse,
@@ -53,6 +56,7 @@ class SenateISVPIE(InfoExtractor):
             'id': 'judiciary031715',
             'ext': 'flv',
             'title': 'Integrated Senate Video Player',
+            'thumbnail': 're:^https?://.*\.(?:jpg|png)$',
         }
     }, {
         'url': 'http://www.senate.gov/isvp/?type=live&comm=commerce&filename=commerce011514.mp4&auto_play=false',
@@ -72,12 +76,22 @@ class SenateISVPIE(InfoExtractor):
         }
     }]
 
+    @staticmethod
+    def _search_iframe_url(webpage):
+        mobj = re.search(
+            r"<iframe[^>]+src=['\"](?P<url>http://www\.senate\.gov/isvp/\?[^'\"]+)['\"]",
+            webpage)
+        if mobj:
+            return mobj.group('url')
+
     def _get_info_for_comm(self, committee):
         for entry in self._COMM_MAP:
             if entry[0] == committee:
                 return entry[1:]
 
     def _real_extract(self, url):
+        url, smuggled_data = unsmuggle_url(url, {})
+
         qs = compat_parse_qs(re.match(self._VALID_URL, url).group('qs'))
         if not qs.get('filename') or not qs.get('type') or not qs.get('comm'):
             raise ExtractorError('Invalid URL', expected=True)
@@ -86,7 +100,13 @@ class SenateISVPIE(InfoExtractor):
 
         webpage = self._download_webpage(url, video_id)
 
-        title = self._html_search_regex(r'<title>([^<]+)</title>', webpage, video_id)
+        if smuggled_data.get('force_title'):
+            title = smuggled_data['force_title']
+        else:
+            title = self._html_search_regex(r'<title>([^<]+)</title>', webpage, video_id)
+        poster = qs.get('poster')
+        if poster:
+            thumbnail = poster[0]
 
         video_type = qs['type'][0]
         committee = video_type if video_type == 'arch' else qs['comm'][0]
@@ -119,6 +139,7 @@ class SenateISVPIE(InfoExtractor):
         info_dict = {
             'id': video_id,
             'title': title,
+            'thumbnail': thumbnail,
         }
 
         if len(formats) >= 1: