]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/nfl.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class NFLIE(InfoExtractor
):
16 _VALID_URL
= r
'(?x)https?://(?:www\.)?nfl\.com/(?:videos/(?:.+)/|.*?\#video=)(?P<id>\d..[0-9]+)'
17 _PLAYER_CONFIG_URL
= 'http://www.nfl.com/static/content/static/config/video/config.json'
19 'url': 'http://www.nfl.com/videos/nfl-game-highlights/0ap3000000398478/Week-3-Redskins-vs-Eagles-highlights',
20 # 'md5': '5eb8c40a727dda106d510e5d6ffa79e5', # md5 checksum fluctuates
22 'id': '0ap3000000398478',
24 'title': 'Week 3: Washington Redskins vs. Philadelphia Eagles highlights',
25 'description': 'md5:56323bfb0ac4ee5ab24bd05fdf3bf478',
26 'upload_date': '20140921',
27 'timestamp': 1411337580,
28 'thumbnail': 're:^https?://.*\.jpg$',
32 def _real_extract(self
, url
):
33 mobj
= re
.match(self
._VALID
_URL
, url
)
34 video_id
= mobj
.group('id')
36 config
= self
._download
_json
(self
._PLAYER
_CONFIG
_URL
, video_id
,
37 note
='Downloading player config')
38 url_template
= 'http://nfl.com{contentURLTemplate:s}'.format(**config
)
39 video_data
= self
._download
_json
(url_template
.format(id=video_id
), video_id
)
41 cdns
= config
.get('cdns')
43 raise ExtractorError('Failed to get CDN data', expected
=True)
46 streams
= video_data
.get('cdnData', {}).get('bitrateInfo', [])
47 for name
, cdn
in cdns
.items():
48 # LimeLight streams don't seem to work
49 if cdn
.get('name') == 'LIMELIGHT':
52 protocol
= cdn
.get('protocol')
53 host
= remove_end(cdn
.get('host', ''), '/')
54 if not (protocol
and host
):
57 path_prefix
= cdn
.get('pathprefix', '')
58 if path_prefix
and not path_prefix
.endswith('/'):
59 path_prefix
= '%s/' % path_prefix
61 get_url
= lambda p
: '{protocol:s}://{host:s}/{prefix:s}{path:}'.format(
68 if protocol
== 'rtmp':
70 elif 'prog' in name
.lower():
75 for stream
in streams
:
76 path
= stream
.get('path')
82 'vbr': int_or_none(stream
.get('rate', 0), 1000),
83 'preference': preference
,
87 self
._sort
_formats
(formats
)
90 for q
in ('xl', 'l', 'm', 's', 'xs'):
91 thumbnail
= video_data
.get('imagePaths', {}).get(q
)
97 'title': video_data
.get('storyHeadline'),
99 'description': video_data
.get('caption'),
100 'duration': video_data
.get('duration'),
101 'thumbnail': thumbnail
,
102 'timestamp': int_or_none(video_data
.get('posted'), 1000),