]>
Commit | Line | Data |
---|---|---|
92b6dc13 AS |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..utils import js_to_json | |
6 | ||
7 | ||
8 | class MyVideoGeIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?myvideo\.ge/v/(?P<id>[0-9]+)' | |
10 | _TEST = { | |
11 | 'url': 'https://www.myvideo.ge/v/3941048', | |
12 | 'md5': '8c192a7d2b15454ba4f29dc9c9a52ea9', | |
13 | 'info_dict': { | |
14 | 'id': '3941048', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'The best prikol', | |
17 | 'thumbnail': r're:^https?://.*\.jpg$', | |
18 | 'uploader': 'md5:d72addd357b0dd914e704781f7f777d8', | |
19 | 'description': 'md5:5c0371f540f5888d603ebfedd46b6df3' | |
20 | } | |
21 | } | |
22 | ||
23 | def _real_extract(self, url): | |
24 | video_id = self._match_id(url) | |
25 | webpage = self._download_webpage(url, video_id) | |
26 | ||
27 | title = self._html_search_regex(r'<h1[^>]*>([^<]+)</h1>', webpage, 'title') | |
28 | description = self._og_search_description(webpage) | |
29 | thumbnail = self._html_search_meta(['og:image'], webpage) | |
30 | uploader = self._search_regex(r'<a[^>]+class="mv_user_name"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False) | |
31 | ||
32 | jwplayer_sources = self._parse_json( | |
33 | self._search_regex( | |
34 | r"(?s)jwplayer\(\"mvplayer\"\).setup\(.*?sources: (.*?])", webpage, 'jwplayer sources'), | |
35 | video_id, transform_source=js_to_json) | |
36 | ||
37 | def _formats_key(f): | |
38 | if f['label'] == 'SD': | |
39 | return -1 | |
40 | elif f['label'] == 'HD': | |
41 | return 1 | |
42 | else: | |
43 | return 0 | |
44 | ||
45 | jwplayer_sources = sorted(jwplayer_sources, key=_formats_key) | |
46 | ||
47 | formats = self._parse_jwplayer_formats(jwplayer_sources, video_id) | |
48 | ||
49 | return { | |
50 | 'id': video_id, | |
51 | 'title': title, | |
52 | 'description': description, | |
53 | 'uploader': uploader, | |
54 | 'formats': formats, | |
55 | 'thumbnail': thumbnail | |
56 | } |