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