2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
15 class DigitalConcertHallIE(InfoExtractor
):
16 IE_DESC
= 'DigitalConcertHall extractor'
17 _VALID_URL
= r
'https?://(?:www\.)?digitalconcerthall\.com/(?P<language>[a-z]+)/concert/(?P<id>[0-9]+)'
18 _OAUTH_URL
= 'https://api.digitalconcerthall.com/v2/oauth2/token'
20 _NETRC_MACHINE
= 'digitalconcerthall'
22 'note': 'Playlist with only one video',
23 'url': 'https://www.digitalconcerthall.com/en/concert/53201',
27 'composer': 'Kurt Weill',
28 'title': '[Magic Night]',
29 'thumbnail': r
're:^https?://images.digitalconcerthall.com/cms/thumbnails.*\.jpg$',
30 'upload_date': '20210624',
31 'timestamp': 1624548600,
33 'album_artist': 'Members of the Berliner Philharmoniker / Simon Rössler',
35 'params': {'skip_download': 'm3u8'}
,
37 'note': 'Concert with several works and an interview',
38 'url': 'https://www.digitalconcerthall.com/en/concert/53785',
41 'album_artist': 'Berliner Philharmoniker / Kirill Petrenko',
42 'title': 'Kirill Petrenko conducts Mendelssohn and Shostakovich',
44 'params': {'skip_download': 'm3u8'}
,
48 def _perform_login(self
, username
, password
):
49 token_response
= self
._download
_json
(
51 None, 'Obtaining token', errnote
='Unable to obtain token', data
=urlencode_postdata({
53 'grant_type': 'device',
54 'device_vendor': 'unknown',
55 'app_id': 'dch.webapp',
56 'app_version': '1.0.0',
57 'client_secret': '2ySLN+2Fwb',
59 'Content-Type': 'application/x-www-form-urlencoded',
61 self
._ACCESS
_TOKEN
= token_response
['access_token']
65 None, note
='Logging in', errnote
='Unable to login', data
=urlencode_postdata({
66 'grant_type': 'password',
70 'Content-Type': 'application/x-www-form-urlencoded',
71 'Referer': 'https://www.digitalconcerthall.com',
72 'Authorization': f
'Bearer {self._ACCESS_TOKEN}'
74 except ExtractorError
:
75 self
.raise_login_required(msg
='Login info incorrect')
77 def _real_initialize(self
):
78 if not self
._ACCESS
_TOKEN
:
79 self
.raise_login_required(method
='password')
81 def _entries(self
, items
, language
, **kwargs
):
84 stream_info
= self
._download
_json
(
85 self
._proto
_relative
_url
(item
['_links']['streams']['href']), video_id
, headers
={
86 'Accept': 'application/json',
87 'Authorization': f
'Bearer {self._ACCESS_TOKEN}',
88 'Accept-Language': language
91 m3u8_url
= traverse_obj(
92 stream_info
, ('channel', lambda x
: x
.startswith('vod_mixed'), 'stream', 0, 'url'), get_all
=False)
93 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, 'mp4', 'm3u8_native', fatal
=False)
94 self
._sort
_formats
(formats
)
98 'title': item
.get('title'),
99 'composer': item
.get('name_composer'),
102 'duration': item
.get('duration_total'),
103 'timestamp': traverse_obj(item
, ('date', 'published')),
104 'description': item
.get('short_description') or stream_info
.get('short_description'),
107 'start_time': chapter
.get('time'),
108 'end_time': try_get(chapter
, lambda x
: x
['time'] + x
['duration']),
109 'title': chapter
.get('text'),
110 } for chapter
in item
['cuepoints']] if item
.get('cuepoints') else None,
113 def _real_extract(self
, url
):
114 language
, video_id
= self
._match
_valid
_url
(url
).group('language', 'id')
118 thumbnail_url
= self
._html
_search
_regex
(
119 r
'(https?://images\.digitalconcerthall\.com/cms/thumbnails/.*\.jpg)',
120 self
._download
_webpage
(url
, video_id
), 'thumbnail')
122 'url': thumbnail_url
,
123 **parse_resolution(thumbnail_url
)
126 vid_info
= self
._download
_json
(
127 f
'https://api.digitalconcerthall.com/v2/concert/{video_id}', video_id
, headers
={
128 'Accept': 'application/json',
129 'Accept-Language': language
131 album_artist
= ' / '.join(traverse_obj(vid_info
, ('_links', 'artist', ..., 'name')) or '')
136 'title': vid_info
.get('title'),
137 'entries': self
._entries
(traverse_obj(vid_info
, ('_embedded', ..., ...)), language
,
138 thumbnails
=thumbnails
, album_artist
=album_artist
),
139 'thumbnails': thumbnails
,
140 'album_artist': album_artist
,