X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fnintendo.py;h=ff8f70ba662a11a42df5c827e71ac54025bcb8c9;hb=0c92f1e96b004fc7a04eac0759f115a535c8e03a;hp=57333ada039a4ca614844c335e49c01497169ed1;hpb=a2f9ca1e67e6b926957abe3b35a4d78355bef7d4;p=youtube-dl diff --git a/youtube_dl/extractor/nintendo.py b/youtube_dl/extractor/nintendo.py index 57333ada0..ff8f70ba6 100644 --- a/youtube_dl/extractor/nintendo.py +++ b/youtube_dl/extractor/nintendo.py @@ -1,15 +1,16 @@ +# coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from .ooyala import OoyalaIE -import re - class NintendoIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?nintendo\.com/games/detail/(?P[\w-]+)' + _VALID_URL = r'https?://(?:www\.)?nintendo\.com/(?:games/detail|nintendo-direct)/(?P[^/?#&]+)' _TESTS = [{ - 'url': 'http://www.nintendo.com/games/detail/yEiAzhU2eQI1KZ7wOHhngFoAHc1FpHwj', + 'url': 'https://www.nintendo.com/games/detail/duck-hunt-wii-u/', 'info_dict': { 'id': 'MzMmticjp0VPzO3CCj4rmFOuohEuEWoW', 'ext': 'flv', @@ -24,24 +25,36 @@ class NintendoIE(InfoExtractor): 'url': 'http://www.nintendo.com/games/detail/tokyo-mirage-sessions-fe-wii-u', 'info_dict': { 'id': 'tokyo-mirage-sessions-fe-wii-u', + 'title': 'Tokyo Mirage Sessions ♯FE', + }, + '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'], - 'playlist_count': 4, }] def _real_extract(self, url): - video_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) + page_id = self._match_id(url) + + webpage = self._download_webpage(url, page_id) - ooyala_codes = re.findall( - r'data-video-code=(["\'])(?P.+?)\1', - webpage) + entries = [ + OoyalaIE._build_url_result(m.group('code')) + for m in re.finditer( + r'data-(?:video-id|directVideoId)=(["\'])(?P(?:(?!\1).)+)\1', webpage)] - entries = [] - for ooyala_code in ooyala_codes: - entries.append(OoyalaIE._build_url_result(ooyala_code[1])) + title = self._html_search_regex( + r'(?s)<(?:span|div)[^>]+class="(?:title|wrapper)"[^>]*>.*?

(.+?)

', + webpage, 'title', fatal=False) - return self.playlist_result(entries, video_id, self._og_search_title(webpage)) + return self.playlist_result( + entries, page_id, title)