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 k
, _
: k
.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)
94 'title': item
.get('title'),
95 'composer': item
.get('name_composer'),
98 'duration': item
.get('duration_total'),
99 'timestamp': traverse_obj(item
, ('date', 'published')),
100 'description': item
.get('short_description') or stream_info
.get('short_description'),
103 'start_time': chapter
.get('time'),
104 'end_time': try_get(chapter
, lambda x
: x
['time'] + x
['duration']),
105 'title': chapter
.get('text'),
106 } for chapter
in item
['cuepoints']] if item
.get('cuepoints') else None,
109 def _real_extract(self
, url
):
110 language
, video_id
= self
._match
_valid
_url
(url
).group('language', 'id')
114 thumbnail_url
= self
._html
_search
_regex
(
115 r
'(https?://images\.digitalconcerthall\.com/cms/thumbnails/.*\.jpg)',
116 self
._download
_webpage
(url
, video_id
), 'thumbnail')
118 'url': thumbnail_url
,
119 **parse_resolution(thumbnail_url
)
122 vid_info
= self
._download
_json
(
123 f
'https://api.digitalconcerthall.com/v2/concert/{video_id}', video_id
, headers
={
124 'Accept': 'application/json',
125 'Accept-Language': language
127 album_artist
= ' / '.join(traverse_obj(vid_info
, ('_links', 'artist', ..., 'name')) or '')
132 'title': vid_info
.get('title'),
133 'entries': self
._entries
(traverse_obj(vid_info
, ('_embedded', ..., ...)), language
,
134 thumbnails
=thumbnails
, album_artist
=album_artist
),
135 'thumbnails': thumbnails
,
136 'album_artist': album_artist
,