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.

57 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. ExtractorError,
  5. smuggle_url,
  6. )
  7. class MinistryGridIE(InfoExtractor):
  8. _VALID_URL = r'https?://www\.ministrygrid.com/([^/?#]*/)*(?P<id>[^/#?]+)/?(?:$|[?#])'
  9. _TEST = {
  10. 'url': 'http://www.ministrygrid.com/training-viewer/-/training/t4g-2014-conference/the-gospel-by-numbers-4/the-gospel-by-numbers',
  11. 'md5': '844be0d2a1340422759c2a9101bab017',
  12. 'info_dict': {
  13. 'id': '3453494717001',
  14. 'ext': 'mp4',
  15. 'title': 'The Gospel by Numbers',
  16. 'thumbnail': 're:^https?://.*\.jpg',
  17. 'upload_date': '20140410',
  18. 'description': 'Coming soon from T4G 2014!',
  19. 'uploader_id': '2034960640001',
  20. 'timestamp': 1397145591,
  21. },
  22. 'params': {
  23. # m3u8 download
  24. 'skip_download': True,
  25. },
  26. 'add_ie': ['TDSLifeway'],
  27. }
  28. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(url, video_id)
  31. portlets = self._parse_json(self._search_regex(
  32. r'Liferay\.Portlet\.list=(\[.+?\])', webpage, 'portlet list'),
  33. video_id)
  34. pl_id = self._search_regex(
  35. r'getPlid:function\(\){return"(\d+)"}', webpage, 'p_l_id')
  36. for i, portlet in enumerate(portlets):
  37. portlet_url = 'http://www.ministrygrid.com/c/portal/render_portlet?p_l_id=%s&p_p_id=%s' % (pl_id, portlet)
  38. portlet_code = self._download_webpage(
  39. portlet_url, video_id,
  40. note='Looking in portlet %s (%d/%d)' % (portlet, i + 1, len(portlets)),
  41. fatal=False)
  42. video_iframe_url = self._search_regex(
  43. r'<iframe.*?src="([^"]+)"', portlet_code, 'video iframe',
  44. default=None)
  45. if video_iframe_url:
  46. return self.url_result(
  47. smuggle_url(video_iframe_url, {'force_videoid': video_id}),
  48. video_id=video_id)
  49. raise ExtractorError('Could not find video iframe in any portlets')