2 from __future__ import unicode_literals
7 from .common import InfoExtractor
8 from ..compat import compat_str
15 class ACastIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?acast\.com/(?P<channel>[^/]+)/(?P<id>[^/#?]+)'
19 'url': 'https://www.acast.com/condenasttraveler/-where-are-you-taipei-101-taiwan',
20 'md5': 'ada3de5a1e3a2a381327d749854788bb',
22 'id': '57de3baa-4bb0-487e-9418-2692c1277a34',
24 'title': '"Where Are You?": Taipei 101, Taiwan',
25 'timestamp': 1196172000000,
26 'description': 'md5:a0b4ef3634e63866b542e5b1199a1a0e',
31 def _real_extract(self, url):
32 channel, display_id = re.match(self._VALID_URL, url).groups()
33 cast_data = self._download_json(
34 'https://embed.acast.com/api/acasts/%s/%s' % (channel, display_id), display_id)
36 'id': compat_str(cast_data['id']),
37 'display_id': display_id,
38 'url': cast_data['blings'][0]['audio'],
39 'title': cast_data['name'],
40 'description': cast_data.get('description'),
41 'thumbnail': cast_data.get('image'),
42 'timestamp': int_or_none(cast_data.get('publishingDate')),
43 'duration': int_or_none(cast_data.get('duration')),
47 class ACastChannelIE(InfoExtractor):
48 IE_NAME = 'acast:channel'
49 _VALID_URL = r'https?://(?:www\.)?acast\.com/(?P<id>[^/#?]+)'
51 'url': 'https://www.acast.com/condenasttraveler',
53 'id': '50544219-29bb-499e-a083-6087f4cb7797',
54 'title': 'Condé Nast Traveler Podcast',
55 'description': 'md5:98646dee22a5b386626ae31866638fbd',
57 'playlist_mincount': 20,
59 _API_BASE_URL = 'https://www.acast.com/api/'
63 def suitable(cls, url):
64 return False if ACastIE.suitable(url) else super(ACastChannelIE, cls).suitable(url)
66 def _fetch_page(self, channel_slug, page):
67 casts = self._download_json(
68 self._API_BASE_URL + 'channels/%s/acasts?page=%s' % (channel_slug, page),
69 channel_slug, note='Download page %d of channel data' % page)
71 yield self.url_result(
72 'https://www.acast.com/%s/%s' % (channel_slug, cast['url']),
75 def _real_extract(self, url):
76 channel_slug = self._match_id(url)
77 channel_data = self._download_json(
78 self._API_BASE_URL + 'channels/%s' % channel_slug, channel_slug)
79 entries = OnDemandPagedList(functools.partial(
80 self._fetch_page, channel_slug), self._PAGE_SIZE)
81 return self.playlist_result(entries, compat_str(
82 channel_data['id']), channel_data['name'], channel_data.get('description'))