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