]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/anysex.py
Initiate new release.
[youtubedl] / youtube_dl / extractor / anysex.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 AnySexIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?anysex\.com/(?P<id>\d+)'
14 _TEST = {
15 'url': 'http://anysex.com/156592/',
16 'md5': '023e9fbb7f7987f5529a394c34ad3d3d',
17 'info_dict': {
18 'id': '156592',
19 'ext': 'mp4',
20 'title': 'Busty and sexy blondie in her bikini strips for you',
21 'description': 'md5:de9e418178e2931c10b62966474e1383',
22 'categories': ['Erotic'],
23 'duration': 270,
24 'age_limit': 18,
25 }
26 }
27
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 video_id = mobj.group('id')
31
32 webpage = self._download_webpage(url, video_id)
33
34 video_url = self._html_search_regex(r"video_url\s*:\s*'([^']+)'", webpage, 'video URL')
35
36 title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
37 description = self._html_search_regex(
38 r'<div class="description"[^>]*>([^<]+)</div>', webpage, 'description', fatal=False)
39 thumbnail = self._html_search_regex(
40 r'preview_url\s*:\s*\'(.*?)\'', webpage, 'thumbnail', fatal=False)
41
42 categories = re.findall(
43 r'<a href="http://anysex\.com/categories/[^"]+" title="[^"]*">([^<]+)</a>', webpage)
44
45 duration = parse_duration(self._search_regex(
46 r'<b>Duration:</b> (?:<q itemprop="duration">)?(\d+:\d+)', webpage, 'duration', fatal=False))
47 view_count = int_or_none(self._html_search_regex(
48 r'<b>Views:</b> (\d+)', webpage, 'view count', fatal=False))
49
50 return {
51 'id': video_id,
52 'url': video_url,
53 'ext': 'mp4',
54 'title': title,
55 'description': description,
56 'thumbnail': thumbnail,
57 'categories': categories,
58 'duration': duration,
59 'view_count': view_count,
60 'age_limit': 18,
61 }