[ie/twitter:spaces] Support video spaces (#10789)
[yt-dlp3.git] / yt_dlp / extractor / magellantv.py
blob6f2524ba22cb465eac00b065bb0581bf6bb7f10c
1 from .common import InfoExtractor
2 from ..utils import parse_age_limit, parse_duration, traverse_obj
5 class MagellanTVIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?magellantv\.com/(?:watch|video)/(?P<id>[\w-]+)'
7 _TESTS = [{
8 'url': 'https://www.magellantv.com/watch/my-dads-on-death-row?type=v',
9 'info_dict': {
10 'id': 'my-dads-on-death-row',
11 'ext': 'mp4',
12 'title': 'My Dad\'s On Death Row',
13 'description': 'md5:33ba23b9f0651fc4537ed19b1d5b0d7a',
14 'duration': 3780.0,
15 'age_limit': 14,
16 'tags': ['Justice', 'Reality', 'United States', 'True Crime'],
18 'params': {'skip_download': 'm3u8'},
19 }, {
20 'url': 'https://www.magellantv.com/video/james-bulger-the-new-revelations',
21 'info_dict': {
22 'id': 'james-bulger-the-new-revelations',
23 'ext': 'mp4',
24 'title': 'James Bulger: The New Revelations',
25 'description': 'md5:7b97922038bad1d0fe8d0470d8a189f2',
26 'duration': 2640.0,
27 'age_limit': 0,
28 'tags': ['Investigation', 'True Crime', 'Justice', 'Europe'],
30 'params': {'skip_download': 'm3u8'},
31 }, {
32 'url': 'https://www.magellantv.com/watch/celebration-nation',
33 'info_dict': {
34 'id': 'celebration-nation',
35 'ext': 'mp4',
36 'tags': ['Art & Culture', 'Human Interest', 'Anthropology', 'China', 'History'],
37 'duration': 2640.0,
38 'title': 'Ancestors',
40 'params': {'skip_download': 'm3u8'},
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
45 webpage = self._download_webpage(url, video_id)
46 data = traverse_obj(self._search_nextjs_data(webpage, video_id), (
47 'props', 'pageProps', 'reactContext',
48 (('video', 'detail'), ('series', 'currentEpisode')), {dict}), get_all=False)
49 formats, subtitles = self._extract_m3u8_formats_and_subtitles(data['jwpVideoUrl'], video_id)
51 return {
52 'id': video_id,
53 'formats': formats,
54 'subtitles': subtitles,
55 **traverse_obj(data, {
56 'title': ('title', {str}),
57 'description': ('metadata', 'description', {str}),
58 'duration': ('duration', {parse_duration}),
59 'age_limit': ('ratingCategory', {parse_age_limit}),
60 'tags': ('tags', ..., {str}),
61 }),