]>
Commit | Line | Data |
---|---|---|
7d273a38 RA |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
7d273a38 | 4 | from .common import InfoExtractor |
cf282071 S |
5 | from ..compat import ( |
6 | compat_b64decode, | |
7 | compat_urllib_parse_unquote, | |
7d273a38 | 8 | ) |
cf282071 | 9 | from ..utils import int_or_none |
7d273a38 RA |
10 | |
11 | ||
12 | class MangomoloBaseIE(InfoExtractor): | |
755541a4 RA |
13 | _BASE_REGEX = r'https?://(?:admin\.mangomolo\.com/analytics/index\.php/customers/embed/|player\.mangomolo\.com/v1/)' |
14 | ||
7d273a38 RA |
15 | def _get_real_id(self, page_id): |
16 | return page_id | |
17 | ||
18 | def _real_extract(self, url): | |
19 | page_id = self._get_real_id(self._match_id(url)) | |
755541a4 RA |
20 | webpage = self._download_webpage( |
21 | 'https://player.mangomolo.com/v1/%s?%s' % (self._TYPE, url.split('?')[1]), page_id) | |
7d273a38 RA |
22 | hidden_inputs = self._hidden_inputs(webpage) |
23 | m3u8_entry_protocol = 'm3u8' if self._IS_LIVE else 'm3u8_native' | |
24 | ||
25 | format_url = self._html_search_regex( | |
26 | [ | |
755541a4 | 27 | r'(?:file|src)\s*:\s*"(https?://[^"]+?/playlist\.m3u8)', |
7d273a38 RA |
28 | r'<a[^>]+href="(rtsp://[^"]+)"' |
29 | ], webpage, 'format url') | |
30 | formats = self._extract_wowza_formats( | |
31 | format_url, page_id, m3u8_entry_protocol, ['smil']) | |
32 | self._sort_formats(formats) | |
33 | ||
34 | return { | |
35 | 'id': page_id, | |
39ca3b5c | 36 | 'title': page_id, |
7d273a38 RA |
37 | 'uploader_id': hidden_inputs.get('userid'), |
38 | 'duration': int_or_none(hidden_inputs.get('duration')), | |
39 | 'is_live': self._IS_LIVE, | |
40 | 'formats': formats, | |
41 | } | |
42 | ||
43 | ||
44 | class MangomoloVideoIE(MangomoloBaseIE): | |
755541a4 RA |
45 | _TYPE = 'video' |
46 | IE_NAME = 'mangomolo:' + _TYPE | |
47 | _VALID_URL = MangomoloBaseIE._BASE_REGEX + r'video\?.*?\bid=(?P<id>\d+)' | |
7d273a38 RA |
48 | _IS_LIVE = False |
49 | ||
50 | ||
51 | class MangomoloLiveIE(MangomoloBaseIE): | |
755541a4 RA |
52 | _TYPE = 'live' |
53 | IE_NAME = 'mangomolo:' + _TYPE | |
54 | _VALID_URL = MangomoloBaseIE._BASE_REGEX + r'(live|index)\?.*?\bchannelid=(?P<id>(?:[A-Za-z0-9+/=]|%2B|%2F|%3D)+)' | |
7d273a38 RA |
55 | _IS_LIVE = True |
56 | ||
57 | def _get_real_id(self, page_id): | |
cf282071 | 58 | return compat_b64decode(compat_urllib_parse_unquote(page_id)).decode() |