]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/cjsw.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / cjsw.py
CommitLineData
d2b9f362 1from .common import InfoExtractor
c319d1c4
S
2from ..utils import (
3 determine_ext,
4 unescapeHTML,
5)
d2b9f362
CS
6
7
8class CJSWIE(InfoExtractor):
c319d1c4 9 _VALID_URL = r'https?://(?:www\.)?cjsw\.com/program/(?P<program>[^/]+)/episode/(?P<id>\d+)'
0d2f0b03 10 _TESTS = [{
d2b9f362
CS
11 'url': 'http://cjsw.com/program/freshly-squeezed/episode/20170620',
12 'md5': 'cee14d40f1e9433632c56e3d14977120',
13 'info_dict': {
c319d1c4 14 'id': '91d9f016-a2e7-46c5-8dcb-7cbcd7437c41',
d2b9f362 15 'ext': 'mp3',
c319d1c4
S
16 'title': 'Freshly Squeezed – Episode June 20, 2017',
17 'description': 'md5:c967d63366c3898a80d0c7b0ff337202',
18 'series': 'Freshly Squeezed',
19 'episode_id': '20170620',
20 },
0d2f0b03
S
21 }, {
22 # no description
23 'url': 'http://cjsw.com/program/road-pops/episode/20170707/',
24 'only_matching': True,
25 }]
d2b9f362
CS
26
27 def _real_extract(self, url):
5ad28e7f 28 mobj = self._match_valid_url(url)
c319d1c4 29 program, episode_id = mobj.group('program', 'id')
add96eb9 30 audio_id = f'{program}/{episode_id}'
d2b9f362
CS
31
32 webpage = self._download_webpage(url, episode_id)
33
c319d1c4
S
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
d2b9f362 47 formats = [{
c319d1c4
S
48 'url': audio_url,
49 'ext': determine_ext(audio_url, 'mp3'),
d2b9f362
CS
50 'vcodec': 'none',
51 }]
c319d1c4
S
52
53 description = self._html_search_regex(
0d2f0b03
S
54 r'<p>(?P<description>.+?)</p>', webpage, 'description',
55 default=None)
c319d1c4
S
56 series = self._search_regex(
57 r'data-showname=(["\'])(?P<name>(?:(?!\1).)+)\1', webpage,
58 'series', default=program, group='name')
59
d2b9f362 60 return {
c319d1c4 61 'id': audio_id,
d2b9f362
CS
62 'title': title,
63 'description': description,
64 'formats': formats,
c319d1c4
S
65 'series': series,
66 'episode_id': episode_id,
d2b9f362 67 }