]>
Commit | Line | Data |
---|---|---|
50e12e9d | 1 | from .common import InfoExtractor |
a1ff3cd5 | 2 | from ..utils import ( |
976e1ff7 | 3 | clean_html, |
00dd0cd5 | 4 | clean_podcast_url, |
cae5d970 | 5 | int_or_none, |
29f7c58a | 6 | parse_iso8601, |
a1ff3cd5 | 7 | ) |
50e12e9d | 8 | |
9 | ||
29f7c58a | 10 | class ACastBaseIE(InfoExtractor): |
11 | def _extract_episode(self, episode, show_info): | |
12 | title = episode['title'] | |
13 | info = { | |
14 | 'id': episode['id'], | |
15 | 'display_id': episode.get('episodeUrl'), | |
00dd0cd5 | 16 | 'url': clean_podcast_url(episode['url']), |
29f7c58a | 17 | 'title': title, |
18 | 'description': clean_html(episode.get('description') or episode.get('summary')), | |
19 | 'thumbnail': episode.get('image'), | |
20 | 'timestamp': parse_iso8601(episode.get('publishDate')), | |
21 | 'duration': int_or_none(episode.get('duration')), | |
22 | 'filesize': int_or_none(episode.get('contentLength')), | |
23 | 'season_number': int_or_none(episode.get('season')), | |
24 | 'episode': title, | |
25 | 'episode_number': int_or_none(episode.get('episode')), | |
26 | } | |
27 | info.update(show_info) | |
28 | return info | |
29 | ||
30 | def _extract_show_info(self, show): | |
31 | return { | |
32 | 'creator': show.get('author'), | |
33 | 'series': show.get('title'), | |
34 | } | |
35 | ||
36 | def _call_api(self, path, video_id, query=None): | |
37 | return self._download_json( | |
38 | 'https://feeder.acast.com/api/v1/shows/' + path, video_id, query=query) | |
39 | ||
40 | ||
41 | class ACastIE(ACastBaseIE): | |
50e12e9d | 42 | IE_NAME = 'acast' |
50a498a6 S |
43 | _VALID_URL = r'''(?x) |
44 | https?:// | |
45 | (?: | |
46 | (?:(?:embed|www)\.)?acast\.com/| | |
47 | play\.acast\.com/s/ | |
48 | ) | |
49 | (?P<channel>[^/]+)/(?P<id>[^/#?]+) | |
50 | ''' | |
846fd69b | 51 | _TESTS = [{ |
846fd69b | 52 | 'url': 'https://www.acast.com/sparpodcast/2.raggarmordet-rosterurdetforflutna', |
29f7c58a | 53 | 'md5': 'f5598f3ad1e4776fed12ec1407153e4b', |
846fd69b MW |
54 | 'info_dict': { |
55 | 'id': '2a92b283-1a75-4ad8-8396-499c641de0d9', | |
56 | 'ext': 'mp3', | |
57 | 'title': '2. Raggarmordet - Röster ur det förflutna', | |
29f7c58a | 58 | 'description': 'md5:a992ae67f4d98f1c0141598f7bebbf67', |
846fd69b MW |
59 | 'timestamp': 1477346700, |
60 | 'upload_date': '20161024', | |
29f7c58a | 61 | 'duration': 2766, |
cae5d970 S |
62 | 'creator': 'Anton Berg & Martin Johnson', |
63 | 'series': 'Spår', | |
64 | 'episode': '2. Raggarmordet - Röster ur det förflutna', | |
846fd69b | 65 | } |
252e172d TL |
66 | }, { |
67 | 'url': 'http://embed.acast.com/adambuxton/ep.12-adam-joeschristmaspodcast2015', | |
68 | 'only_matching': True, | |
50a498a6 | 69 | }, { |
29f7c58a | 70 | 'url': 'https://play.acast.com/s/rattegangspodden/s04e09styckmordetihelenelund-del2-2', |
50a498a6 | 71 | 'only_matching': True, |
976e1ff7 RA |
72 | }, { |
73 | 'url': 'https://play.acast.com/s/sparpodcast/2a92b283-1a75-4ad8-8396-499c641de0d9', | |
74 | 'only_matching': True, | |
846fd69b | 75 | }] |
50e12e9d | 76 | |
77 | def _real_extract(self, url): | |
5ad28e7f | 78 | channel, display_id = self._match_valid_url(url).groups() |
29f7c58a | 79 | episode = self._call_api( |
80 | '%s/episodes/%s' % (channel, display_id), | |
81 | display_id, {'showInfo': 'true'}) | |
82 | return self._extract_episode( | |
83 | episode, self._extract_show_info(episode.get('show') or {})) | |
50e12e9d | 84 | |
85 | ||
29f7c58a | 86 | class ACastChannelIE(ACastBaseIE): |
50e12e9d | 87 | IE_NAME = 'acast:channel' |
0e713dbb | 88 | _VALID_URL = r'''(?x) |
89 | https?:// | |
90 | (?: | |
91 | (?:www\.)?acast\.com/| | |
92 | play\.acast\.com/s/ | |
93 | ) | |
94 | (?P<id>[^/#?]+) | |
95 | ''' | |
96 | _TESTS = [{ | |
97 | 'url': 'https://www.acast.com/todayinfocus', | |
50e12e9d | 98 | 'info_dict': { |
0e713dbb | 99 | 'id': '4efc5294-5385-4847-98bd-519799ce5786', |
100 | 'title': 'Today in Focus', | |
29f7c58a | 101 | 'description': 'md5:c09ce28c91002ce4ffce71d6504abaae', |
50e12e9d | 102 | }, |
29f7c58a | 103 | 'playlist_mincount': 200, |
0e713dbb | 104 | }, { |
105 | 'url': 'http://play.acast.com/s/ft-banking-weekly', | |
106 | 'only_matching': True, | |
107 | }] | |
50e12e9d | 108 | |
ab3b773b | 109 | @classmethod |
110 | def suitable(cls, url): | |
111 | return False if ACastIE.suitable(url) else super(ACastChannelIE, cls).suitable(url) | |
112 | ||
a1ff3cd5 | 113 | def _real_extract(self, url): |
29f7c58a | 114 | show_slug = self._match_id(url) |
115 | show = self._call_api(show_slug, show_slug) | |
116 | show_info = self._extract_show_info(show) | |
117 | entries = [] | |
118 | for episode in (show.get('episodes') or []): | |
119 | entries.append(self._extract_episode(episode, show_info)) | |
120 | return self.playlist_result( | |
121 | entries, show.get('id'), show.get('title'), show.get('description')) |