Merge remote-tracking branch 'FiloSottille/supports'
[youtube-dl] / youtube_dl / InfoExtractors.py
index 2b313966fd35a69f338f9d8ee1024c4bdbaa3064..ff5c47726db5c1f4d1bfb3492c747b2bb2481382 100644 (file)
@@ -404,7 +404,7 @@ class YoutubeIE(InfoExtractor):
                        url_data_strs = video_info['url_encoded_fmt_stream_map'][0].split(',')
                        url_data = [parse_qs(uds) for uds in url_data_strs]
                        url_data = filter(lambda ud: 'itag' in ud and 'url' in ud, url_data)
-                       url_map = dict((ud['itag'][0], ud['url'][0]) for ud in url_data)
+                       url_map = dict((ud['itag'][0], ud['url'][0] + '&signature=' + ud['sig'][0]) for ud in url_data)
 
                        format_limit = self._downloader.params.get('format_limit', None)
                        available_formats = self._available_formats_prefer_free if self._downloader.params.get('prefer_free_formats', False) else self._available_formats
@@ -3098,30 +3098,6 @@ class XNXXIE(InfoExtractor):
                """Report information extraction"""
                self._downloader.to_screen(u'[%s] %s: Extracting information' % (self.IE_NAME, video_id))
 
-       def extract_video_url(self, webpage):
-               "Extract the url for the video from the webpage"
-               
-               result = re.search(self.VIDEO_URL_RE, webpage)
-               if result is None:
-                       self._downloader.trouble(u'ERROR: unable to extract video url')
-               return urllib.unquote(result.group(1).decode('utf-8'))
-
-       def extract_video_title(self, webpage):
-               "Extract the title for the video from the webpage"
-
-               result = re.search(self.VIDEO_TITLE_RE, webpage)
-               if result is None:
-                       self._downloader.trouble(u'ERROR: unable to extract video title')
-               return result.group(1).decode('utf-8')
-
-       def extract_video_thumbnail(self, webpage):
-               "Extract the thumbnail for the video from the webpage"
-
-               result = re.search(self.VIDEO_THUMB_RE, webpage)
-               if result is None:
-                       self._downloader.trouble(u'ERROR: unable to extract video thumbnail')
-               return result.group(1).decode('utf-8')
-
        def _real_extract(self, url):
                mobj = re.match(self._VALID_URL, url)
                if mobj is None:
@@ -3138,15 +3114,33 @@ class XNXXIE(InfoExtractor):
                        self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % err)
                        return
 
+               result = re.search(self.VIDEO_URL_RE, webpage)
+               if result is None:
+                       self._downloader.trouble(u'ERROR: unable to extract video url')
+                       return
+               video_url = urllib.unquote(result.group(1).decode('utf-8'))
+
+               result = re.search(self.VIDEO_TITLE_RE, webpage)
+               if result is None:
+                       self._downloader.trouble(u'ERROR: unable to extract video title')
+                       return
+               video_title = result.group(1).decode('utf-8')
+
+               result = re.search(self.VIDEO_THUMB_RE, webpage)
+               if result is None:
+                       self._downloader.trouble(u'ERROR: unable to extract video thumbnail')
+                       return
+               video_thumbnail = result.group(1).decode('utf-8')
+
                info = {'id': video_id,
-                               'url': self.extract_video_url(webpage),
+                               'url': video_url,
                                'uploader': None,
                                'upload_date': None,
-                               'title': self.extract_video_title(webpage),
+                               'title': video_title,
                                'ext': 'flv',
                                'format': 'flv',
-                               'thumbnail': self.extract_video_thumbnail(webpage),
+                               'thumbnail': video_thumbnail,
                                'description': None,
                                'player_url': None}
 
-               return [info]
\ No newline at end of file
+               return [info]