aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2012-09-27 18:55:56 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2012-09-27 18:55:56 +0200
commitebe3f89ea45dc74bbadab10acc27ebf91ddbb736 (patch)
treef7b4703a7ef73c1d4812c0fb2fa4ee398e5bde7b /youtube_dl
parentb5de8af234789e3a202de30a6d9b05c95fe82910 (diff)
parent154b55dae3e611e05b9ae1762f59467d753338c4 (diff)
downloadyoutube-dl-ebe3f89ea45dc74bbadab10acc27ebf91ddbb736.tar.xz
Merge xnxx.com Support (NSFW). Test URL (SFW): http://video.xnxx.com/video1443330/youtube-dl_testvid_a_and_9829_._and_amp_and_38_
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/InfoExtractors.py70
-rw-r--r--youtube_dl/__init__.py1
2 files changed, 71 insertions, 0 deletions
diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py
index 8dd1c0b07..56003df26 100644
--- a/youtube_dl/InfoExtractors.py
+++ b/youtube_dl/InfoExtractors.py
@@ -2955,3 +2955,73 @@ class MTVIE(InfoExtractor):
}
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 --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 0122f725a..0f9d73c46 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -351,6 +351,7 @@ def gen_extractors():
MixcloudIE(),
StanfordOpenClassroomIE(),
MTVIE(),
+ XNXXIE(),
GenericIE()
]