]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/eporner.py
[dailymotion] Error spelling
[youtube-dl] / youtube_dl / extractor / eporner.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8     parse_duration,
9     str_to_int,
10 )
11
12
13 class EpornerIE(InfoExtractor):
14     _VALID_URL = r'https?://(?:www\.)?eporner\.com/hd-porn/(?P<id>\d+)/(?P<display_id>[\w-]+)'
15     _TEST = {
16         'url': 'http://www.eporner.com/hd-porn/95008/Infamous-Tiffany-Teen-Strip-Tease-Video/',
17         'md5': '39d486f046212d8e1b911c52ab4691f8',
18         'info_dict': {
19             'id': '95008',
20             'display_id': 'Infamous-Tiffany-Teen-Strip-Tease-Video',
21             'ext': 'mp4',
22             'title': 'Infamous Tiffany Teen Strip Tease Video',
23             'duration': 1838,
24             'view_count': int,
25             'age_limit': 18,
26         }
27     }
28
29     def _real_extract(self, url):
30         mobj = re.match(self._VALID_URL, url)
31         video_id = mobj.group('id')
32         display_id = mobj.group('display_id')
33
34         webpage = self._download_webpage(url, display_id)
35         title = self._html_search_regex(
36             r'<title>(.*?) - EPORNER', webpage, 'title')
37
38         redirect_url = 'http://www.eporner.com/config5/%s' % video_id
39         player_code = self._download_webpage(
40             redirect_url, display_id, note='Downloading player config')
41
42         sources = self._search_regex(
43             r'(?s)sources\s*:\s*\[\s*({.+?})\s*\]', player_code, 'sources')
44
45         formats = []
46         for video_url, format_id in re.findall(r'file\s*:\s*"([^"]+)",\s*label\s*:\s*"([^"]+)"', sources):
47             fmt = {
48                 'url': video_url,
49                 'format_id': format_id,
50             }
51             m = re.search(r'^(\d+)', format_id)
52             if m:
53                 fmt['height'] = int(m.group(1))
54             formats.append(fmt)
55         self._sort_formats(formats)
56
57         duration = parse_duration(self._html_search_meta('duration', webpage))
58         view_count = str_to_int(self._search_regex(
59             r'id="cinemaviews">\s*([0-9,]+)\s*<small>views',
60             webpage, 'view count', fatal=False))
61
62         return {
63             'id': video_id,
64             'display_id': display_id,
65             'title': title,
66             'duration': duration,
67             'view_count': view_count,
68             'formats': formats,
69             'age_limit': 18,
70         }