]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/acast.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
8 from ..compat
import compat_str
19 class ACastIE(InfoExtractor
):
24 (?:(?:embed|www)\.)?acast\.com/|
27 (?P<channel>[^/]+)/(?P<id>[^/#?]+)
30 'url': 'https://www.acast.com/sparpodcast/2.raggarmordet-rosterurdetforflutna',
31 'md5': '16d936099ec5ca2d5869e3a813ee8dc4',
33 'id': '2a92b283-1a75-4ad8-8396-499c641de0d9',
35 'title': '2. Raggarmordet - Röster ur det förflutna',
36 'description': 'md5:4f81f6d8cf2e12ee21a321d8bca32db4',
37 'timestamp': 1477346700,
38 'upload_date': '20161024',
39 'duration': 2766.602563,
40 'creator': 'Anton Berg & Martin Johnson',
42 'episode': '2. Raggarmordet - Röster ur det förflutna',
45 'url': 'http://embed.acast.com/adambuxton/ep.12-adam-joeschristmaspodcast2015',
46 'only_matching': True,
48 'url': 'https://play.acast.com/s/rattegangspodden/s04e09-styckmordet-i-helenelund-del-22',
49 'only_matching': True,
51 'url': 'https://play.acast.com/s/sparpodcast/2a92b283-1a75-4ad8-8396-499c641de0d9',
52 'only_matching': True,
55 def _real_extract(self
, url
):
56 channel
, display_id
= re
.match(self
._VALID
_URL
, url
).groups()
57 s
= self
._download
_json
(
58 'https://feeder.acast.com/api/v1/shows/%s/episodes/%s' % (channel
, display_id
),
61 if re
.search(r
'[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}', display_id
):
62 episode_url
= s
.get('episodeUrl')
64 display_id
= episode_url
66 channel
, display_id
= re
.match(self
._VALID
_URL
, s
['link']).groups()
67 cast_data
= self
._download
_json
(
68 'https://play-api.acast.com/splash/%s/%s' % (channel
, display_id
),
70 e
= cast_data
['episode']
71 title
= e
.get('name') or s
['title']
73 'id': compat_str(e
['id']),
74 'display_id': display_id
,
77 'description': e
.get('summary') or clean_html(e
.get('description') or s
.get('description')),
78 'thumbnail': e
.get('image'),
79 'timestamp': unified_timestamp(e
.get('publishingDate') or s
.get('publishDate')),
80 'duration': float_or_none(e
.get('duration') or s
.get('duration')),
81 'filesize': int_or_none(e
.get('contentLength')),
82 'creator': try_get(cast_data
, lambda x
: x
['show']['author'], compat_str
),
83 'series': try_get(cast_data
, lambda x
: x
['show']['name'], compat_str
),
84 'season_number': int_or_none(e
.get('seasonNumber')),
86 'episode_number': int_or_none(e
.get('episodeNumber')),
90 class ACastChannelIE(InfoExtractor
):
91 IE_NAME
= 'acast:channel'
95 (?:www\.)?acast\.com/|
101 'url': 'https://www.acast.com/todayinfocus',
103 'id': '4efc5294-5385-4847-98bd-519799ce5786',
104 'title': 'Today in Focus',
105 'description': 'md5:9ba5564de5ce897faeb12963f4537a64',
107 'playlist_mincount': 35,
109 'url': 'http://play.acast.com/s/ft-banking-weekly',
110 'only_matching': True,
112 _API_BASE_URL
= 'https://play.acast.com/api/'
116 def suitable(cls
, url
):
117 return False if ACastIE
.suitable(url
) else super(ACastChannelIE
, cls
).suitable(url
)
119 def _fetch_page(self
, channel_slug
, page
):
120 casts
= self
._download
_json
(
121 self
._API
_BASE
_URL
+ 'channels/%s/acasts?page=%s' % (channel_slug
, page
),
122 channel_slug
, note
='Download page %d of channel data' % page
)
124 yield self
.url_result(
125 'https://play.acast.com/s/%s/%s' % (channel_slug
, cast
['url']),
128 def _real_extract(self
, url
):
129 channel_slug
= self
._match
_id
(url
)
130 channel_data
= self
._download
_json
(
131 self
._API
_BASE
_URL
+ 'channels/%s' % channel_slug
, channel_slug
)
132 entries
= OnDemandPagedList(functools
.partial(
133 self
._fetch
_page
, channel_slug
), self
._PAGE
_SIZE
)
134 return self
.playlist_result(entries
, compat_str(
135 channel_data
['id']), channel_data
['name'], channel_data
.get('description'))