[charlierose] Add new extractor
[youtube-dl] / youtube_dl / extractor / charlierose.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import remove_end
5
6
7 class CharlieRoseIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?charlierose\.com/video(?:s|/player)/(?P<id>\d+)'
9     _TEST = {
10         'url': 'https://charlierose.com/videos/27996',
11         'info_dict': {
12             'id': '27996',
13             'ext': 'mp4',
14             'title': 'Remembering Zaha Hadid',
15             'thumbnail': 're:^https?://.*\.jpg\?\d+',
16             'description': 'We revisit past conversations with Zaha Hadid, in memory of the world renowned Iraqi architect.',
17         },
18         'params': {
19             # m3u8 download
20             'skip_download': True,
21         }
22     }
23
24     _PLAYER_BASE = 'https://charlierose.com/video/player/%s'
25
26     def _real_extract(self, url):
27         video_id = self._match_id(url)
28         webpage = self._download_webpage(self._PLAYER_BASE % video_id, video_id)
29
30         title = remove_end(self._og_search_title(webpage), ' - Charlie Rose')
31
32         entries = self._parse_html5_media_entries(self._PLAYER_BASE % video_id, webpage, video_id)[0]
33         formats = entries['formats']
34
35         self._sort_formats(formats)
36         self._remove_duplicate_formats(formats)
37
38         return {
39             'id': video_id,
40             'title': title,
41             'formats': formats,
42             'thumbnail': self._og_search_thumbnail(webpage),
43             'description': self._og_search_description(webpage),
44             'subtitles': entries.get('subtitles'),
45         }