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.

58 lines
2.0 KiB

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