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.0 KiB

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