about summary refs log tree commit diff
path: root/youtube_dl/extractor/xvideos.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-06-23 21:11:47 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2013-06-23 21:11:47 +0200
commitcbf46c737c3f4156dee019b70521dcd3194877ac (patch)
tree59298f69374e85ad1173971ab5893efda6904bba /youtube_dl/extractor/xvideos.py
parent7beb36a52974a2cf7c8b00ba1da339f4f3de3abc (diff)
downloadyoutube-dl-cbf46c737c3f4156dee019b70521dcd3194877ac.tar.gz
youtube-dl-cbf46c737c3f4156dee019b70521dcd3194877ac.tar.xz
youtube-dl-cbf46c737c3f4156dee019b70521dcd3194877ac.zip
Move XVideos IE into its own file (and simplify it a bit)
Diffstat (limited to 'youtube_dl/extractor/xvideos.py')
-rw-r--r--youtube_dl/extractor/xvideos.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py
new file mode 100644
index 000000000..8b3cb3930
--- /dev/null
+++ b/youtube_dl/extractor/xvideos.py
@@ -0,0 +1,43 @@
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+    compat_urllib_parse,
+)
+
+
+class XVideosIE(InfoExtractor):
+    _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
+
+    def _real_extract(self, url):
+        mobj = re.match(self._VALID_URL, url)
+        video_id = mobj.group(1)
+
+        webpage = self._download_webpage(url, video_id)
+
+        self.report_extraction(video_id)
+
+        # Extract video URL
+        video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
+            webpage, u'video URL'))
+
+        # Extract title
+        video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
+            webpage, u'title')
+
+        # Extract video thumbnail
+        video_thumbnail = self._search_regex(r'http://(?:img.*?\.)xvideos.com/videos/thumbs/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/([a-fA-F0-9.]+jpg)',
+            webpage, u'thumbnail', fatal=False)
+
+        info = {
+            'id': video_id,
+            'url': video_url,
+            'uploader': None,
+            'upload_date': None,
+            'title': video_title,
+            'ext': 'flv',
+            'thumbnail': video_thumbnail,
+            'description': None,
+        }
+
+        return [info]