]>
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): | |
13 | def _get_real_id(self, page_id): | |
14 | return page_id | |
15 | ||
16 | def _real_extract(self, url): | |
17 | page_id = self._get_real_id(self._match_id(url)) | |
18 | webpage = self._download_webpage(url, page_id) | |
19 | hidden_inputs = self._hidden_inputs(webpage) | |
20 | m3u8_entry_protocol = 'm3u8' if self._IS_LIVE else 'm3u8_native' | |
21 | ||
22 | format_url = self._html_search_regex( | |
23 | [ | |
197224b7 | 24 | r'file\s*:\s*"(https?://[^"]+?/playlist\.m3u8)', |
7d273a38 RA |
25 | r'<a[^>]+href="(rtsp://[^"]+)"' |
26 | ], webpage, 'format url') | |
27 | formats = self._extract_wowza_formats( | |
28 | format_url, page_id, m3u8_entry_protocol, ['smil']) | |
29 | self._sort_formats(formats) | |
30 | ||
31 | return { | |
32 | 'id': page_id, | |
33 | 'title': self._live_title(page_id) if self._IS_LIVE else page_id, | |
34 | 'uploader_id': hidden_inputs.get('userid'), | |
35 | 'duration': int_or_none(hidden_inputs.get('duration')), | |
36 | 'is_live': self._IS_LIVE, | |
37 | 'formats': formats, | |
38 | } | |
39 | ||
40 | ||
41 | class MangomoloVideoIE(MangomoloBaseIE): | |
fc86d4ee | 42 | IE_NAME = 'mangomolo:video' |
d05ef09d | 43 | _VALID_URL = r'https?://admin\.mangomolo\.com/analytics/index\.php/customers/embed/video\?.*?\bid=(?P<id>\d+)' |
7d273a38 RA |
44 | _IS_LIVE = False |
45 | ||
46 | ||
47 | class MangomoloLiveIE(MangomoloBaseIE): | |
fc86d4ee | 48 | IE_NAME = 'mangomolo:live' |
d05ef09d | 49 | _VALID_URL = r'https?://admin\.mangomolo\.com/analytics/index\.php/customers/embed/index\?.*?\bchannelid=(?P<id>(?:[A-Za-z0-9+/=]|%2B|%2F|%3D)+)' |
7d273a38 RA |
50 | _IS_LIVE = True |
51 | ||
52 | def _get_real_id(self, page_id): | |
cf282071 | 53 | return compat_b64decode(compat_urllib_parse_unquote(page_id)).decode() |