1 from .common
import InfoExtractor
11 class DigitalConcertHallIE(InfoExtractor
):
12 IE_DESC
= 'DigitalConcertHall extractor'
13 _VALID_URL
= r
'https?://(?:www\.)?digitalconcerthall\.com/(?P<language>[a-z]+)/(?P<type>film|concert)/(?P<id>[0-9]+)'
14 _OAUTH_URL
= 'https://api.digitalconcerthall.com/v2/oauth2/token'
16 _NETRC_MACHINE
= 'digitalconcerthall'
18 'note': 'Playlist with only one video',
19 'url': 'https://www.digitalconcerthall.com/en/concert/53201',
23 'composer': 'Kurt Weill',
24 'title': '[Magic Night]',
25 'thumbnail': r
're:^https?://images.digitalconcerthall.com/cms/thumbnails.*\.jpg$',
26 'upload_date': '20210624',
27 'timestamp': 1624548600,
29 'album_artist': 'Members of the Berliner Philharmoniker / Simon Rössler',
31 'params': {'skip_download': 'm3u8'}
,
33 'note': 'Concert with several works and an interview',
34 'url': 'https://www.digitalconcerthall.com/en/concert/53785',
37 'album_artist': 'Berliner Philharmoniker / Kirill Petrenko',
38 'title': 'Kirill Petrenko conducts Mendelssohn and Shostakovich',
40 'params': {'skip_download': 'm3u8'}
,
43 'url': 'https://www.digitalconcerthall.com/en/film/388',
47 'title': 'The Berliner Philharmoniker and Frank Peter Zimmermann',
48 'description': 'md5:cfe25a7044fa4be13743e5089b5b5eb2',
49 'thumbnail': r
're:^https?://images.digitalconcerthall.com/cms/thumbnails.*\.jpg$',
50 'upload_date': '20220714',
51 'timestamp': 1657785600,
52 'album_artist': 'Frank Peter Zimmermann / Benedikt von Bernstorff / Jakob von Bernstorff',
54 'params': {'skip_download': 'm3u8'}
,
57 def _perform_login(self
, username
, password
):
58 token_response
= self
._download
_json
(
60 None, 'Obtaining token', errnote
='Unable to obtain token', data
=urlencode_postdata({
62 'grant_type': 'device',
63 'device_vendor': 'unknown',
64 'app_id': 'dch.webapp',
65 'app_version': '1.0.0',
66 'client_secret': '2ySLN+2Fwb',
68 'Content-Type': 'application/x-www-form-urlencoded',
70 self
._ACCESS
_TOKEN
= token_response
['access_token']
74 None, note
='Logging in', errnote
='Unable to login', data
=urlencode_postdata({
75 'grant_type': 'password',
79 'Content-Type': 'application/x-www-form-urlencoded',
80 'Referer': 'https://www.digitalconcerthall.com',
81 'Authorization': f
'Bearer {self._ACCESS_TOKEN}'
83 except ExtractorError
:
84 self
.raise_login_required(msg
='Login info incorrect')
86 def _real_initialize(self
):
87 if not self
._ACCESS
_TOKEN
:
88 self
.raise_login_required(method
='password')
90 def _entries(self
, items
, language
, type_
, **kwargs
):
93 stream_info
= self
._download
_json
(
94 self
._proto
_relative
_url
(item
['_links']['streams']['href']), video_id
, headers
={
95 'Accept': 'application/json',
96 'Authorization': f
'Bearer {self._ACCESS_TOKEN}',
97 'Accept-Language': language
100 m3u8_url
= traverse_obj(
101 stream_info
, ('channel', lambda k
, _
: k
.startswith('vod_mixed'), 'stream', 0, 'url'), get_all
=False)
102 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, 'mp4', 'm3u8_native', fatal
=False)
106 'title': item
.get('title'),
107 'composer': item
.get('name_composer'),
110 'duration': item
.get('duration_total'),
111 'timestamp': traverse_obj(item
, ('date', 'published')),
112 'description': item
.get('short_description') or stream_info
.get('short_description'),
115 'start_time': chapter
.get('time'),
116 'end_time': try_get(chapter
, lambda x
: x
['time'] + x
['duration']),
117 'title': chapter
.get('text'),
118 } for chapter
in item
['cuepoints']] if item
.get('cuepoints') and type_
== 'concert' else None,
121 def _real_extract(self
, url
):
122 language
, type_
, video_id
= self
._match
_valid
_url
(url
).group('language', 'type', 'id')
126 thumbnail_url
= self
._html
_search
_regex
(
127 r
'(https?://images\.digitalconcerthall\.com/cms/thumbnails/.*\.jpg)',
128 self
._download
_webpage
(url
, video_id
), 'thumbnail')
130 'url': thumbnail_url
,
131 **parse_resolution(thumbnail_url
)
134 vid_info
= self
._download
_json
(
135 f
'https://api.digitalconcerthall.com/v2/{type_}/{video_id}', video_id
, headers
={
136 'Accept': 'application/json',
137 'Accept-Language': language
139 album_artist
= ' / '.join(traverse_obj(vid_info
, ('_links', 'artist', ..., 'name')) or '')
140 videos
= [vid_info
] if type_
== 'film' else traverse_obj(vid_info
, ('_embedded', ..., ...))
145 'title': vid_info
.get('title'),
146 'entries': self
._entries
(videos
, language
, thumbnails
=thumbnails
, album_artist
=album_artist
, type_
=type_
),
147 'thumbnails': thumbnails
,
148 'album_artist': album_artist
,