]>
Commit | Line | Data |
---|---|---|
030dfb04 S |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
7 | from ..utils import ( | |
8 | int_or_none, | |
9 | parse_age_limit, | |
10 | parse_iso8601, | |
11 | xpath_text, | |
12 | ) | |
13 | ||
14 | ||
15 | class VideomoreIE(InfoExtractor): | |
69759a59 | 16 | IE_NAME = 'videomore' |
030dfb04 S |
17 | _VALID_URL = r'videomore:(?P<sid>\d+)$|https?://videomore\.ru/(?:(?:embed|[^/]+/[^/]+)/|[^/]+\?.*\btrack_id=)(?P<id>\d+)(?:[/?#&]|\.(?:xml|json)|$)' |
18 | _TESTS = [{ | |
19 | 'url': 'http://videomore.ru/kino_v_detalayah/5_sezon/367617', | |
20 | 'md5': '70875fbf57a1cd004709920381587185', | |
21 | 'info_dict': { | |
22 | 'id': '367617', | |
23 | 'ext': 'flv', | |
24 | 'title': 'В гостях Алексей Чумаков и Юлия Ковальчук', | |
25 | 'description': 'В гостях – лучшие романтические комедии года, «Выживший» Иньярриту и «Стив Джобс» Дэнни Бойла.', | |
7a0b07c7 S |
26 | 'series': 'Кино в деталях', |
27 | 'episode': 'В гостях Алексей Чумаков и Юлия Ковальчук', | |
306c51c6 | 28 | 'episode_number': None, |
7a0b07c7 | 29 | 'season': 'Сезон 2015', |
306c51c6 | 30 | 'season_number': 5, |
030dfb04 S |
31 | 'thumbnail': 're:^https?://.*\.jpg', |
32 | 'duration': 2910, | |
33 | 'age_limit': 16, | |
34 | 'view_count': int, | |
35 | }, | |
7a0b07c7 S |
36 | }, { |
37 | 'url': 'http://videomore.ru/embed/259974', | |
38 | 'info_dict': { | |
39 | 'id': '259974', | |
40 | 'ext': 'flv', | |
41 | 'title': '80 серия', | |
42 | 'description': '«Медведей» ждет решающий матч. Макеев выясняет отношения со Стрельцовым. Парни узнают подробности прошлого Макеева.', | |
43 | 'series': 'Молодежка', | |
44 | 'episode': '80 серия', | |
306c51c6 | 45 | 'episode_number': 40, |
7a0b07c7 | 46 | 'season': '2 сезон', |
306c51c6 | 47 | 'season_number': 2, |
7a0b07c7 S |
48 | 'thumbnail': 're:^https?://.*\.jpg', |
49 | 'duration': 2809, | |
50 | 'age_limit': 16, | |
51 | 'view_count': int, | |
52 | }, | |
53 | 'params': { | |
54 | 'skip_download': True, | |
55 | }, | |
56 | }, { | |
57 | 'url': 'http://videomore.ru/molodezhka/sezon_promo/341073', | |
58 | 'info_dict': { | |
59 | 'id': '341073', | |
60 | 'ext': 'flv', | |
61 | 'title': 'Команда проиграла из-за Бакина?', | |
62 | 'description': 'Молодежка 3 сезон скоро', | |
63 | 'series': 'Молодежка', | |
64 | 'episode': 'Команда проиграла из-за Бакина?', | |
306c51c6 | 65 | 'episode_number': None, |
7a0b07c7 | 66 | 'season': 'Промо', |
306c51c6 | 67 | 'season_number': 99, |
7a0b07c7 S |
68 | 'thumbnail': 're:^https?://.*\.jpg', |
69 | 'duration': 29, | |
70 | 'age_limit': 16, | |
71 | 'view_count': int, | |
72 | }, | |
73 | 'params': { | |
74 | 'skip_download': True, | |
75 | }, | |
030dfb04 S |
76 | }, { |
77 | 'url': 'http://videomore.ru/elki_3?track_id=364623', | |
78 | 'only_matching': True, | |
79 | }, { | |
80 | 'url': 'http://videomore.ru/embed/364623', | |
81 | 'only_matching': True, | |
82 | }, { | |
83 | 'url': 'http://videomore.ru/video/tracks/364623.xml', | |
84 | 'only_matching': True, | |
85 | }, { | |
86 | 'url': 'http://videomore.ru/video/tracks/364623.json', | |
87 | 'only_matching': True, | |
88 | }, { | |
89 | 'url': 'http://videomore.ru/video/tracks/158031/quotes/33248', | |
90 | 'only_matching': True, | |
91 | }, { | |
92 | 'url': 'videomore:367617', | |
93 | 'only_matching': True, | |
94 | }] | |
95 | ||
96 | @staticmethod | |
97 | def _extract_url(webpage): | |
98 | mobj = re.search( | |
99 | r'<object[^>]+data=(["\'])https?://videomore.ru/player\.swf\?.*config=(?P<url>https?://videomore\.ru/(?:[^/]+/)+\d+\.xml).*\1', | |
100 | webpage) | |
101 | if mobj: | |
102 | return mobj.group('url') | |
103 | ||
104 | def _real_extract(self, url): | |
105 | mobj = re.match(self._VALID_URL, url) | |
106 | video_id = mobj.group('sid') or mobj.group('id') | |
107 | ||
108 | video = self._download_xml( | |
109 | 'http://videomore.ru/video/tracks/%s.xml' % video_id, | |
110 | video_id, 'Downloading video XML') | |
111 | ||
112 | video_url = xpath_text(video, './/video_url', 'video url', fatal=True) | |
113 | formats = self._extract_f4m_formats(video_url, video_id, f4m_id='hds') | |
19dbaeec | 114 | self._sort_formats(formats) |
030dfb04 S |
115 | |
116 | data = self._download_json( | |
117 | 'http://videomore.ru/video/tracks/%s.json' % video_id, | |
4340727e | 118 | video_id, 'Downloading video JSON') |
030dfb04 S |
119 | |
120 | title = data.get('title') or data['project_title'] | |
121 | description = data.get('description') or data.get('description_raw') | |
122 | timestamp = parse_iso8601(data.get('published_at')) | |
123 | duration = int_or_none(data.get('duration')) | |
124 | view_count = int_or_none(data.get('views')) | |
125 | age_limit = parse_age_limit(data.get('min_age')) | |
126 | thumbnails = [{ | |
127 | 'url': thumbnail, | |
128 | } for thumbnail in data.get('big_thumbnail_urls', [])] | |
129 | ||
7a0b07c7 S |
130 | series = data.get('project_title') |
131 | episode = data.get('title') | |
306c51c6 | 132 | episode_number = int_or_none(data.get('episode_of_season') or None) |
7a0b07c7 | 133 | season = data.get('season_title') |
306c51c6 | 134 | season_number = int_or_none(data.get('season_pos') or None) |
7a0b07c7 | 135 | |
030dfb04 S |
136 | return { |
137 | 'id': video_id, | |
138 | 'title': title, | |
139 | 'description': description, | |
7a0b07c7 S |
140 | 'series': series, |
141 | 'episode': episode, | |
306c51c6 | 142 | 'episode_number': episode_number, |
7a0b07c7 | 143 | 'season': season, |
306c51c6 | 144 | 'season_number': season_number, |
030dfb04 S |
145 | 'thumbnails': thumbnails, |
146 | 'timestamp': timestamp, | |
147 | 'duration': duration, | |
148 | 'view_count': view_count, | |
149 | 'age_limit': age_limit, | |
150 | 'formats': formats, | |
151 | } | |
152 | ||
153 | ||
154 | class VideomoreVideoIE(InfoExtractor): | |
155 | IE_NAME = 'videomore:video' | |
156 | _VALID_URL = r'https?://videomore\.ru/(?:(?:[^/]+/){2})?(?P<id>[^/?#&]+)[/?#&]*$' | |
157 | _TESTS = [{ | |
158 | # single video with og:video:iframe | |
159 | 'url': 'http://videomore.ru/elki_3', | |
160 | 'info_dict': { | |
161 | 'id': '364623', | |
162 | 'ext': 'flv', | |
163 | 'title': 'Ёлки 3', | |
164 | 'description': '', | |
165 | 'thumbnail': 're:^https?://.*\.jpg', | |
166 | 'duration': 5579, | |
167 | 'age_limit': 6, | |
168 | 'view_count': int, | |
169 | }, | |
170 | 'params': { | |
171 | 'skip_download': True, | |
172 | }, | |
173 | }, { | |
dfb1b146 | 174 | # season single series with og:video:iframe |
030dfb04 S |
175 | 'url': 'http://videomore.ru/poslednii_ment/1_sezon/14_seriya', |
176 | 'only_matching': True, | |
177 | }, { | |
178 | 'url': 'http://videomore.ru/sejchas_v_seti/serii_221-240/226_vypusk', | |
179 | 'only_matching': True, | |
180 | }, { | |
181 | # single video without og:video:iframe | |
182 | 'url': 'http://videomore.ru/marin_i_ego_druzya', | |
183 | 'info_dict': { | |
184 | 'id': '359073', | |
185 | 'ext': 'flv', | |
186 | 'title': '1 серия. Здравствуй, Аквавилль!', | |
187 | 'description': 'md5:c6003179538b5d353e7bcd5b1372b2d7', | |
188 | 'thumbnail': 're:^https?://.*\.jpg', | |
189 | 'duration': 754, | |
190 | 'age_limit': 6, | |
191 | 'view_count': int, | |
192 | }, | |
193 | 'params': { | |
194 | 'skip_download': True, | |
195 | }, | |
196 | }] | |
197 | ||
198 | @classmethod | |
199 | def suitable(cls, url): | |
200 | return False if VideomoreIE.suitable(url) else super(VideomoreVideoIE, cls).suitable(url) | |
201 | ||
202 | def _real_extract(self, url): | |
203 | display_id = self._match_id(url) | |
204 | ||
205 | webpage = self._download_webpage(url, display_id) | |
206 | ||
207 | video_url = self._og_search_property( | |
208 | 'video:iframe', webpage, 'video url', default=None) | |
209 | ||
210 | if not video_url: | |
211 | video_id = self._search_regex( | |
212 | (r'config\s*:\s*["\']https?://videomore\.ru/video/tracks/(\d+)\.xml', | |
213 | r'track-id=["\'](\d+)', | |
214 | r'xcnt_product_id\s*=\s*(\d+)'), webpage, 'video id') | |
215 | video_url = 'videomore:%s' % video_id | |
216 | ||
217 | return self.url_result(video_url, VideomoreIE.ie_key()) | |
218 | ||
219 | ||
220 | class VideomoreSeasonIE(InfoExtractor): | |
221 | IE_NAME = 'videomore:season' | |
222 | _VALID_URL = r'https?://videomore\.ru/(?!embed)(?P<id>[^/]+/[^/?#&]+)[/?#&]*$' | |
223 | _TESTS = [{ | |
224 | 'url': 'http://videomore.ru/molodezhka/sezon_promo', | |
225 | 'info_dict': { | |
226 | 'id': 'molodezhka/sezon_promo', | |
227 | 'title': 'Молодежка Промо', | |
228 | }, | |
229 | 'playlist_mincount': 12, | |
230 | }] | |
231 | ||
232 | def _real_extract(self, url): | |
233 | display_id = self._match_id(url) | |
234 | ||
235 | webpage = self._download_webpage(url, display_id) | |
236 | ||
237 | title = self._og_search_title(webpage) | |
238 | ||
239 | entries = [ | |
240 | self.url_result(item) for item in re.findall( | |
241 | r'<a[^>]+href="((?:https?:)?//videomore\.ru/%s/[^/]+)"[^>]+class="widget-item-desc"' | |
242 | % display_id, webpage)] | |
243 | ||
244 | return self.playlist_result(entries, display_id, title) |