From fb8f04688ac4a72ccf024142a3ccae8a67ae8792 Mon Sep 17 00:00:00 2001 From: TRox1972 Date: Sun, 3 Jul 2016 00:39:35 +0200 Subject: [PATCH 1/2] [Nintendo] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/nintendo.py | 34 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 youtube_dl/extractor/nintendo.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 9f98a1490..b2dda2a19 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -522,6 +522,7 @@ from .nick import ( ) from .niconico import NiconicoIE, NiconicoPlaylistIE from .ninegag import NineGagIE +from .nintendo import NintendoIE from .noco import NocoIE from .normalboots import NormalbootsIE from .nosvideo import NosVideoIE diff --git a/youtube_dl/extractor/nintendo.py b/youtube_dl/extractor/nintendo.py new file mode 100644 index 000000000..cafddd3a2 --- /dev/null +++ b/youtube_dl/extractor/nintendo.py @@ -0,0 +1,34 @@ +from __future__ import unicode_literals + +from .common import InfoExtractor +from .ooyala import OoyalaIE + + +class NintendoIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?nintendo\.com/games/detail/(?P[\w-]+)' + _TESTS = [{ + 'url': 'http://www.nintendo.com/games/detail/yEiAzhU2eQI1KZ7wOHhngFoAHc1FpHwj', + 'info_dict': { + 'id': 'MzMmticjp0VPzO3CCj4rmFOuohEuEWoW', + 'ext': 'flv', + 'title': 'Duck Hunt Wii U VC NES - Trailer', + 'duration': 60.326, + }, + 'params': { + 'skip_download': True, + }, + 'add_ie': ['Ooyala'], + }, { + 'url': 'http://www.nintendo.com/games/detail/tokyo-mirage-sessions-fe-wii-u', + 'only_matching': True, + }] + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + ooyala_code = self._search_regex( + r'data-video-code=(["\'])(?P.+?)\1', + webpage, 'ooyala code', group='code') + + return OoyalaIE._build_url_result(ooyala_code) From 6bc3e36dd82c1b247a43f9171de2e660df85974e Mon Sep 17 00:00:00 2001 From: TRox1972 Date: Sun, 3 Jul 2016 01:06:55 +0200 Subject: [PATCH 2/2] [Nintedo] Add playlist support --- youtube_dl/extractor/nintendo.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/nintendo.py b/youtube_dl/extractor/nintendo.py index cafddd3a2..57333ada0 100644 --- a/youtube_dl/extractor/nintendo.py +++ b/youtube_dl/extractor/nintendo.py @@ -3,6 +3,8 @@ from __future__ import unicode_literals from .common import InfoExtractor from .ooyala import OoyalaIE +import re + class NintendoIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?nintendo\.com/games/detail/(?P[\w-]+)' @@ -20,15 +22,26 @@ class NintendoIE(InfoExtractor): 'add_ie': ['Ooyala'], }, { 'url': 'http://www.nintendo.com/games/detail/tokyo-mirage-sessions-fe-wii-u', - 'only_matching': True, + 'info_dict': { + 'id': 'tokyo-mirage-sessions-fe-wii-u', + }, + '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) - ooyala_code = self._search_regex( + ooyala_codes = re.findall( r'data-video-code=(["\'])(?P.+?)\1', - webpage, 'ooyala code', group='code') + webpage) - return OoyalaIE._build_url_result(ooyala_code) + entries = [] + for ooyala_code in ooyala_codes: + entries.append(OoyalaIE._build_url_result(ooyala_code[1])) + + return self.playlist_result(entries, video_id, self._og_search_title(webpage))