]>
Commit | Line | Data |
---|---|---|
ac563359 S |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
9bae185b S |
4 | import re |
5 | ||
ac563359 S |
6 | from .common import InfoExtractor |
7 | from ..utils import ( | |
8 | parse_iso8601, | |
9 | int_or_none, | |
128eb31d S |
10 | xpath_attr, |
11 | xpath_element, | |
ac563359 S |
12 | ) |
13 | ||
14 | ||
15 | class TwentyFourVideoIE(InfoExtractor): | |
16 | IE_NAME = '24video' | |
f4cc2ca5 S |
17 | _VALID_URL = r'''(?x) |
18 | https?:// | |
19 | (?P<host> | |
19a107f2 AG |
20 | (?:(?:www|porno)\.)?24video\. |
21 | (?:net|me|xxx|sexy?|tube|adult|site) | |
f4cc2ca5 S |
22 | )/ |
23 | (?: | |
24 | video/(?:(?:view|xml)/)?| | |
25 | player/new24_play\.swf\?id= | |
26 | ) | |
27 | (?P<id>\d+) | |
28 | ''' | |
ac563359 | 29 | |
c366f8d3 S |
30 | _TESTS = [{ |
31 | 'url': 'http://www.24video.net/video/view/1044982', | |
32 | 'md5': 'e09fc0901d9eaeedac872f154931deeb', | |
33 | 'info_dict': { | |
34 | 'id': '1044982', | |
35 | 'ext': 'mp4', | |
36 | 'title': 'Эротика каменного века', | |
37 | 'description': 'Как смотрели порно в каменном веке.', | |
ec85ded8 | 38 | 'thumbnail': r're:^https?://.*\.jpg$', |
c366f8d3 S |
39 | 'uploader': 'SUPERTELO', |
40 | 'duration': 31, | |
41 | 'timestamp': 1275937857, | |
42 | 'upload_date': '20100607', | |
43 | 'age_limit': 18, | |
44 | 'like_count': int, | |
45 | 'dislike_count': int, | |
ac563359 | 46 | }, |
c366f8d3 S |
47 | }, { |
48 | 'url': 'http://www.24video.net/player/new24_play.swf?id=1044982', | |
49 | 'only_matching': True, | |
50 | }, { | |
51 | 'url': 'http://www.24video.me/video/view/1044982', | |
52 | 'only_matching': True, | |
71e9577b S |
53 | }, { |
54 | 'url': 'http://www.24video.tube/video/view/2363750', | |
55 | 'only_matching': True, | |
11ec06de S |
56 | }, { |
57 | 'url': 'https://www.24video.site/video/view/2640421', | |
58 | 'only_matching': True, | |
f4cc2ca5 S |
59 | }, { |
60 | 'url': 'https://porno.24video.net/video/2640421-vsya-takaya-gibkaya-i-v-masle', | |
61 | 'only_matching': True, | |
c366f8d3 | 62 | }] |
ac563359 S |
63 | |
64 | def _real_extract(self, url): | |
9bae185b S |
65 | mobj = re.match(self._VALID_URL, url) |
66 | video_id = mobj.group('id') | |
67 | host = mobj.group('host') | |
ac563359 S |
68 | |
69 | webpage = self._download_webpage( | |
9bae185b | 70 | 'http://%s/video/view/%s' % (host, video_id), video_id) |
ac563359 S |
71 | |
72 | title = self._og_search_title(webpage) | |
73 | description = self._html_search_regex( | |
f6e588af S |
74 | r'<(p|span)[^>]+itemprop="description"[^>]*>(?P<description>[^<]+)</\1>', |
75 | webpage, 'description', fatal=False, group='description') | |
ac563359 S |
76 | thumbnail = self._og_search_thumbnail(webpage) |
77 | duration = int_or_none(self._og_search_property( | |
78 | 'duration', webpage, 'duration', fatal=False)) | |
79 | timestamp = parse_iso8601(self._search_regex( | |
e3440d82 S |
80 | r'<time[^>]+\bdatetime="([^"]+)"[^>]+itemprop="uploadDate"', |
81 | webpage, 'upload date', fatal=False)) | |
ac563359 S |
82 | |
83 | uploader = self._html_search_regex( | |
687cb3ad | 84 | r'class="video-uploaded"[^>]*>\s*<a href="/jsecUser/movies/[^"]+"[^>]*>([^<]+)</a>', |
ac563359 S |
85 | webpage, 'uploader', fatal=False) |
86 | ||
87 | view_count = int_or_none(self._html_search_regex( | |
88 | r'<span class="video-views">(\d+) просмотр', | |
89 | webpage, 'view count', fatal=False)) | |
90 | comment_count = int_or_none(self._html_search_regex( | |
bd6fb007 | 91 | r'<a[^>]+href="#tab-comments"[^>]*>(\d+) комментари', |
e3440d82 | 92 | webpage, 'comment count', default=None)) |
ac563359 | 93 | |
747b0284 S |
94 | # Sets some cookies |
95 | self._download_xml( | |
9bae185b | 96 | r'http://%s/video/xml/%s?mode=init' % (host, video_id), |
747b0284 | 97 | video_id, 'Downloading init XML') |
ac563359 | 98 | |
128eb31d | 99 | video_xml = self._download_xml( |
9bae185b | 100 | 'http://%s/video/xml/%s?mode=play' % (host, video_id), |
128eb31d S |
101 | video_id, 'Downloading video XML') |
102 | ||
103 | video = xpath_element(video_xml, './/video', 'video', fatal=True) | |
ac563359 | 104 | |
747b0284 | 105 | formats = [{ |
128eb31d | 106 | 'url': xpath_attr(video, '', 'url', 'video URL', fatal=True), |
747b0284 | 107 | }] |
ac563359 | 108 | |
747b0284 S |
109 | like_count = int_or_none(video.get('ratingPlus')) |
110 | dislike_count = int_or_none(video.get('ratingMinus')) | |
111 | age_limit = 18 if video.get('adult') == 'true' else 0 | |
ac563359 S |
112 | |
113 | return { | |
114 | 'id': video_id, | |
115 | 'title': title, | |
116 | 'description': description, | |
117 | 'thumbnail': thumbnail, | |
118 | 'uploader': uploader, | |
119 | 'duration': duration, | |
120 | 'timestamp': timestamp, | |
121 | 'view_count': view_count, | |
122 | 'comment_count': comment_count, | |
123 | 'like_count': like_count, | |
124 | 'dislike_count': dislike_count, | |
125 | 'age_limit': age_limit, | |
126 | 'formats': formats, | |
127 | } |