]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/alphaporno.py
debian/changelog: Annotate with bug being closed.
[youtubedl] / youtube_dl / extractor / alphaporno.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 parse_iso8601,
6 parse_duration,
7 parse_filesize,
8 int_or_none,
9 )
10
11
12 class AlphaPornoIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P<id>[^/]+)'
14 _TEST = {
15 'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/',
16 'md5': 'feb6d3bba8848cd54467a87ad34bd38e',
17 'info_dict': {
18 'id': '258807',
19 'display_id': 'sensual-striptease-porn-with-samantha-alexandra',
20 'ext': 'mp4',
21 'title': 'Sensual striptease porn with Samantha Alexandra',
22 'thumbnail': r're:https?://.*\.jpg$',
23 'timestamp': 1418694611,
24 'upload_date': '20141216',
25 'duration': 387,
26 'filesize_approx': 54120000,
27 'tbr': 1145,
28 'categories': list,
29 'age_limit': 18,
30 }
31 }
32
33 def _real_extract(self, url):
34 display_id = self._match_id(url)
35
36 webpage = self._download_webpage(url, display_id)
37
38 video_id = self._search_regex(
39 r"video_id\s*:\s*'([^']+)'", webpage, 'video id', default=None)
40
41 video_url = self._search_regex(
42 r"video_url\s*:\s*'([^']+)'", webpage, 'video url')
43 ext = self._html_search_meta(
44 'encodingFormat', webpage, 'ext', default='.mp4')[1:]
45
46 title = self._search_regex(
47 [r'<meta content="([^"]+)" itemprop="description">',
48 r'class="title" itemprop="name">([^<]+)<'],
49 webpage, 'title')
50 thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail')
51 timestamp = parse_iso8601(self._html_search_meta(
52 'uploadDate', webpage, 'upload date'))
53 duration = parse_duration(self._html_search_meta(
54 'duration', webpage, 'duration'))
55 filesize_approx = parse_filesize(self._html_search_meta(
56 'contentSize', webpage, 'file size'))
57 bitrate = int_or_none(self._html_search_meta(
58 'bitrate', webpage, 'bitrate'))
59 categories = self._html_search_meta(
60 'keywords', webpage, 'categories', default='').split(',')
61
62 age_limit = self._rta_search(webpage)
63
64 return {
65 'id': video_id,
66 'display_id': display_id,
67 'url': video_url,
68 'ext': ext,
69 'title': title,
70 'thumbnail': thumbnail,
71 'timestamp': timestamp,
72 'duration': duration,
73 'filesize_approx': filesize_approx,
74 'tbr': bitrate,
75 'categories': categories,
76 'age_limit': age_limit,
77 }