]> git.bitcoin.ninja Git - youtube-dl/commitdiff
Merge xnxx.com Support (NSFW). Test URL (SFW): http://video.xnxx.com/video1443330...
authorPhilipp Hagemeister <phihag@phihag.de>
Thu, 27 Sep 2012 16:55:56 +0000 (18:55 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Thu, 27 Sep 2012 16:55:56 +0000 (18:55 +0200)
1  2 
youtube_dl/InfoExtractors.py
youtube_dl/__init__.py

index 8dd1c0b0727ff3bcb6001a460aa7b892f529d586,32c52cc08542a10588a5adeb444b6d3e6b7c3d64..56003df260284b6bd1c86c01e3cc4e24dd3b5c75
@@@ -95,7 -95,7 +95,7 @@@ class InfoExtractor(object)
  class YoutubeIE(InfoExtractor):
        """Information extractor for youtube.com."""
  
 -      _VALID_URL = r'^((?:https?://)?(?:youtu\.be/|(?:\w+\.)?youtube(?:-nocookie)?\.com/)(?!view_play_list|my_playlists|artist|playlist)(?:(?:(?:v|embed|e)/)|(?:(?:watch(?:_popup)?(?:\.php)?)?(?:\?|#!?)(?:.+&)?v=))?)?([0-9A-Za-z_-]+)(?(1).+)?$'
 +      _VALID_URL = r'^((?:https?://)?(?:youtu\.be/|(?:\w+\.)?youtube(?:-nocookie)?\.com/|tube.majestyc.net/)(?!view_play_list|my_playlists|artist|playlist)(?:(?:(?:v|embed|e)/)|(?:(?:watch(?:_popup)?(?:\.php)?)?(?:\?|#!?)(?:.+&)?v=))?)?([0-9A-Za-z_-]+)(?(1).+)?$'
        _LANG_URL = r'http://www.youtube.com/?hl=en&persist_hl=1&gl=US&persist_gl=1&opt_out_ackd=1'
        _LOGIN_URL = 'https://www.youtube.com/signup?next=/&gl=US&hl=en'
        _AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en'
                        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
@@@ -2955,3 -2955,73 +2955,73 @@@ class MTVIE(InfoExtractor)
                }
  
                return [info]
 -              return [info]
+ class XNXXIE(InfoExtractor):
+       """Information extractor for xnxx.com"""
+       _VALID_URL = r'^http://video\.xnxx\.com/video([0-9]+)/(.*)'
+       IE_NAME = u'xnxx'
+       VIDEO_URL_RE = r'flv_url=(.*?)&amp;'
+       VIDEO_TITLE_RE = r'<title>(.*?)\s+-\s+XNXX.COM'
+       VIDEO_THUMB_RE = r'url_bigthumb=(.*?)&amp;'
+       def report_webpage(self, video_id):
+               """Report information extraction"""
+               self._downloader.to_screen(u'[%s] %s: Downloading webpage' % (self.IE_NAME, video_id))
+       def report_extraction(self, video_id):
+               """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:
+                       self._downloader.trouble(u'ERROR: invalid URL: %s' % url)
+                       return
+               video_id = mobj.group(1).decode('utf-8')
+               self.report_webpage(video_id)
+               # Get webpage content
+               try:
+                       webpage = urllib2.urlopen(url).read()
+               except (urllib2.URLError, httplib.HTTPException, socket.error), err:
+                       self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % err)
+                       return
+               info = {'id': video_id,
+                               'url': self.extract_video_url(webpage),
+                               'uploader': None,
+                               'upload_date': None,
+                               'title': self.extract_video_title(webpage),
+                               'ext': 'flv',
+                               'format': 'flv',
+                               'thumbnail': self.extract_video_thumbnail(webpage),
+                               'description': None,
+                               'player_url': None}
++              return [info]
diff --combined youtube_dl/__init__.py
index 0122f725ab5e3fc3664cab610f608930cbbb53be,0a6a5d35c2e4428460d8d5e20174de694394e621..0f9d73c464155ef122ffbcf9cb93e3a074229d62
@@@ -19,7 -19,7 +19,7 @@@ __authors__  = 
        )
  
  __license__ = 'Public Domain'
 -__version__ = '2012.02.27'
 +__version__ = '2012.09.27'
  
  UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl'
  UPDATE_URL_VERSION = 'https://raw.github.com/rg3/youtube-dl/master/LATEST_VERSION'
@@@ -351,6 -351,7 +351,7 @@@ def gen_extractors()
                MixcloudIE(),
                StanfordOpenClassroomIE(),
                MTVIE(),
+               XNXXIE(),
  
                GenericIE()
        ]