3 from .common
import InfoExtractor
15 class MuseAIIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?muse\.ai/(?:v|embed)/(?P<id>\w+)'
18 'url': 'https://muse.ai/embed/YdTWvUW',
19 'md5': 'f994f9a38be1c3aaf9e37cbd7d76fe7c',
23 'title': '2023-05-28-Grabien-1941111 (1)',
25 'uploader': 'Today News Africa',
26 'uploader_id': 'TodayNewsAfrica',
27 'upload_date': '20230528',
28 'timestamp': 1685285044,
31 'availability': 'public',
34 'url': 'https://muse.ai/v/gQ4gGAA-0756',
35 'md5': '52dbfc78e865e56dc19a1715badc35e8',
40 'description': 'md5:0ca1483f9aac423e9a96ad00bb3a0785',
41 'uploader': 'Aerial.ie',
42 'uploader_id': 'aerial',
43 'upload_date': '20210306',
44 'timestamp': 1615072842,
47 'availability': 'public',
51 'url': 'https://muse.ai/docs',
52 'playlist_mincount': 4,
55 'title': 'muse.ai | docs',
56 'description': 'md5:6c0293431481582739c82ee8902687fa',
58 'thumbnail': 'https://muse.ai/static/imgs/poster-img-docs.png',
60 'params': {'allowed_extractors': ['all', '-html5']},
62 _EMBED_REGEX
= [r
'<iframe[^>]*\bsrc=["\'](?P
<url
>https
://muse\
.ai
/embed
/\w
+)']
65 def _extract_embed_urls(cls, url, webpage):
66 yield from super()._extract_embed_urls(url, webpage)
67 for embed_id in re.findall(r'<script
>[^
<]*\bMusePlayer\
(\
{[^
}<]*\bvideo
:\s
*["\'](\w+)["\']', webpage):
68 yield f'https
://muse
.ai
/embed
/{embed_id}
'
70 def _real_extract(self, url):
71 video_id = self._match_id(url)
72 webpage = self._download_webpage(f'https
://muse
.ai
/embed
/{video_id}
', video_id)
73 data = self._search_json(
74 r'player\
.setData\
(', webpage, 'player data
', video_id, transform_source=js_to_json)
76 source_url = data['url
']
77 if not url_or_none(source_url):
78 raise ExtractorError('Unable to extract video URL
')
82 'format_id
': 'source
',
84 **traverse_obj(data, {
85 'ext
': ('filename
', {determine_ext}),
86 'width
': ('width
', {int_or_none}),
87 'height
': ('height
', {int_or_none}),
88 'filesize
': ('size
', {int_or_none}),
91 if source_url.endswith('/data
'):
92 base_url = f'{source_url
[:-5]}/videos
'
93 formats.extend(self._extract_m3u8_formats(
94 f'{base_url}
/hls
.m3u8
', video_id, m3u8_id='hls
', fatal=False))
95 formats.extend(self._extract_mpd_formats(
96 f'{base_url}
/dash
.mpd
', video_id, mpd_id='dash
', fatal=False))
101 **traverse_obj(data, {
102 'title
': ('title
', {str}),
103 'description
': ('description
', {str}),
104 'duration
': ('duration
', {float_or_none}),
105 'timestamp
': ('tcreated
', {int_or_none}),
106 'uploader
': ('owner_name
', {str}),
107 'uploader_id
': ('owner_username
', {str}),
108 'view_count
': ('views
', {int_or_none}),
109 'age_limit
': ('mature
', {lambda x: 18 if x else None}),
110 'availability
': ('visibility
', {lambda x: x if x in ('private
', 'unlisted
') else 'public
'}),