Release 2024.12.23
[yt-dlp.git] / yt_dlp / extractor / megaphone.py
blobd249a8492d9075ed79a79279b6b435c404bf77fd
1 from .common import InfoExtractor
2 from ..utils import js_to_json
5 class MegaphoneIE(InfoExtractor):
6 IE_NAME = 'megaphone.fm'
7 IE_DESC = 'megaphone.fm embedded players'
8 _VALID_URL = r'https?://player\.megaphone\.fm/(?P<id>[A-Z0-9]+)'
9 _EMBED_REGEX = [rf'<iframe[^>]*?\ssrc=["\'](?P<url>{_VALID_URL})']
10 _TEST = {
11 'url': 'https://player.megaphone.fm/GLT9749789991',
12 'md5': '4816a0de523eb3e972dc0dda2c191f96',
13 'info_dict': {
14 'id': 'GLT9749789991',
15 'ext': 'mp3',
16 'title': '#97 What Kind Of Idiot Gets Phished?',
17 'thumbnail': r're:^https://.*\.png.*$',
18 'duration': 1998.36,
19 'creators': ['Reply All'],
23 def _real_extract(self, url):
24 video_id = self._match_id(url)
25 webpage = self._download_webpage(url, video_id)
27 title = self._og_search_property('audio:title', webpage)
28 author = self._og_search_property('audio:artist', webpage)
29 thumbnail = self._og_search_thumbnail(webpage)
31 episode_json = self._search_regex(r'(?s)var\s+episode\s*=\s*(\{.+?\});', webpage, 'episode JSON')
32 episode_data = self._parse_json(episode_json, video_id, js_to_json)
33 video_url = self._proto_relative_url(episode_data['mediaUrl'], 'https:')
35 formats = [{
36 'url': video_url,
39 return {
40 'id': video_id,
41 'thumbnail': thumbnail,
42 'title': title,
43 'creators': [author] if author else None,
44 'duration': episode_data['duration'],
45 'formats': formats,