Created
August 8, 2023 07:53
-
-
Save pwaldhauer/03855965b00fc11b8f7049af98694f45 to your computer and use it in GitHub Desktop.
yt-dlp Cotent Extractor for magentamusik.de (I'm too lazy to create a pull request)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .common import InfoExtractor | |
class MagentaMusikIE(InfoExtractor): | |
_VALID_URL = r'https?://(?:www\.)?magentamusik\.de/(?P<id>.*)' | |
_TESTS = [] | |
def _real_extract(self, url): | |
video_id = self._match_id(url) | |
webpage = self._download_webpage(url, video_id) | |
video_id = self._html_search_regex(r'"assetId":"[^\d]+([0-9]+)"', webpage, 'video_id') | |
json = self._download_json("https://wcps.t-online.de/cvss/magentamusic/vodplayer/v3/player/58935/%s/Main%%20Movie" % video_id, video_id) | |
print(json) | |
xml_url = json['content']['feature']['representations'][0]['contentPackages'][0]['media']['href'] | |
metadata = json['content']['feature'].get('metadata') | |
title = None | |
description = None | |
duration = None | |
thumbnails = [] | |
if metadata: | |
title = metadata.get('title') | |
description = metadata.get('fullDescription') | |
duration = metadata.get('runtimeInSeconds') | |
for img_key in ('teaserImageWide', 'smallCoverImage'): | |
if img_key in metadata: | |
thumbnails.append({'url': metadata[img_key].get('href')}) | |
xml = self._download_xml(xml_url, video_id) | |
final_url = xml[0][0][0].attrib['src'] | |
formats = self._extract_m3u8_formats( | |
final_url, video_id, ext='mp4') | |
return { | |
'id': video_id, | |
'title': title, | |
'description': description, | |
'formats': formats, | |
'duration': duration, | |
'thumbnails': thumbnails | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment