]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/theweatherchannel.py
   2 from __future__ 
import unicode_literals
 
   4 from .theplatform 
import ThePlatformIE
 
  11 class TheWeatherChannelIE(ThePlatformIE
): 
  12     _VALID_URL 
= r
'https?://(?:www\.)?weather\.com/(?:[^/]+/)*video/(?P<id>[^/?#]+)' 
  14         'url': 'https://weather.com/series/great-outdoors/video/ice-climber-is-in-for-a-shock', 
  15         'md5': 'ab924ac9574e79689c24c6b95e957def', 
  17             'id': 'cc82397e-cc3f-4d11-9390-a785add090e8', 
  19             'title': 'Ice Climber Is In For A Shock', 
  20             'description': 'md5:55606ce1378d4c72e6545e160c9d9695', 
  21             'uploader': 'TWC - Digital (No Distro)', 
  22             'uploader_id': '6ccd5455-16bb-46f2-9c57-ff858bb9f62c', 
  26     def _real_extract(self
, url
): 
  27         display_id 
= self
._match
_id
(url
) 
  28         webpage 
= self
._download
_webpage
(url
, display_id
) 
  29         drupal_settings 
= self
._parse
_json
(self
._search
_regex
( 
  30             r
'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', 
  31             webpage
, 'drupal settings'), display_id
) 
  32         video_id 
= drupal_settings
['twc']['contexts']['node']['uuid'] 
  33         video_data 
= self
._download
_json
( 
  34             'https://dsx.weather.com/cms/v4/asset-collection/en_US/' + video_id
, video_id
) 
  35         seo_meta 
= video_data
.get('seometa', {}) 
  36         title 
= video_data
.get('title') or seo_meta
['title'] 
  41         for variant_id
, variant_url 
in video_data
.get('variants', []).items(): 
  42             variant_url 
= variant_url
.strip() 
  43             if not variant_url 
or variant_url 
in urls
: 
  45             urls
.append(variant_url
) 
  46             ext 
= determine_ext(variant_url
) 
  52             elif ThePlatformIE
.suitable(variant_url
): 
  53                 tp_formats
, _ 
= self
._extract
_theplatform
_smil
(variant_url
, video_id
) 
  54                 formats
.extend(tp_formats
) 
  56                 formats
.extend(self
._extract
_m
3u8_formats
( 
  57                     variant_url
, video_id
, 'mp4', 'm3u8_native', 
  58                     m3u8_id
=variant_id
, fatal
=False)) 
  60                 formats
.extend(self
._extract
_f
4m
_formats
( 
  61                     variant_url
, video_id
, f4m_id
=variant_id
, fatal
=False)) 
  65                     'format_id': variant_id
, 
  67         self
._sort
_formats
(formats
) 
  71             'display_id': display_id
, 
  73             'description': video_data
.get('description') or seo_meta
.get('description') or seo_meta
.get('og:description'), 
  74             'duration': parse_duration(video_data
.get('duration')), 
  75             'uploader': video_data
.get('providername'), 
  76             'uploader_id': video_data
.get('providerid'), 
  77             'thumbnails': thumbnails
,