]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/pornotube.py
Merge tag 'upstream/2013.12.23'
[youtubedl] / youtube_dl / extractor / pornotube.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 compat_urllib_parse,
6
7 unified_strdate,
8 )
9
10
11 class PornotubeIE(InfoExtractor):
12 _VALID_URL = r'^(?:https?://)?(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
13 _TEST = {
14 u'url': u'http://pornotube.com/c/173/m/1689755/Marilyn-Monroe-Bathing',
15 u'file': u'1689755.flv',
16 u'md5': u'374dd6dcedd24234453b295209aa69b6',
17 u'info_dict': {
18 u"upload_date": u"20090708",
19 u"title": u"Marilyn-Monroe-Bathing",
20 u"age_limit": 18
21 }
22 }
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26
27 video_id = mobj.group('videoid')
28 video_title = mobj.group('title')
29
30 # Get webpage content
31 webpage = self._download_webpage(url, video_id)
32
33 # Get the video URL
34 VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
35 video_url = self._search_regex(VIDEO_URL_RE, webpage, u'video url')
36 video_url = compat_urllib_parse.unquote(video_url)
37
38 #Get the uploaded date
39 VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
40 upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, u'upload date', fatal=False)
41 if upload_date: upload_date = unified_strdate(upload_date)
42 age_limit = self._rta_search(webpage)
43
44 info = {'id': video_id,
45 'url': video_url,
46 'uploader': None,
47 'upload_date': upload_date,
48 'title': video_title,
49 'ext': 'flv',
50 'format': 'flv',
51 'age_limit': age_limit}
52
53 return [info]