2 from __future__
import unicode_literals
7 from .theplatform
import ThePlatformIE
15 class TheWeatherChannelIE(ThePlatformIE
):
16 _VALID_URL
= r
'https?://(?:www\.)?weather\.com(?P<asset_name>(?:/(?P<locale>[a-z]{2}-[A-Z]{2}))?/(?:[^/]+/)*video/(?P<id>[^/?#]+))'
18 'url': 'https://weather.com/series/great-outdoors/video/ice-climber-is-in-for-a-shock',
19 'md5': 'c4cbe74c9c17c5676b704b950b73dd92',
21 'id': 'cc82397e-cc3f-4d11-9390-a785add090e8',
23 'title': 'Ice Climber Is In For A Shock',
24 'description': 'md5:55606ce1378d4c72e6545e160c9d9695',
25 'uploader': 'TWC - Digital (No Distro)',
26 'uploader_id': '6ccd5455-16bb-46f2-9c57-ff858bb9f62c',
27 'upload_date': '20160720',
28 'timestamp': 1469018835,
31 'url': 'https://weather.com/en-CA/international/videos/video/unidentified-object-falls-from-sky-in-india',
32 'only_matching': True,
35 def _real_extract(self
, url
):
36 asset_name
, locale
, display_id
= re
.match(self
._VALID
_URL
, url
).groups()
39 video_data
= list(self
._download
_json
(
40 'https://weather.com/api/v1/p/redux-dal', display_id
, data
=json
.dumps([{
41 'name': 'getCMSAssetsUrlConfig',
43 'language': locale
.replace('-', '_'),
50 }]).encode(), headers
={
51 'Content-Type': 'application/json',
52 })['dal']['getCMSAssetsUrlConfig'].values())[0]['data'][0]
53 video_id
= video_data
['id']
54 seo_meta
= video_data
.get('seometa', {})
55 title
= video_data
.get('title') or seo_meta
['title']
60 for variant_id
, variant_url
in video_data
.get('variants', []).items():
61 variant_url
= variant_url
.strip()
62 if not variant_url
or variant_url
in urls
:
64 urls
.append(variant_url
)
65 ext
= determine_ext(variant_url
)
71 elif ThePlatformIE
.suitable(variant_url
):
72 tp_formats
, _
= self
._extract
_theplatform
_smil
(variant_url
, video_id
)
73 formats
.extend(tp_formats
)
75 formats
.extend(self
._extract
_m
3u8_formats
(
76 variant_url
, video_id
, 'mp4', 'm3u8_native',
77 m3u8_id
=variant_id
, fatal
=False))
79 formats
.extend(self
._extract
_f
4m
_formats
(
80 variant_url
, video_id
, f4m_id
=variant_id
, fatal
=False))
84 'format_id': variant_id
,
86 self
._sort
_formats
(formats
)
88 cc_url
= video_data
.get('cc_url')
92 'display_id': display_id
,
94 'description': video_data
.get('description') or seo_meta
.get('description') or seo_meta
.get('og:description'),
95 'duration': parse_duration(video_data
.get('duration')),
96 'uploader': video_data
.get('providername'),
97 'uploader_id': video_data
.get('providerid'),
98 'timestamp': parse_iso8601(video_data
.get('publishdate')),
99 'subtitles': {locale[:2]: [{'url': cc_url}
]} if cc_url
else None,
100 'thumbnails': thumbnails
,