mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-11 03:52:52 +08:00
[nhl] get 60fps videos and default first media item
This commit is contained in:
parent
d9218ed9a8
commit
7d4af4d53c
@ -357,11 +357,11 @@ class NHLIE(InfoExtractor):
|
|||||||
|
|
||||||
class NHLTVIE(InfoExtractor):
|
class NHLTVIE(InfoExtractor):
|
||||||
IE_NAME = 'nhl.com:nhltv'
|
IE_NAME = 'nhl.com:nhltv'
|
||||||
_VALID_URL = r'https?://(?:www\.)?nhl.com/tv/(?P<gameId>\d+)/(?:[^/]+/)*(?P<id>\d+)'
|
_VALID_URL = r'https?://(?:www\.)?nhl.com/tv/(?P<gameId>\d+)(/[^/]+)*(/(?P<id>\d+))?'
|
||||||
_OAUTH_URL = 'https://user.svc.nhl.com/oauth/token?grant_type=client_credentials'
|
_OAUTH_URL = 'https://user.svc.nhl.com/oauth/token?grant_type=client_credentials'
|
||||||
_LOGIN_URL = 'https://gateway.web.nhl.com/ws/subscription/flow/nhlPurchase.login'
|
_LOGIN_URL = 'https://gateway.web.nhl.com/ws/subscription/flow/nhlPurchase.login'
|
||||||
_NETRC_MACHINE = 'nhltv'
|
_NETRC_MACHINE = 'nhltv'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
# This is a free video that can be accessed by anyone with an NHL TV login
|
# This is a free video that can be accessed by anyone with an NHL TV login
|
||||||
'url': 'https://www.nhl.com/tv/2016020321/221-1003765/46561403',
|
'url': 'https://www.nhl.com/tv/2016020321/221-1003765/46561403',
|
||||||
'md5': '34d9518c495ebdad947b9723b5a7c9a9',
|
'md5': '34d9518c495ebdad947b9723b5a7c9a9',
|
||||||
@ -376,8 +376,14 @@ class NHLTVIE(InfoExtractor):
|
|||||||
'usenetrc': True,
|
'usenetrc': True,
|
||||||
'format': '[width=400]',
|
'format': '[width=400]',
|
||||||
'hls_use_mpegts': True,
|
'hls_use_mpegts': True,
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.nhl.com/tv/2016020362/221-1003808',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.nhl.com/tv/2016020373',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _login(self):
|
def _login(self):
|
||||||
# TODO cache login to avoid 'Sign-on restriction: Too many usage attempts'
|
# TODO cache login to avoid 'Sign-on restriction: Too many usage attempts'
|
||||||
@ -454,19 +460,25 @@ class NHLTVIE(InfoExtractor):
|
|||||||
if epg_item.get("title") != "NHLTV":
|
if epg_item.get("title") != "NHLTV":
|
||||||
continue
|
continue
|
||||||
for item in epg_item.get('items', []):
|
for item in epg_item.get('items', []):
|
||||||
if item.get('mediaPlaybackId') != video_id:
|
if item.get('mediaPlaybackId') == video_id or video_id == None:
|
||||||
continue
|
|
||||||
feed_type = item.get('mediaFeedType')
|
feed_type = item.get('mediaFeedType')
|
||||||
|
video_id = item.get('mediaPlaybackId')
|
||||||
timestamp = parse_iso8601(media_node.get('milestones').get('streamStart'))
|
timestamp = parse_iso8601(media_node.get('milestones').get('streamStart'))
|
||||||
title = "%s: %s @ %s (%s feed)" % (date, away, home, feed_type)
|
title = "%s: %s @ %s (%s feed)" % (date, away, home, feed_type)
|
||||||
return (title, timestamp)
|
return (video_id, title, timestamp)
|
||||||
|
|
||||||
|
|
||||||
|
def get_60fps_playlist(self, url):
|
||||||
|
"""Returns a modified url that adds a 60 fps broadcast"""
|
||||||
|
return re.sub('_wired_web', '_wired60', url)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id, game_id = mobj.group('id'), mobj.group('gameId')
|
video_id, game_id = mobj.group('id'), mobj.group('gameId')
|
||||||
|
|
||||||
title, timestamp = self.extract_game_info(video_id, game_id)
|
video_id, title, timestamp = self.extract_game_info(video_id, game_id)
|
||||||
media_auth, m3u8_url = self.extract_stream_info(video_id)
|
media_auth, m3u8_url = self.extract_stream_info(video_id)
|
||||||
|
m3u8_url = self.get_60fps_playlist(m3u8_url)
|
||||||
|
|
||||||
# media auth cookie is required for the downloader
|
# media auth cookie is required for the downloader
|
||||||
self._set_cookie('nhl.com', 'mediaAuth_v2', media_auth)
|
self._set_cookie('nhl.com', 'mediaAuth_v2', media_auth)
|
||||||
|
Loading…
Reference in New Issue
Block a user