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