3 from .theplatform
import ThePlatformIE
11 class TheWeatherChannelIE(ThePlatformIE
): # XXX: Do not subclass from concrete IE
12 _VALID_URL
= r
'https?://(?:www\.)?weather\.com(?P<asset_name>(?:/(?P<locale>[a-z]{2}-[A-Z]{2}))?/(?:[^/]+/)*video/(?P<id>[^/?#]+))'
14 'url': 'https://weather.com/storms/hurricane/video/invest-95l-in-atlantic-has-a-medium-chance-of-development',
15 'md5': '68f0cf616435683f27ce36bd9c927394',
17 'id': '81acef2d-ee8c-4545-ba83-bff3cc80db97',
19 'title': 'Invest 95L In Atlantic Has A Medium Chance Of Development',
20 'description': 'md5:0de720fd5f0d0e32207bd4c270fff824',
21 'uploader': 'TWC - Digital',
22 'uploader_id': 'b5a999e0-9e04-11e1-9ee2-001d092f5a10',
23 'upload_date': '20230721',
24 'timestamp': 1689967343,
25 'display_id': 'invest-95l-in-atlantic-has-a-medium-chance-of-development',
29 'url': 'https://weather.com/en-CA/international/videos/video/unidentified-object-falls-from-sky-in-india',
30 'only_matching': True,
33 def _real_extract(self
, url
):
34 asset_name
, locale
, display_id
= self
._match
_valid
_url
(url
).groups()
37 video_data
= next(iter(self
._download
_json
(
38 'https://weather.com/api/v1/p/redux-dal', display_id
, data
=json
.dumps([{
39 'name': 'getCMSAssetsUrlConfig',
41 'language': locale
.replace('-', '_'),
48 }]).encode(), headers
={
49 'Content-Type': 'application/json',
50 })['dal']['getCMSAssetsUrlConfig'].values()))['data'][0]
51 video_id
= video_data
['id']
52 seo_meta
= video_data
.get('seometa', {})
53 title
= video_data
.get('title') or seo_meta
['title']
58 for variant_id
, variant_url
in video_data
.get('variants', []).items():
59 variant_url
= variant_url
.strip()
60 if not variant_url
or variant_url
in urls
:
62 urls
.append(variant_url
)
63 ext
= determine_ext(variant_url
)
69 elif ThePlatformIE
.suitable(variant_url
):
70 tp_formats
, _
= self
._extract
_theplatform
_smil
(variant_url
, video_id
)
71 formats
.extend(tp_formats
)
73 formats
.extend(self
._extract
_m
3u8_formats
(
74 variant_url
, video_id
, 'mp4', 'm3u8_native',
75 m3u8_id
=variant_id
, fatal
=False))
77 formats
.extend(self
._extract
_f
4m
_formats
(
78 variant_url
, video_id
, f4m_id
=variant_id
, fatal
=False))
82 'format_id': variant_id
,
85 cc_url
= video_data
.get('cc_url')
89 'display_id': display_id
,
91 'description': video_data
.get('description') or seo_meta
.get('description') or seo_meta
.get('og:description'),
92 'duration': parse_duration(video_data
.get('duration')),
93 'uploader': video_data
.get('providername'),
94 'uploader_id': video_data
.get('providerid'),
95 'timestamp': parse_iso8601(video_data
.get('publishdate')),
96 'subtitles': {locale
[:2]: [{'url': cc_url
}]} if cc_url
else None,
97 'thumbnails': thumbnails
,