]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/pornotube.py
Prepare for release.
[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 }
21 }
22
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url)
25
26 video_id = mobj.group('videoid')
27 video_title = mobj.group('title')
28
29 # Get webpage content
30 webpage = self._download_webpage(url, video_id)
31
32 # Get the video URL
33 VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
34 video_url = self._search_regex(VIDEO_URL_RE, webpage, u'video url')
35 video_url = compat_urllib_parse.unquote(video_url)
36
37 #Get the uploaded date
38 VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
39 upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, u'upload date', fatal=False)
40 if upload_date: upload_date = unified_strdate(upload_date)
41
42 info = {'id': video_id,
43 'url': video_url,
44 'uploader': None,
45 'upload_date': upload_date,
46 'title': video_title,
47 'ext': 'flv',
48 'format': 'flv'}
49
50 return [info]