]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/acast.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
8 from ..utils
import int_or_none
11 class ACastBaseIE(InfoExtractor
):
12 _API_BASE_URL
= 'https://www.acast.com/api/'
15 class ACastIE(ACastBaseIE
):
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:0c5d8201dfea2b93218ea986c91eee6e',
31 def _real_extract(self
, url
):
32 channel
, display_id
= re
.match(self
._VALID
_URL
, url
).groups()
33 cast_data
= self
._download
_json
(self
._API
_BASE
_URL
+ 'channels/%s/acasts/%s/playback' % (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(ACastBaseIE
):
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,
61 def suitable(cls
, url
):
62 return False if ACastIE
.suitable(url
) else super(ACastChannelIE
, cls
).suitable(url
)
64 def _real_extract(self
, url
):
65 display_id
= self
._match
_id
(url
)
66 channel_data
= self
._download
_json
(self
._API
_BASE
_URL
+ 'channels/%s' % display_id
, display_id
)
67 casts
= self
._download
_json
(self
._API
_BASE
_URL
+ 'channels/%s/acasts' % display_id
, display_id
)
68 entries
= [self
.url_result('https://www.acast.com/%s/%s' % (display_id
, cast
['url']), 'ACast') for cast
in casts
]
70 return self
.playlist_result(entries
, compat_str(channel_data
['id']), channel_data
['name'], channel_data
.get('description'))