]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/nba.py
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
11 class NBABaseIE(InfoExtractor
):
12 def _get_formats(self
, video_id
):
13 base_url
= 'http://nba.cdn.turner.com/nba/big%s' % video_id
15 'url': base_url
+ '_nba_android_high.mp4',
20 'url': base_url
+ '_640x360_664b.mp4',
25 'url': base_url
+ '_768x432_1404.mp4',
30 'url': base_url
+ '_1280x720.mp4',
36 def _real_extract(self
, url
):
37 video_id
= self
._match
_id
(url
)
38 webpage
= self
._download
_webpage
(url
, video_id
)
39 ret
= self
._extract
_metadata
(webpage
, video_id
)
40 ret
['id'] = video_id
.rpartition('/')[2]
41 ret
['formats'] = self
._get
_formats
(video_id
)
45 class NBAIE(NBABaseIE
):
47 _VALID_URL
= r
'https?://(?:www\.)?nba\.com/(?:nba/)?video(?P<id>/[^?]*?)/?(?:/index\.html)?(?:\?.*)?$'
49 'url': 'http://www.nba.com/video/games/nets/2012/12/04/0021200253-okc-bkn-recap.nba/index.html',
50 'md5': '9d902940d2a127af3f7f9d2f3dc79c96',
52 'id': '0021200253-okc-bkn-recap.nba',
54 'title': 'Thunder vs. Nets',
55 'description': 'Kevin Durant scores 32 points and dishes out six assists as the Thunder beat the Nets in Brooklyn.',
57 'timestamp': 1354680189,
58 'upload_date': '20121205',
61 'url': 'http://www.nba.com/video/games/hornets/2014/12/05/0021400276-nyk-cha-play5.nba/',
62 'only_matching': True,
65 def _extract_metadata(self
, webpage
, video_id
):
67 'title': self
._html
_search
_meta
('name', webpage
),
68 'description': self
._html
_search
_meta
('description', webpage
),
69 'duration': parse_duration(self
._html
_search
_meta
('duration', webpage
)),
70 'thumbnail': self
._html
_search
_meta
('thumbnailUrl', webpage
),
71 'timestamp': parse_iso8601(self
._html
_search
_meta
('uploadDate', webpage
))
74 class NBAWatchIE(NBABaseIE
):
76 _VALID_URL
= r
'https?://watch.nba\.com/(?:nba/)?video(?P<id>/[^?]*?)/?(?:/index\.html)?(?:\?.*)?$'
78 'url': 'http://watch.nba.com/nba/video/channels/playoffs/2015/05/20/0041400301-cle-atl-recap.nba',
79 'md5': 'b2b39b81cf28615ae0c3360a3f9668c4',
81 'id': '0041400301-cle-atl-recap.nba',
83 'title': 'Hawks vs. Cavaliers Game 1',
84 'description': 'md5:8094c3498d35a9bd6b1a8c396a071b4d',
86 'timestamp': 1432094400,
87 'upload_date': '20150520',
91 def _extract_metadata(self
, webpage
, video_id
):
92 program_id
= self
._search
_regex
(r
'var\s+programId\s*=\s*(\d+);', webpage
, 'program id')
93 metadata
= self
._download
_json
(
94 'http://smbsolr.cdnak.neulion.com/solr_nbav6/nba/nba/mlt/?wt=json&fl=name,description,image,runtime,releaseDate&q=sequence%3A' + program_id
, video_id
)['match']['docs'][0]
96 'title': metadata
['name'],
97 'description': metadata
.get('description'),
98 'duration': int_or_none(metadata
.get('runtime')),
99 'thumbnail': metadata
.get('image'),
100 'timestamp': parse_iso8601(metadata
.get('releaseDate'))