]>
Commit | Line | Data |
---|---|---|
26a78d4b JMF |
1 | from __future__ import unicode_literals |
2 | ||
5b286728 PH |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
7bbc6428 S |
6 | from ..utils import ( |
7 | remove_end, | |
8 | parse_duration, | |
9 | ) | |
5b286728 PH |
10 | |
11 | ||
12 | class NBAIE(InfoExtractor): | |
2ff7f897 | 13 | _VALID_URL = r'https?://(?:watch\.|www\.)?nba\.com/(?:nba/)?video(?P<id>/[^?]*?)(?:/index\.html)?(?:\?.*)?$' |
6f5ac90c | 14 | _TEST = { |
26a78d4b | 15 | 'url': 'http://www.nba.com/video/games/nets/2012/12/04/0021200253-okc-bkn-recap.nba/index.html', |
7bbc6428 | 16 | 'md5': 'c0edcfc37607344e2ff8f13c378c88a4', |
26a78d4b | 17 | 'info_dict': { |
2ff7f897 JMF |
18 | 'id': '0021200253-okc-bkn-recap.nba', |
19 | 'ext': 'mp4', | |
26a78d4b | 20 | 'title': 'Thunder vs. Nets', |
7bbc6428 S |
21 | 'description': 'Kevin Durant scores 32 points and dishes out six assists as the Thunder beat the Nets in Brooklyn.', |
22 | 'duration': 181, | |
26a78d4b | 23 | }, |
6f5ac90c | 24 | } |
5b286728 PH |
25 | |
26 | def _real_extract(self, url): | |
27 | mobj = re.match(self._VALID_URL, url) | |
2ff7f897 | 28 | video_id = mobj.group('id') |
5b286728 PH |
29 | |
30 | webpage = self._download_webpage(url, video_id) | |
31 | ||
26a78d4b | 32 | video_url = 'http://ht-mobile.cdn.turner.com/nba/big' + video_id + '_nba_1280x720.mp4' |
5b286728 PH |
33 | |
34 | shortened_video_id = video_id.rpartition('/')[2] | |
7bbc6428 S |
35 | title = remove_end( |
36 | self._og_search_title(webpage, default=shortened_video_id), ' : NBA.com') | |
37 | ||
38 | description = self._og_search_description(webpage) | |
39 | duration = parse_duration( | |
40 | self._html_search_meta('duration', webpage, 'duration', fatal=False)) | |
5b286728 | 41 | |
5b286728 | 42 | |
26a78d4b | 43 | return { |
5b286728 PH |
44 | 'id': shortened_video_id, |
45 | 'url': video_url, | |
5b286728 | 46 | 'title': title, |
5b286728 | 47 | 'description': description, |
7bbc6428 | 48 | 'duration': duration, |
5b286728 | 49 | } |