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