Merge branch 'polskie-radio-programme' of https://github.com/JakubAdamWieczorek/youtu...
[youtube-dl] / youtube_dl / extractor / parliamentliveuk.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class ParliamentLiveUKIE(InfoExtractor):
7     IE_NAME = 'parliamentlive.tv'
8     IE_DESC = 'UK parliament videos'
9     _VALID_URL = r'https?://(?:www\.)?parliamentlive\.tv/Event/Index/(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
10
11     _TEST = {
12         'url': 'http://parliamentlive.tv/Event/Index/c1e9d44d-fd6c-4263-b50f-97ed26cc998b',
13         'info_dict': {
14             'id': 'c1e9d44d-fd6c-4263-b50f-97ed26cc998b',
15             'ext': 'mp4',
16             'title': 'Home Affairs Committee',
17             'uploader_id': 'FFMPEG-01',
18             'timestamp': 1422696664,
19             'upload_date': '20150131',
20         },
21     }
22
23     def _real_extract(self, url):
24         video_id = self._match_id(url)
25         webpage = self._download_webpage(
26             'http://vodplayer.parliamentlive.tv/?mid=' + video_id, video_id)
27         widget_config = self._parse_json(self._search_regex(
28             r'kWidgetConfig\s*=\s*({.+});',
29             webpage, 'kaltura widget config'), video_id)
30         kaltura_url = 'kaltura:%s:%s' % (widget_config['wid'][1:], widget_config['entry_id'])
31         event_title = self._download_json(
32             'http://parliamentlive.tv/Event/GetShareVideo/' + video_id, video_id)['event']['title']
33         return {
34             '_type': 'url_transparent',
35             'id': video_id,
36             'title': event_title,
37             'description': '',
38             'url': kaltura_url,
39             'ie_key': 'Kaltura',
40         }