1 from .common
import InfoExtractor
12 class DigitalConcertHallIE(InfoExtractor
):
13 IE_DESC
= 'DigitalConcertHall extractor'
14 _VALID_URL
= r
'https?://(?:www\.)?digitalconcerthall\.com/(?P<language>[a-z]+)/concert/(?P<id>[0-9]+)'
15 _OAUTH_URL
= 'https://api.digitalconcerthall.com/v2/oauth2/token'
17 _NETRC_MACHINE
= 'digitalconcerthall'
19 'note': 'Playlist with only one video',
20 'url': 'https://www.digitalconcerthall.com/en/concert/53201',
24 'composer': 'Kurt Weill',
25 'title': '[Magic Night]',
26 'thumbnail': r
're:^https?://images.digitalconcerthall.com/cms/thumbnails.*\.jpg$',
27 'upload_date': '20210624',
28 'timestamp': 1624548600,
30 'album_artist': 'Members of the Berliner Philharmoniker / Simon Rössler',
32 'params': {'skip_download': 'm3u8'}
,
34 'note': 'Concert with several works and an interview',
35 'url': 'https://www.digitalconcerthall.com/en/concert/53785',
38 'album_artist': 'Berliner Philharmoniker / Kirill Petrenko',
39 'title': 'Kirill Petrenko conducts Mendelssohn and Shostakovich',
41 'params': {'skip_download': 'm3u8'}
,
45 def _perform_login(self
, username
, password
):
46 token_response
= self
._download
_json
(
48 None, 'Obtaining token', errnote
='Unable to obtain token', data
=urlencode_postdata({
50 'grant_type': 'device',
51 'device_vendor': 'unknown',
52 'app_id': 'dch.webapp',
53 'app_version': '1.0.0',
54 'client_secret': '2ySLN+2Fwb',
56 'Content-Type': 'application/x-www-form-urlencoded',
58 self
._ACCESS
_TOKEN
= token_response
['access_token']
62 None, note
='Logging in', errnote
='Unable to login', data
=urlencode_postdata({
63 'grant_type': 'password',
67 'Content-Type': 'application/x-www-form-urlencoded',
68 'Referer': 'https://www.digitalconcerthall.com',
69 'Authorization': f
'Bearer {self._ACCESS_TOKEN}'
71 except ExtractorError
:
72 self
.raise_login_required(msg
='Login info incorrect')
74 def _real_initialize(self
):
75 if not self
._ACCESS
_TOKEN
:
76 self
.raise_login_required(method
='password')
78 def _entries(self
, items
, language
, **kwargs
):
81 stream_info
= self
._download
_json
(
82 self
._proto
_relative
_url
(item
['_links']['streams']['href']), video_id
, headers
={
83 'Accept': 'application/json',
84 'Authorization': f
'Bearer {self._ACCESS_TOKEN}',
85 'Accept-Language': language
88 m3u8_url
= traverse_obj(
89 stream_info
, ('channel', lambda x
: x
.startswith('vod_mixed'), 'stream', 0, 'url'), get_all
=False)
90 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, 'mp4', 'm3u8_native', fatal
=False)
91 self
._sort
_formats
(formats
)
95 'title': item
.get('title'),
96 'composer': item
.get('name_composer'),
99 'duration': item
.get('duration_total'),
100 'timestamp': traverse_obj(item
, ('date', 'published')),
101 'description': item
.get('short_description') or stream_info
.get('short_description'),
104 'start_time': chapter
.get('time'),
105 'end_time': try_get(chapter
, lambda x
: x
['time'] + x
['duration']),
106 'title': chapter
.get('text'),
107 } for chapter
in item
['cuepoints']] if item
.get('cuepoints') else None,
110 def _real_extract(self
, url
):
111 language
, video_id
= self
._match
_valid
_url
(url
).group('language', 'id')
115 thumbnail_url
= self
._html
_search
_regex
(
116 r
'(https?://images\.digitalconcerthall\.com/cms/thumbnails/.*\.jpg)',
117 self
._download
_webpage
(url
, video_id
), 'thumbnail')
119 'url': thumbnail_url
,
120 **parse_resolution(thumbnail_url
)
123 vid_info
= self
._download
_json
(
124 f
'https://api.digitalconcerthall.com/v2/concert/{video_id}', video_id
, headers
={
125 'Accept': 'application/json',
126 'Accept-Language': language
128 album_artist
= ' / '.join(traverse_obj(vid_info
, ('_links', 'artist', ..., 'name')) or '')
133 'title': vid_info
.get('title'),
134 'entries': self
._entries
(traverse_obj(vid_info
, ('_embedded', ..., ...)), language
,
135 thumbnails
=thumbnails
, album_artist
=album_artist
),
136 'thumbnails': thumbnails
,
137 'album_artist': album_artist
,