3 import xml.etree.ElementTree
5 from .common import InfoExtractor
14 class NHLIE(InfoExtractor):
16 _VALID_URL = r'https?://video(?P<team>\.[^.]*)?\.nhl\.com/videocenter/console\?.*?(?<=[?&])id=(?P<id>\d+)'
19 u'url': u'http://video.canucks.nhl.com/videocenter/console?catid=6?id=453614',
20 u'file': u'453614.mp4',
22 u'title': u'Quick clip: Weise 4-3 goal vs Flames',
23 u'description': u'Dale Weise scores his first of the season to put the Canucks up 4-3.',
25 u'upload_date': u'20131006',
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
32 json_url = 'http://video.nhl.com/videocenter/servlets/playlist?ids=%s&format=json' % video_id
33 info_json = self._download_webpage(json_url, video_id,
34 u'Downloading info json')
35 info_json = info_json.replace('\\\'', '\'')
36 info = json.loads(info_json)[0]
38 initial_video_url = info['publishPoint']
39 data = compat_urllib_parse.urlencode({
41 'path': initial_video_url.replace('.mp4', '_sd.mp4'),
43 path_url = 'http://video.nhl.com/videocenter/servlets/encryptvideopath?' + data
44 path_response = self._download_webpage(path_url, video_id,
45 u'Downloading final video url')
46 path_doc = xml.etree.ElementTree.fromstring(path_response)
47 video_url = path_doc.find('path').text
49 join = compat_urlparse.urljoin
52 'title': info['name'],
54 'ext': determine_ext(video_url),
55 'description': info['description'],
56 'duration': int(info['duration']),
57 'thumbnail': join(join(video_url, '/u/'), info['bigImage']),
58 'upload_date': unified_strdate(info['releaseDate'].split('.')[0]),