]>
Commit | Line | Data |
---|---|---|
b4a190fe S |
1 | import re |
2 | ||
570fa151 | 3 | from .common import InfoExtractor |
b4a190fe S |
4 | from ..utils import ( |
5 | determine_ext, | |
6 | int_or_none, | |
7 | NO_DEFAULT, | |
8 | str_to_int, | |
9 | ) | |
570fa151 PH |
10 | |
11 | ||
12 | class XNXXIE(InfoExtractor): | |
ab2579bb | 13 | _VALID_URL = r'https?://(?:video|www)\.xnxx3?\.com/video-?(?P<id>[0-9a-z]+)/' |
73843ae8 | 14 | _TESTS = [{ |
97674f04 | 15 | 'url': 'http://www.xnxx.com/video-55awb78/skyrim_test_video', |
b4a190fe | 16 | 'md5': '7583e96c15c0f21e9da3453d9920fbba', |
bdebf51c | 17 | 'info_dict': { |
97674f04 | 18 | 'id': '55awb78', |
b4a190fe | 19 | 'ext': 'mp4', |
97674f04 | 20 | 'title': 'Skyrim Test Video', |
b4a190fe S |
21 | 'thumbnail': r're:^https?://.*\.jpg', |
22 | 'duration': 469, | |
23 | 'view_count': int, | |
bdebf51c | 24 | 'age_limit': 18, |
73843ae8 | 25 | }, |
26 | }, { | |
27 | 'url': 'http://video.xnxx.com/video1135332/lida_naked_funny_actress_5_', | |
28 | 'only_matching': True, | |
adf1921d S |
29 | }, { |
30 | 'url': 'http://www.xnxx.com/video-55awb78/', | |
31 | 'only_matching': True, | |
ab2579bb D |
32 | }, { |
33 | 'url': 'http://www.xnxx3.com/video-55awb78/', | |
34 | 'only_matching': True, | |
73843ae8 | 35 | }] |
570fa151 PH |
36 | |
37 | def _real_extract(self, url): | |
1cc79574 | 38 | video_id = self._match_id(url) |
b4a190fe | 39 | |
570fa151 PH |
40 | webpage = self._download_webpage(url, video_id) |
41 | ||
b4a190fe S |
42 | def get(meta, default=NO_DEFAULT, fatal=True): |
43 | return self._search_regex( | |
44 | r'set%s\s*\(\s*(["\'])(?P<value>(?:(?!\1).)+)\1' % meta, | |
45 | webpage, meta, default=default, fatal=fatal, group='value') | |
46 | ||
47 | title = self._og_search_title( | |
48 | webpage, default=None) or get('VideoTitle') | |
570fa151 | 49 | |
b4a190fe S |
50 | formats = [] |
51 | for mobj in re.finditer( | |
52 | r'setVideo(?:Url(?P<id>Low|High)|HLS)\s*\(\s*(?P<q>["\'])(?P<url>(?:https?:)?//.+?)(?P=q)', webpage): | |
53 | format_url = mobj.group('url') | |
54 | if determine_ext(format_url) == 'm3u8': | |
55 | formats.extend(self._extract_m3u8_formats( | |
56 | format_url, video_id, 'mp4', entry_protocol='m3u8_native', | |
f983b875 | 57 | quality=1, m3u8_id='hls', fatal=False)) |
b4a190fe S |
58 | else: |
59 | format_id = mobj.group('id') | |
60 | if format_id: | |
61 | format_id = format_id.lower() | |
62 | formats.append({ | |
63 | 'url': format_url, | |
64 | 'format_id': format_id, | |
65 | 'quality': -1 if format_id == 'low' else 0, | |
66 | }) | |
67 | self._sort_formats(formats) | |
570fa151 | 68 | |
b4a190fe S |
69 | thumbnail = self._og_search_thumbnail(webpage, default=None) or get( |
70 | 'ThumbUrl', fatal=False) or get('ThumbUrl169', fatal=False) | |
71 | duration = int_or_none(self._og_search_property('duration', webpage)) | |
72 | view_count = str_to_int(self._search_regex( | |
73 | r'id=["\']nb-views-number[^>]+>([\d,.]+)', webpage, 'view count', | |
74 | default=None)) | |
570fa151 | 75 | |
bdebf51c | 76 | return { |
570fa151 | 77 | 'id': video_id, |
b4a190fe S |
78 | 'title': title, |
79 | 'thumbnail': thumbnail, | |
80 | 'duration': duration, | |
81 | 'view_count': view_count, | |
8e590a11 | 82 | 'age_limit': 18, |
b4a190fe | 83 | 'formats': formats, |
bdebf51c | 84 | } |