]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | determine_ext, | |
4 | unescapeHTML, | |
5 | ) | |
6 | ||
7 | ||
8 | class CJSWIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/(?P<program>[^/]+)/episode/(?P<id>\d+)' | |
10 | _TESTS = [{ | |
11 | 'url': 'http://cjsw.com/program/freshly-squeezed/episode/20170620', | |
12 | 'md5': 'cee14d40f1e9433632c56e3d14977120', | |
13 | 'info_dict': { | |
14 | 'id': '91d9f016-a2e7-46c5-8dcb-7cbcd7437c41', | |
15 | 'ext': 'mp3', | |
16 | 'title': 'Freshly Squeezed – Episode June 20, 2017', | |
17 | 'description': 'md5:c967d63366c3898a80d0c7b0ff337202', | |
18 | 'series': 'Freshly Squeezed', | |
19 | 'episode_id': '20170620', | |
20 | }, | |
21 | }, { | |
22 | # no description | |
23 | 'url': 'http://cjsw.com/program/road-pops/episode/20170707/', | |
24 | 'only_matching': True, | |
25 | }] | |
26 | ||
27 | def _real_extract(self, url): | |
28 | mobj = self._match_valid_url(url) | |
29 | program, episode_id = mobj.group('program', 'id') | |
30 | audio_id = '%s/%s' % (program, episode_id) | |
31 | ||
32 | webpage = self._download_webpage(url, episode_id) | |
33 | ||
34 | title = unescapeHTML(self._search_regex( | |
35 | (r'<h1[^>]+class=["\']episode-header__title["\'][^>]*>(?P<title>[^<]+)', | |
36 | r'data-audio-title=(["\'])(?P<title>(?:(?!\1).)+)\1'), | |
37 | webpage, 'title', group='title')) | |
38 | ||
39 | audio_url = self._search_regex( | |
40 | r'<button[^>]+data-audio-src=(["\'])(?P<url>(?:(?!\1).)+)\1', | |
41 | webpage, 'audio url', group='url') | |
42 | ||
43 | audio_id = self._search_regex( | |
44 | r'/([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})\.mp3', | |
45 | audio_url, 'audio id', default=audio_id) | |
46 | ||
47 | formats = [{ | |
48 | 'url': audio_url, | |
49 | 'ext': determine_ext(audio_url, 'mp3'), | |
50 | 'vcodec': 'none', | |
51 | }] | |
52 | ||
53 | description = self._html_search_regex( | |
54 | r'<p>(?P<description>.+?)</p>', webpage, 'description', | |
55 | default=None) | |
56 | series = self._search_regex( | |
57 | r'data-showname=(["\'])(?P<name>(?:(?!\1).)+)\1', webpage, | |
58 | 'series', default=program, group='name') | |
59 | ||
60 | return { | |
61 | 'id': audio_id, | |
62 | 'title': title, | |
63 | 'description': description, | |
64 | 'formats': formats, | |
65 | 'series': series, | |
66 | 'episode_id': episode_id, | |
67 | } |