]>
Raphaël G. Git Repositories - youtubedl/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 ACastIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?acast\.com/(?P<channel>[^/]+)/(?P<id>[^/#?]+)'
15 'url': 'https://www.acast.com/condenasttraveler/-where-are-you-taipei-101-taiwan',
16 'md5': 'ada3de5a1e3a2a381327d749854788bb',
18 'id': '57de3baa-4bb0-487e-9418-2692c1277a34',
20 'title': '"Where Are You?": Taipei 101, Taiwan',
21 'timestamp': 1196172000000,
22 'description': 'md5:a0b4ef3634e63866b542e5b1199a1a0e',
27 def _real_extract(self
, url
):
28 channel
, display_id
= re
.match(self
._VALID
_URL
, url
).groups()
30 embed_page
= self
._download
_webpage
(
31 re
.sub('(?:www\.)?acast\.com', 'embedcdn.acast.com', url
), display_id
)
32 cast_data
= self
._parse
_json
(self
._search
_regex
(
33 r
'window\[\'acast
/queries
\'\
]\s
*=\s
*([^
;]+);', embed_page, 'acast data
'),
34 display_id)['GetAcast
/%s/%s' % (channel, display_id)]
37 'id': compat_str(cast_data['id']),
38 'display_id
': display_id,
39 'url
': cast_data['blings
'][0]['audio
'],
40 'title
': cast_data['name
'],
41 'description
': cast_data.get('description
'),
42 'thumbnail
': cast_data.get('image
'),
43 'timestamp
': int_or_none(cast_data.get('publishingDate
')),
44 'duration
': int_or_none(cast_data.get('duration
')),
48 class ACastChannelIE(InfoExtractor):
49 IE_NAME = 'acast
:channel
'
50 _VALID_URL = r'https?
://(?
:www\
.)?acast\
.com
/(?P
<id>[^
/#?]+)'
52 'url': 'https://www.acast.com/condenasttraveler',
54 'id': '50544219-29bb-499e-a083-6087f4cb7797',
55 'title': 'Condé Nast Traveler Podcast',
56 'description': 'md5:98646dee22a5b386626ae31866638fbd',
58 'playlist_mincount': 20,
60 _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 _real_extract(self
, url
):
67 display_id
= self
._match
_id
(url
)
68 channel_data
= self
._download
_json
(self
._API
_BASE
_URL
+ 'channels/%s' % display_id
, display_id
)
69 casts
= self
._download
_json
(self
._API
_BASE
_URL
+ 'channels/%s/acasts' % display_id
, display_id
)
70 entries
= [self
.url_result('https://www.acast.com/%s/%s' % (display_id
, cast
['url']), 'ACast') for cast
in casts
]
72 return self
.playlist_result(entries
, compat_str(channel_data
['id']), channel_data
['name'], channel_data
.get('description'))