[nintendo] Add extractor
authorTRox1972 <TRox1972@users.noreply.github.com>
Sat, 2 Jul 2016 22:39:35 +0000 (00:39 +0200)
committerSergey M․ <dstftw@gmail.com>
Sat, 16 Jul 2016 16:58:53 +0000 (23:58 +0700)
youtube_dl/extractor/extractors.py
youtube_dl/extractor/nintendo.py [new file with mode: 0644]

index 45817d7df8a0196763411b50eada48f15f9f4205..2761f709569c9fe6e6e34c07c9b3dfefa6023c10 100644 (file)
@@ -538,6 +538,7 @@ from .niconico import NiconicoIE, NiconicoPlaylistIE
 from .ninecninemedia import NineCNineMediaIE
 from .ninegag import NineGagIE
 from .ninenow import NineNowIE
+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 (file)
index 0000000..57333ad
--- /dev/null
@@ -0,0 +1,47 @@
+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<id>[\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',
+        '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_codes = re.findall(
+            r'data-video-code=(["\'])(?P<code>.+?)\1',
+            webpage)
+
+        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))