Add new extractor for TV Noe (Czech Christian TV).
[youtube-dl] / youtube_dl / extractor / tvnoe.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .jwplatform import JWPlatformBaseIE
5 from ..utils import clean_html, get_element_by_class, js_to_json
6
7
8 class TVNoeIE(JWPlatformBaseIE):
9     _VALID_URL = r'https?://(www\.)?tvnoe\.cz/video/(?P<id>[0-9]+)'
10     _TEST = {
11         'url': 'http://www.tvnoe.cz/video/10362',
12         'md5': 'aee983f279aab96ec45ab6e2abb3c2ca',
13         'info_dict': {
14             'id': '10362',
15             'ext': 'mp4',
16             'series': 'Noční univerzita',
17             'title': 'prof. Tomáš Halík, Th.D. - ' +
18                      'Návrat náboženství a střet civilizací',
19             'description': 'md5:f337bae384e1a531a52c55ebc50fff41',
20         }
21     }
22
23     def _real_extract(self, url):
24         video_id = self._match_id(url)
25         webpage = self._download_webpage(url, video_id)
26
27         iframe_url = self._search_regex(r'<iframe[^>]+src="([^"]+)"',
28                                         webpage, 'iframe src attribute')
29
30         ifs_page = self._download_webpage(iframe_url, video_id)
31         jwplayer_data = self._parse_json(self._find_jwplayer_data(ifs_page),
32                                          video_id, transform_source=js_to_json)
33         info_dict = self._parse_jwplayer_data(
34             jwplayer_data, video_id, require_title=False, base_url=iframe_url)
35
36         info_dict.update({
37             'id': video_id,
38             'title': clean_html(
39                get_element_by_class('field-name-field-podnazev', webpage)),
40             'description': clean_html(get_element_by_class('field-name-body',
41                                                            webpage)),
42             'series': clean_html(get_element_by_class('title', webpage))
43         })
44         return info_dict