]>
Commit | Line | Data |
---|---|---|
397b305c | 1 | from .common import InfoExtractor |
fd94e267 | 2 | from .pladform import PladformIE |
397b305c RA |
3 | from ..utils import ( |
4 | unescapeHTML, | |
5 | int_or_none, | |
6 | ExtractorError, | |
7 | ) | |
8 | ||
9 | ||
10 | class METAIE(InfoExtractor): | |
049da7cb S |
11 | _VALID_URL = r'https?://video\.meta\.ua/(?:iframe/)?(?P<id>[0-9]+)' |
12 | _TESTS = [{ | |
397b305c RA |
13 | 'url': 'http://video.meta.ua/5502115.video', |
14 | 'md5': '71b6f3ee274bef16f1ab410f7f56b476', | |
15 | 'info_dict': { | |
16 | 'id': '5502115', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'Sony Xperia Z camera test [HQ]', | |
19 | 'description': 'Xperia Z shoots video in FullHD HDR.', | |
20 | 'uploader_id': 'nomobile', | |
21 | 'uploader': 'CHЁZA.TV', | |
22 | 'upload_date': '20130211', | |
23 | }, | |
24 | 'add_ie': ['Youtube'], | |
049da7cb S |
25 | }, { |
26 | 'url': 'http://video.meta.ua/iframe/5502115', | |
27 | 'only_matching': True, | |
fd94e267 S |
28 | }, { |
29 | # pladform embed | |
30 | 'url': 'http://video.meta.ua/7121015.video', | |
31 | 'only_matching': True, | |
049da7cb | 32 | }] |
397b305c RA |
33 | |
34 | def _real_extract(self, url): | |
35 | video_id = self._match_id(url) | |
36 | webpage = self._download_webpage(url, video_id) | |
37 | ||
fd94e267 S |
38 | st_html5 = self._search_regex( |
39 | r"st_html5\s*=\s*'#([^']+)'", webpage, 'uppod html5 st', default=None) | |
40 | ||
41 | if st_html5: | |
76dad392 | 42 | # uppod st decryption algorithm is reverse engineered from function un(s) at uppod.js |
fd94e267 S |
43 | json_str = '' |
44 | for i in range(0, len(st_html5), 3): | |
45 | json_str += '�%s;' % st_html5[i:i + 3] | |
46 | uppod_data = self._parse_json(unescapeHTML(json_str), video_id) | |
47 | error = uppod_data.get('customnotfound') | |
48 | if error: | |
49 | raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True) | |
50 | ||
51 | video_url = uppod_data['file'] | |
52 | info = { | |
53 | 'id': video_id, | |
54 | 'url': video_url, | |
55 | 'title': uppod_data.get('comment') or self._og_search_title(webpage), | |
56 | 'description': self._og_search_description(webpage, default=None), | |
57 | 'thumbnail': uppod_data.get('poster') or self._og_search_thumbnail(webpage), | |
58 | 'duration': int_or_none(self._og_search_property( | |
59 | 'video:duration', webpage, default=None)), | |
60 | } | |
61 | if 'youtube.com/' in video_url: | |
62 | info.update({ | |
63 | '_type': 'url_transparent', | |
64 | 'ie_key': 'Youtube', | |
65 | }) | |
66 | return info | |
67 | ||
68 | pladform_url = PladformIE._extract_url(webpage) | |
69 | if pladform_url: | |
70 | return self.url_result(pladform_url) |