]>
Commit | Line | Data |
---|---|---|
3c50b99a PH |
1 | from __future__ import unicode_literals |
2 | ||
32a35e44 | 3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
1cc79574 | 6 | from ..utils import ( |
50506cb6 | 7 | int_or_none, |
5c2266df | 8 | sanitized_Request, |
2f9e8776 | 9 | str_to_int, |
32a35e44 | 10 | ) |
11 | ||
3c50b99a | 12 | |
32a35e44 | 13 | class ExtremeTubeIE(InfoExtractor): |
cc8034cc | 14 | _VALID_URL = r'https?://(?:www\.)?extremetube\.com/(?:[^/]+/)?video/(?P<id>[^/#?&]+)' |
52fadd5f | 15 | _TESTS = [{ |
3c50b99a | 16 | 'url': 'http://www.extremetube.com/video/music-video-14-british-euro-brit-european-cumshots-swallow-652431', |
c2ebea65 | 17 | 'md5': '344d0c6d50e2f16b06e49ca011d8ac69', |
3c50b99a | 18 | 'info_dict': { |
cc8034cc | 19 | 'id': 'music-video-14-british-euro-brit-european-cumshots-swallow-652431', |
3c50b99a PH |
20 | 'ext': 'mp4', |
21 | 'title': 'Music Video 14 british euro brit european cumshots swallow', | |
22 | 'uploader': 'unknown', | |
2f9e8776 | 23 | 'view_count': int, |
3c50b99a | 24 | 'age_limit': 18, |
32a35e44 | 25 | } |
52fadd5f PH |
26 | }, { |
27 | 'url': 'http://www.extremetube.com/gay/video/abcde-1234', | |
28 | 'only_matching': True, | |
cc8034cc S |
29 | }, { |
30 | 'url': 'http://www.extremetube.com/video/latina-slut-fucked-by-fat-black-dick', | |
31 | 'only_matching': True, | |
32 | }, { | |
33 | 'url': 'http://www.extremetube.com/video/652431', | |
34 | 'only_matching': True, | |
52fadd5f | 35 | }] |
32a35e44 | 36 | |
37 | def _real_extract(self, url): | |
cc8034cc | 38 | video_id = self._match_id(url) |
32a35e44 | 39 | |
5c2266df | 40 | req = sanitized_Request(url) |
32a35e44 | 41 | req.add_header('Cookie', 'age_verified=1') |
42 | webpage = self._download_webpage(req, video_id) | |
43 | ||
3c50b99a | 44 | video_title = self._html_search_regex( |
9c7b79ac | 45 | r'<h1 [^>]*?title="([^"]+)"[^>]*>', webpage, 'title') |
3c50b99a | 46 | uploader = self._html_search_regex( |
2f9e8776 S |
47 | r'Uploaded by:\s*</strong>\s*(.+?)\s*</div>', |
48 | webpage, 'uploader', fatal=False) | |
49 | view_count = str_to_int(self._html_search_regex( | |
50 | r'Views:\s*</strong>\s*<span>([\d,\.]+)</span>', | |
51 | webpage, 'view count', fatal=False)) | |
52 | ||
50506cb6 S |
53 | flash_vars = self._parse_json( |
54 | self._search_regex( | |
55 | r'var\s+flashvars\s*=\s*({.+?});', webpage, 'flash vars'), | |
56 | video_id) | |
c2ebea65 NJ |
57 | |
58 | formats = [] | |
50506cb6 S |
59 | for quality_key, video_url in flash_vars.items(): |
60 | height = int_or_none(self._search_regex( | |
61 | r'quality_(\d+)[pP]$', quality_key, 'height', default=None)) | |
62 | if not height: | |
63 | continue | |
64 | f = { | |
65 | 'url': video_url, | |
66 | } | |
67 | mobj = re.search( | |
68 | r'/(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+', video_url) | |
69 | if mobj: | |
70 | height = int(mobj.group('height')) | |
71 | bitrate = int(mobj.group('bitrate')) | |
72 | f.update({ | |
73 | 'format_id': '%dp-%dk' % (height, bitrate), | |
74 | 'height': height, | |
75 | 'tbr': bitrate, | |
c2ebea65 | 76 | }) |
50506cb6 S |
77 | else: |
78 | f.update({ | |
79 | 'format_id': '%dp' % height, | |
80 | 'height': height, | |
81 | }) | |
82 | formats.append(f) | |
c2ebea65 | 83 | self._sort_formats(formats) |
32a35e44 | 84 | |
32a35e44 | 85 | return { |
86 | 'id': video_id, | |
87 | 'title': video_title, | |
c2ebea65 | 88 | 'formats': formats, |
32a35e44 | 89 | 'uploader': uploader, |
2f9e8776 | 90 | 'view_count': view_count, |
86ad94bb | 91 | 'age_limit': 18, |
32a35e44 | 92 | } |