[cleanup] Misc (#8968)
[yt-dlp.git] / yt_dlp / extractor / masters.py
blob716f1c9615a201b4be9a09b1ddcc27ae39ef4be3
1 from __future__ import unicode_literals
2 from .common import InfoExtractor
3 from ..utils import (
4 traverse_obj,
5 unified_strdate,
9 class MastersIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/(?P<date>\d{4}-\d{2}-\d{2})/(?P<id>\d+)'
11 _TESTS = [{
12 'url': 'https://www.masters.com/en_US/watch/2022-04-07/16493755593805191/sungjae_im_thursday_interview_2022.html',
13 'info_dict': {
14 'id': '16493755593805191',
15 'ext': 'mp4',
16 'title': 'Sungjae Im: Thursday Interview 2022',
17 'upload_date': '20220407',
18 'thumbnail': r're:^https?://.*\.jpg$',
22 def _real_extract(self, url):
23 video_id, upload_date = self._match_valid_url(url).group('id', 'date')
24 content_resp = self._download_json(
25 f'https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en',
26 video_id)
27 formats, subtitles = self._extract_m3u8_formats_and_subtitles(traverse_obj(content_resp, ('media', 'm3u8')), video_id, 'mp4')
29 thumbnails = [{'id': name, 'url': url} for name, url in traverse_obj(content_resp, ('images', 0), default={}).items()]
31 return {
32 'id': video_id,
33 'title': content_resp.get('title'),
34 'formats': formats,
35 'subtitles': subtitles,
36 'upload_date': unified_strdate(upload_date),
37 'thumbnails': thumbnails,