[xxxymovies] new ectractor
[youtube-dl] / youtube_dl / extractor / xxxymovies.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7     parse_duration,
8     int_or_none,
9 )
10
11
12 class XXXYMoviesIE(InfoExtractor):
13     _VALID_URL = r'https?://(?:www\.)?xxxymovies\.com/videos/(?P<id>\d+)/(?P<display_id>[^/]+)'
14     _TEST = {
15         'url': 'http://xxxymovies.com/videos/138669/ecstatic-orgasm-sofcore/',
16         'md5': '810b1bdbbffff89dd13bdb369fe7be4b',
17         'info_dict': {
18             'id': '138669',
19             'display_id': 'ecstatic-orgasm-sofcore',
20             'ext': 'mp4',
21             'title': 'Ecstatic Orgasm Sofcore',
22             'duration': 931,
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('id')
31         display_id = mobj.group('display_id')
32
33         webpage = self._download_webpage(url, video_id)
34
35         video_url = self._html_search_regex(
36             r"video_url\s*:\s*'([^']+)'", webpage, 'video URL')
37
38         title = self._html_search_regex(
39             r'<title>(.*?)\s*-\s*XXXYMovies.com</title>', webpage, 'title')
40
41         thumbnail = self._html_search_regex(
42             r'preview_url\s*:\s*\'(.*?)\'', webpage, 'thumbnail', fatal=False)
43
44         categories = self._html_search_meta(
45             'keywords', webpage, 'categories', default='').split(',')
46
47         duration = parse_duration(self._search_regex(
48             r'<span>Duration:</span>\s*(\d+:\d+)', webpage, 'duration', fatal=False))
49
50         view_count = int_or_none(self._html_search_regex(
51             r'<div class="video_views">\s*(\d+)', webpage, 'view count', fatal=False))
52
53         return {
54             'id': video_id,
55             'display_id': display_id,
56             'url': video_url,
57             'title': title,
58             'thumbnail': thumbnail,
59             'categories': categories,
60             'duration': duration,
61             'view_count': view_count,
62             'age_limit': 18,
63         }