2014-08-26 10:51:13 +00:00
|
|
|
from .common import InfoExtractor
|
2023-02-17 07:44:26 +00:00
|
|
|
|
2014-12-13 11:24:42 +00:00
|
|
|
from ..utils import (
|
2023-02-17 07:44:26 +00:00
|
|
|
format_field,
|
|
|
|
traverse_obj,
|
|
|
|
unified_timestamp,
|
|
|
|
strip_or_none
|
2014-08-26 10:51:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class SportDeutschlandIE(InfoExtractor):
|
2021-03-14 23:22:06 +00:00
|
|
|
_VALID_URL = r'https?://sportdeutschland\.tv/(?P<id>(?:[^/]+/)?[^?#/&]+)'
|
2014-08-28 08:55:32 +00:00
|
|
|
_TESTS = [{
|
2023-02-17 07:44:26 +00:00
|
|
|
'url': 'https://sportdeutschland.tv/blauweissbuchholztanzsport/buchholzer-formationswochenende-2023-samstag-1-bundesliga-landesliga',
|
2014-08-26 10:51:13 +00:00
|
|
|
'info_dict': {
|
2023-02-17 07:44:26 +00:00
|
|
|
'id': '983758e9-5829-454d-a3cf-eb27bccc3c94',
|
2014-08-26 10:51:13 +00:00
|
|
|
'ext': 'mp4',
|
2023-02-17 07:44:26 +00:00
|
|
|
'title': 'Buchholzer Formationswochenende 2023 - Samstag - 1. Bundesliga / Landesliga',
|
|
|
|
'description': 'md5:a288c794a5ee69e200d8f12982f81a87',
|
|
|
|
'live_status': 'was_live',
|
|
|
|
'channel': 'Blau-Weiss Buchholz Tanzsport',
|
|
|
|
'channel_url': 'https://sportdeutschland.tv/blauweissbuchholztanzsport',
|
|
|
|
'channel_id': '93ec33c9-48be-43b6-b404-e016b64fdfa3',
|
|
|
|
'display_id': '9839a5c7-0dbb-48a8-ab63-3b408adc7b54',
|
|
|
|
'duration': 32447,
|
|
|
|
'upload_date': '20230114',
|
|
|
|
'timestamp': 1673730018.0,
|
|
|
|
}
|
2021-03-14 23:22:06 +00:00
|
|
|
}, {
|
2023-02-17 07:44:26 +00:00
|
|
|
'url': 'https://sportdeutschland.tv/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0',
|
2021-03-14 23:22:06 +00:00
|
|
|
'info_dict': {
|
2023-02-17 07:44:26 +00:00
|
|
|
'id': '95b97d9a-04f6-4880-9039-182985c33943',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'BWF Tour: 1. Runde Feld 1 - YONEX GAINWARD German Open 2022',
|
|
|
|
'description': 'md5:2afb5996ceb9ac0b2ac81f563d3a883e',
|
|
|
|
'live_status': 'was_live',
|
|
|
|
'channel': 'Deutscher Badminton Verband',
|
|
|
|
'channel_url': 'https://sportdeutschland.tv/deutscherbadmintonverband',
|
|
|
|
'channel_id': '93ca5866-2551-49fc-8424-6db35af58920',
|
|
|
|
'display_id': '95c80c52-6b9a-4ae9-9197-984145adfced',
|
|
|
|
'duration': 41097,
|
|
|
|
'upload_date': '20220309',
|
|
|
|
'timestamp': 1646860727.0,
|
|
|
|
}
|
2014-08-28 08:55:32 +00:00
|
|
|
}]
|
2014-08-26 10:51:13 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-03-14 23:22:06 +00:00
|
|
|
display_id = self._match_id(url)
|
2023-02-17 07:44:26 +00:00
|
|
|
meta = self._download_json(
|
|
|
|
'https://api.sportdeutschland.tv/api/stateless/frontend/assets/' + display_id,
|
2021-03-14 23:22:06 +00:00
|
|
|
display_id, query={'access_token': 'true'})
|
2023-02-17 07:44:26 +00:00
|
|
|
|
|
|
|
asset_id = traverse_obj(meta, 'id', 'uuid')
|
|
|
|
|
2021-03-14 23:22:06 +00:00
|
|
|
info = {
|
|
|
|
'id': asset_id,
|
2023-02-17 07:44:26 +00:00
|
|
|
'channel_url': format_field(meta, ('profile', 'slug'), 'https://sportdeutschland.tv/%s'),
|
|
|
|
**traverse_obj(meta, {
|
|
|
|
'title': (('title', 'name'), {strip_or_none}),
|
|
|
|
'description': 'description',
|
|
|
|
'channel': ('profile', 'name'),
|
|
|
|
'channel_id': ('profile', 'id'),
|
|
|
|
'is_live': 'currently_live',
|
|
|
|
'was_live': 'was_live'
|
|
|
|
}, get_all=False)
|
2021-03-14 23:22:06 +00:00
|
|
|
}
|
2023-02-17 07:44:26 +00:00
|
|
|
|
|
|
|
videos = meta.get('videos') or []
|
|
|
|
|
2021-03-14 23:22:06 +00:00
|
|
|
if len(videos) > 1:
|
|
|
|
info.update({
|
|
|
|
'_type': 'multi_video',
|
2023-02-17 07:44:26 +00:00
|
|
|
'entries': self.processVideoOrStream(asset_id, video)
|
|
|
|
} for video in enumerate(videos) if video.get('formats'))
|
|
|
|
|
|
|
|
elif len(videos) == 1:
|
|
|
|
info.update(
|
|
|
|
self.processVideoOrStream(asset_id, videos[0])
|
|
|
|
)
|
|
|
|
|
|
|
|
livestream = meta.get('livestream')
|
|
|
|
|
|
|
|
if livestream is not None:
|
|
|
|
info.update(
|
|
|
|
self.processVideoOrStream(asset_id, livestream)
|
|
|
|
)
|
|
|
|
|
2021-03-14 23:22:06 +00:00
|
|
|
return info
|
2023-02-17 07:44:26 +00:00
|
|
|
|
|
|
|
def process_video_or_stream(self, asset_id, video):
|
|
|
|
video_id = video['id']
|
|
|
|
video_src = video['src']
|
|
|
|
video_type = video['type']
|
|
|
|
|
|
|
|
token = self._download_json(
|
|
|
|
f'https://api.sportdeutschland.tv/api/frontend/asset-token/{asset_id}',
|
|
|
|
video_id, query={'type': video_type, 'playback_id': video_src})['token']
|
|
|
|
formats = self._extract_m3u8_formats(f'https://stream.mux.com/{video_src}.m3u8?token={token}', video_id)
|
|
|
|
|
|
|
|
video_data = {
|
|
|
|
'display_id': video_id,
|
|
|
|
'formats': formats,
|
|
|
|
}
|
|
|
|
if video_type == 'mux_vod':
|
|
|
|
video_data.update({
|
|
|
|
'duration': video.get('duration'),
|
|
|
|
'timestamp': unified_timestamp(video.get('created_at'))
|
|
|
|
})
|
|
|
|
|
|
|
|
return video_data
|