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