diff --git a/script.module.libard/addon.xml b/script.module.libard/addon.xml index 98c678c3eb..1e975421bc 100644 --- a/script.module.libard/addon.xml +++ b/script.module.libard/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/script.module.libard/lib/libardnewjsonparser.py b/script.module.libard/lib/libardnewjsonparser.py index 30c49a413d..9ac8d4cd7b 100644 --- a/script.module.libard/lib/libardnewjsonparser.py +++ b/script.module.libard/lib/libardnewjsonparser.py @@ -117,15 +117,47 @@ def parseSearchVOD(self,client='ard',text=''): """ def parseVideo(self,clipId='Y3JpZDovL2JyLmRlL3ZpZGVvL2NkNzBjODMwLTM2ZTAtNDljNC1iMDJiLTQyNWNhMWIyZDg3NA',client="ard"): - j = requests.get(f'{apiUrl}/mediacollection/{clipId}?devicetype={self.deviceType}',headers=headers).json() - for item in j['_mediaArray'][0]['_mediaStreamArray']: - if item['_quality'] == 'auto': - url = item['_stream'] - if url.startswith('//'): - url = 'http:' + url + response = requests.get( + f'{apiUrl}/pages/ard/item/{clipId}?embedded=false&mcV6=true&devicetype={self.deviceType}', + headers=headers + ) + response.raise_for_status() + j = response.json() + + mediaCollection = next( + widget['mediaCollection']['embedded'] + for widget in j['widgets'] + if 'mediaCollection' in widget + ) + + url = None + for stream in mediaCollection.get('streams', []): + for media in stream.get('media', []): + if media.get('mimeType') == 'application/vnd.apple.mpegurl': + url = media['url'] + break + if url: + break + + if not url: + raise RuntimeError('ARD: no HLS stream found') + d = {'media':[{'url':url, 'stream':'HLS'}]} - if '_subtitleUrl' in j: - d['subtitle'] = [{'url':j['_subtitleUrl'], 'type':'ttml', 'lang':'de', 'colour':True}] + + subtitles = [] + for subtitle in mediaCollection.get('subtitles', []): + for source in subtitle.get('sources', []): + if source.get('kind') == 'webvtt': + subtitles.append({ + 'url': source['url'], + 'type': 'webvtt', + 'lang': subtitle.get('languageCode', 'deu'), + 'colour': True + }) + + if subtitles: + d['subtitle'] = subtitles + return d