mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 06:42:21 +00:00
[nba] use xpath utils
This commit is contained in:
parent
6a11bb77ba
commit
46cc1c65a4
@ -6,6 +6,8 @@ from .common import InfoExtractor
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
parse_duration,
|
parse_duration,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
xpath_text,
|
||||||
|
xpath_attr,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ class NBAIE(InfoExtractor):
|
|||||||
}, {
|
}, {
|
||||||
'url': 'http://www.nba.com/video/games/hornets/2014/12/05/0021400276-nyk-cha-play5.nba/',
|
'url': 'http://www.nba.com/video/games/hornets/2014/12/05/0021400276-nyk-cha-play5.nba/',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
},{
|
}, {
|
||||||
'url': 'http://watch.nba.com/video/channels/playoffs/2015/05/20/0041400301-cle-atl-recap.nba',
|
'url': 'http://watch.nba.com/video/channels/playoffs/2015/05/20/0041400301-cle-atl-recap.nba',
|
||||||
'md5': 'b2b39b81cf28615ae0c3360a3f9668c4',
|
'md5': 'b2b39b81cf28615ae0c3360a3f9668c4',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -43,11 +45,11 @@ class NBAIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
path, video_id = re.match(self._VALID_URL, url).groups()
|
path, video_id = re.match(self._VALID_URL, url).groups()
|
||||||
video_info = self._download_xml('http://www.nba.com/%s.xml' % path, video_id)
|
video_info = self._download_xml('http://www.nba.com/%s.xml' % path, video_id)
|
||||||
video_id = video_info.find('slug').text
|
video_id = xpath_text(video_info, 'slug')
|
||||||
title = video_info.find('headline').text
|
title = xpath_text(video_info, 'headline')
|
||||||
description = video_info.find('description').text
|
description = xpath_text(video_info, 'description')
|
||||||
duration = parse_duration(video_info.find('length').text)
|
duration = parse_duration(xpath_text(video_info, 'length'))
|
||||||
timestamp = int_or_none(video_info.find('dateCreated').attrib.get('uts'))
|
timestamp = int_or_none(xpath_attr(video_info, 'dateCreated', 'uts'))
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
for image in video_info.find('images'):
|
for image in video_info.find('images'):
|
||||||
|
Loading…
Reference in New Issue
Block a user