2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class RTPIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?rtp\.pt/play/p(?P<program_id>[0-9]+)/(?P<id>[^/?#]+)/?'
14 'url': 'http://www.rtp.pt/play/p405/e174042/paixoes-cruzadas',
15 'md5': 'e736ce0c665e459ddb818546220b4ef8',
19 'title': 'Paixões Cruzadas',
20 'description': 'As paixões musicais de António Cartaxo e António Macedo',
21 'thumbnail': r're:^https?://.*\.jpg',
24 'url': 'http://www.rtp.pt/play/p831/a-quimica-das-coisas',
25 'only_matching': True,
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
32 title = self._html_search_meta(
33 'twitter:title', webpage, display_name='title', fatal=True)
35 config = self._parse_json(self._search_regex(
36 r'(?s)RTPPlayer\(({.+?})\);', webpage,
37 'player config'), video_id, js_to_json)
38 file_url = config['file']
39 ext = determine_ext(file_url)
41 file_key = config.get('fileKey')
42 formats = self._extract_m3u8_formats(
43 file_url, video_id, 'mp4', 'm3u8_native',
44 m3u8_id='hls', fatal=file_key)
47 'url': 'https://cdn-ondemand.rtp.pt' + file_key,
50 self._sort_formats(formats)
56 if config.get('mediaType') == 'audio':
64 'description': self._html_search_meta(['description', 'twitter:description'], webpage),
65 'thumbnail': config.get('poster') or self._og_search_thumbnail(webpage),