]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/willow.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / willow.py
1 from ..utils import ExtractorError
2 from .common import InfoExtractor
3
4
5 class WillowIE(InfoExtractor):
6 _VALID_URL = r'https?://(www\.)?willow\.tv/videos/(?P<id>[0-9a-z-_]+)'
7 _GEO_COUNTRIES = ['US']
8
9 _TESTS = [{
10 'url': 'http://willow.tv/videos/d5winning-moment-eng-vs-ind-streaming-online-4th-test-india-tour-of-england-2021',
11 'info_dict': {
12 'id': '169662',
13 'display_id': 'd5winning-moment-eng-vs-ind-streaming-online-4th-test-india-tour-of-england-2021',
14 'ext': 'mp4',
15 'title': 'Winning Moment: 4th Test, England vs India',
16 'thumbnail': 'https://aimages.willow.tv/ytThumbnails/6748_D5winning_moment.jpg',
17 'duration': 233,
18 'timestamp': 1630947954,
19 'upload_date': '20210906',
20 'location': 'Kennington Oval, London',
21 'series': 'India tour of England 2021',
22 },
23 'params': {
24 'skip_download': True, # AES-encrypted m3u8
25 },
26 }, {
27 'url': 'http://willow.tv/videos/highlights-short-ind-vs-nz-streaming-online-2nd-t20i-new-zealand-tour-of-india-2021',
28 'only_matching': True,
29 }]
30
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33 webpage = self._download_webpage(url, video_id)
34 video_data = self._parse_json(self._html_search_regex(
35 r'var\s+data_js\s*=\s*JSON\.parse\(\'(.+)\'\)', webpage,
36 'data_js'), video_id)
37
38 video = next((v for v in video_data.get('trending_videos') or []
39 if v.get('secureurl')), None)
40 if not video:
41 raise ExtractorError('No videos found')
42
43 formats = self._extract_m3u8_formats(video['secureurl'], video_id, 'mp4')
44
45 return {
46 'id': str(video.get('content_id')),
47 'display_id': video.get('video_slug'),
48 'title': video.get('video_name') or self._html_search_meta('twitter:title', webpage),
49 'formats': formats,
50 'thumbnail': video.get('yt_thumb_url') or self._html_search_meta(
51 'twitter:image', webpage, default=None),
52 'duration': video.get('duration_seconds'),
53 'timestamp': video.get('created_date'),
54 'location': video.get('venue'),
55 'series': video.get('series_name'),
56 }