You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import base64
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_parse_unquote
  6. from ..utils import (
  7. int_or_none,
  8. )
  9. class MangomoloBaseIE(InfoExtractor):
  10. def _get_real_id(self, page_id):
  11. return page_id
  12. def _real_extract(self, url):
  13. page_id = self._get_real_id(self._match_id(url))
  14. webpage = self._download_webpage(url, page_id)
  15. hidden_inputs = self._hidden_inputs(webpage)
  16. m3u8_entry_protocol = 'm3u8' if self._IS_LIVE else 'm3u8_native'
  17. format_url = self._html_search_regex(
  18. [
  19. r'file\s*:\s*"(https?://[^"]+?/playlist.m3u8)',
  20. r'<a[^>]+href="(rtsp://[^"]+)"'
  21. ], webpage, 'format url')
  22. formats = self._extract_wowza_formats(
  23. format_url, page_id, m3u8_entry_protocol, ['smil'])
  24. self._sort_formats(formats)
  25. return {
  26. 'id': page_id,
  27. 'title': self._live_title(page_id) if self._IS_LIVE else page_id,
  28. 'uploader_id': hidden_inputs.get('userid'),
  29. 'duration': int_or_none(hidden_inputs.get('duration')),
  30. 'is_live': self._IS_LIVE,
  31. 'formats': formats,
  32. }
  33. class MangomoloVideoIE(MangomoloBaseIE):
  34. IE_NAME = 'mangomolo:video'
  35. _VALID_URL = r'https?://admin\.mangomolo\.com/analytics/index\.php/customers/embed/video\?.*?\bid=(?P<id>\d+)'
  36. _IS_LIVE = False
  37. class MangomoloLiveIE(MangomoloBaseIE):
  38. IE_NAME = 'mangomolo:live'
  39. _VALID_URL = r'https?://admin\.mangomolo\.com/analytics/index\.php/customers/embed/index\?.*?\bchannelid=(?P<id>(?:[A-Za-z0-9+/=]|%2B|%2F|%3D)+)'
  40. _IS_LIVE = True
  41. def _get_real_id(self, page_id):
  42. return base64.b64decode(compat_urllib_parse_unquote(page_id).encode()).decode()