mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-10 23:07:16 +08:00
Merge pull request #183 from ytdl-org/master
[pull] master from ytdl-org:master
This commit is contained in:
commit
d960fa8167
@ -5,13 +5,12 @@ import re
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from .ooyala import OoyalaIE
|
from .ooyala import OoyalaIE
|
||||||
from ..utils import unescapeHTML
|
|
||||||
|
|
||||||
|
|
||||||
class NintendoIE(InfoExtractor):
|
class NintendoIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?nintendo\.com/games/detail/(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https?://(?:www\.)?nintendo\.com/(?:games/detail|nintendo-direct)/(?P<id>[^/?#&]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.nintendo.com/games/detail/yEiAzhU2eQI1KZ7wOHhngFoAHc1FpHwj',
|
'url': 'https://www.nintendo.com/games/detail/duck-hunt-wii-u/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'MzMmticjp0VPzO3CCj4rmFOuohEuEWoW',
|
'id': 'MzMmticjp0VPzO3CCj4rmFOuohEuEWoW',
|
||||||
'ext': 'flv',
|
'ext': 'flv',
|
||||||
@ -28,7 +27,19 @@ class NintendoIE(InfoExtractor):
|
|||||||
'id': 'tokyo-mirage-sessions-fe-wii-u',
|
'id': 'tokyo-mirage-sessions-fe-wii-u',
|
||||||
'title': 'Tokyo Mirage Sessions ♯FE',
|
'title': 'Tokyo Mirage Sessions ♯FE',
|
||||||
},
|
},
|
||||||
'playlist_count': 3,
|
'playlist_count': 4,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.nintendo.com/nintendo-direct/09-04-2019/',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'J2bXdmaTE6fe3dWJTPcc7m23FNbc_A1V',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Switch_ROS_ND0904-H264.mov',
|
||||||
|
'duration': 2324.758,
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
'add_ie': ['Ooyala'],
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
@ -39,8 +50,11 @@ class NintendoIE(InfoExtractor):
|
|||||||
entries = [
|
entries = [
|
||||||
OoyalaIE._build_url_result(m.group('code'))
|
OoyalaIE._build_url_result(m.group('code'))
|
||||||
for m in re.finditer(
|
for m in re.finditer(
|
||||||
r'class=(["\'])embed-video\1[^>]+data-video-code=(["\'])(?P<code>(?:(?!\2).)+)\2',
|
r'data-(?:video-id|directVideoId)=(["\'])(?P<code>(?:(?!\1).)+)\1', webpage)]
|
||||||
webpage)]
|
|
||||||
|
title = self._html_search_regex(
|
||||||
|
r'(?s)<(?:span|div)[^>]+class="(?:title|wrapper)"[^>]*>.*?<h1>(.+?)</h1>',
|
||||||
|
webpage, 'title', fatal=False)
|
||||||
|
|
||||||
return self.playlist_result(
|
return self.playlist_result(
|
||||||
entries, page_id, unescapeHTML(self._og_search_title(webpage, fatal=False)))
|
entries, page_id, title)
|
||||||
|
@ -23,8 +23,8 @@ class NRLTVIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
q_data = self._parse_json(self._search_regex(
|
q_data = self._parse_json(self._html_search_regex(
|
||||||
r"(?s)q-data='({.+?})'", webpage, 'player data'), display_id)
|
r'(?s)q-data="({.+?})"', webpage, 'player data'), display_id)
|
||||||
ooyala_id = q_data['videoId']
|
ooyala_id = q_data['videoId']
|
||||||
return self.url_result(
|
return self.url_result(
|
||||||
'ooyala:' + ooyala_id, 'Ooyala', ooyala_id, q_data.get('title'))
|
'ooyala:' + ooyala_id, 'Ooyala', ooyala_id, q_data.get('title'))
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import base64
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_b64decode,
|
compat_b64decode,
|
||||||
compat_str,
|
compat_str,
|
||||||
compat_urllib_parse_urlencode,
|
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
@ -21,9 +21,9 @@ from ..utils import (
|
|||||||
class OoyalaBaseIE(InfoExtractor):
|
class OoyalaBaseIE(InfoExtractor):
|
||||||
_PLAYER_BASE = 'http://player.ooyala.com/'
|
_PLAYER_BASE = 'http://player.ooyala.com/'
|
||||||
_CONTENT_TREE_BASE = _PLAYER_BASE + 'player_api/v1/content_tree/'
|
_CONTENT_TREE_BASE = _PLAYER_BASE + 'player_api/v1/content_tree/'
|
||||||
_AUTHORIZATION_URL_TEMPLATE = _PLAYER_BASE + 'sas/player_api/v2/authorization/embed_code/%s/%s?'
|
_AUTHORIZATION_URL_TEMPLATE = _PLAYER_BASE + 'sas/player_api/v2/authorization/embed_code/%s/%s'
|
||||||
|
|
||||||
def _extract(self, content_tree_url, video_id, domain='example.org', supportedformats=None, embed_token=None):
|
def _extract(self, content_tree_url, video_id, domain=None, supportedformats=None, embed_token=None):
|
||||||
content_tree = self._download_json(content_tree_url, video_id)['content_tree']
|
content_tree = self._download_json(content_tree_url, video_id)['content_tree']
|
||||||
metadata = content_tree[list(content_tree)[0]]
|
metadata = content_tree[list(content_tree)[0]]
|
||||||
embed_code = metadata['embed_code']
|
embed_code = metadata['embed_code']
|
||||||
@ -31,19 +31,22 @@ class OoyalaBaseIE(InfoExtractor):
|
|||||||
title = metadata['title']
|
title = metadata['title']
|
||||||
|
|
||||||
auth_data = self._download_json(
|
auth_data = self._download_json(
|
||||||
self._AUTHORIZATION_URL_TEMPLATE % (pcode, embed_code)
|
self._AUTHORIZATION_URL_TEMPLATE % (pcode, embed_code),
|
||||||
+ compat_urllib_parse_urlencode({
|
video_id, headers=self.geo_verification_headers(), query={
|
||||||
'domain': domain,
|
'domain': domain or 'player.ooyala.com',
|
||||||
'supportedFormats': supportedformats or 'mp4,rtmp,m3u8,hds,dash,smooth',
|
'supportedFormats': supportedformats or 'mp4,rtmp,m3u8,hds,dash,smooth',
|
||||||
'embedToken': embed_token,
|
'embedToken': embed_token,
|
||||||
}), video_id, headers=self.geo_verification_headers())
|
})['authorization_data'][embed_code]
|
||||||
|
|
||||||
cur_auth_data = auth_data['authorization_data'][embed_code]
|
|
||||||
|
|
||||||
urls = []
|
urls = []
|
||||||
formats = []
|
formats = []
|
||||||
if cur_auth_data['authorized']:
|
streams = auth_data.get('streams') or [{
|
||||||
for stream in cur_auth_data['streams']:
|
'delivery_type': 'hls',
|
||||||
|
'url': {
|
||||||
|
'data': base64.b64encode(('http://player.ooyala.com/hls/player/all/%s.m3u8' % embed_code).encode()).decode(),
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
for stream in streams:
|
||||||
url_data = try_get(stream, lambda x: x['url']['data'], compat_str)
|
url_data = try_get(stream, lambda x: x['url']['data'], compat_str)
|
||||||
if not url_data:
|
if not url_data:
|
||||||
continue
|
continue
|
||||||
@ -81,9 +84,9 @@ class OoyalaBaseIE(InfoExtractor):
|
|||||||
'vbr': int_or_none(stream.get('video_bitrate')),
|
'vbr': int_or_none(stream.get('video_bitrate')),
|
||||||
'fps': float_or_none(stream.get('framerate')),
|
'fps': float_or_none(stream.get('framerate')),
|
||||||
})
|
})
|
||||||
else:
|
if not formats and not auth_data.get('authorized'):
|
||||||
raise ExtractorError('%s said: %s' % (
|
raise ExtractorError('%s said: %s' % (
|
||||||
self.IE_NAME, cur_auth_data['message']), expected=True)
|
self.IE_NAME, auth_data['message']), expected=True)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
|
@ -1,35 +1,33 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from .ooyala import OoyalaIE
|
|
||||||
|
|
||||||
|
|
||||||
class TeachingChannelIE(InfoExtractor):
|
class TeachingChannelIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?teachingchannel\.org/videos/(?P<title>.+)'
|
_VALID_URL = r'https?://(?:www\.)?teachingchannel\.org/videos?/(?P<id>[^/?&#]+)'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://www.teachingchannel.org/videos/teacher-teaming-evolution',
|
'url': 'https://www.teachingchannel.org/videos/teacher-teaming-evolution',
|
||||||
'md5': '3d6361864d7cac20b57c8784da17166f',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'F3bnlzbToeI6pLEfRyrlfooIILUjz4nM',
|
'id': '3swwlzkT',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'A History of Teaming',
|
'title': 'A History of Teaming',
|
||||||
'description': 'md5:2a9033db8da81f2edffa4c99888140b3',
|
'description': 'md5:2a9033db8da81f2edffa4c99888140b3',
|
||||||
'duration': 422.255,
|
'duration': 422,
|
||||||
|
'upload_date': '20170316',
|
||||||
|
'timestamp': 1489691297,
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
'add_ie': ['Ooyala'],
|
'add_ie': ['JWPlatform'],
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
display_id = self._match_id(url)
|
||||||
title = mobj.group('title')
|
webpage = self._download_webpage(url, display_id)
|
||||||
webpage = self._download_webpage(url, title)
|
mid = self._search_regex(
|
||||||
ooyala_code = self._search_regex(
|
r'(?:data-mid=["\']|id=["\']jw-video-player-)([a-zA-Z0-9]{8})',
|
||||||
r'data-embed-code=\'(.+?)\'', webpage, 'ooyala code')
|
webpage, 'media id')
|
||||||
|
|
||||||
return OoyalaIE._build_url_result(ooyala_code)
|
return self.url_result('jwplatform:' + mid, 'JWPlatform', mid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user