]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nintendo.py
Use canonical URL in Vcs-Git.
[youtubedl] / youtube_dl / extractor / nintendo.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from .ooyala import OoyalaIE
8
9
10 class NintendoIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?nintendo\.com/(?:games/detail|nintendo-direct)/(?P<id>[^/?#&]+)'
12 _TESTS = [{
13 'url': 'https://www.nintendo.com/games/detail/duck-hunt-wii-u/',
14 'info_dict': {
15 'id': 'MzMmticjp0VPzO3CCj4rmFOuohEuEWoW',
16 'ext': 'flv',
17 'title': 'Duck Hunt Wii U VC NES - Trailer',
18 'duration': 60.326,
19 },
20 'params': {
21 'skip_download': True,
22 },
23 'add_ie': ['Ooyala'],
24 }, {
25 'url': 'http://www.nintendo.com/games/detail/tokyo-mirage-sessions-fe-wii-u',
26 'info_dict': {
27 'id': 'tokyo-mirage-sessions-fe-wii-u',
28 'title': 'Tokyo Mirage Sessions ♯FE',
29 },
30 'playlist_count': 4,
31 }, {
32 'url': 'https://www.nintendo.com/nintendo-direct/09-04-2019/',
33 'info_dict': {
34 'id': 'J2bXdmaTE6fe3dWJTPcc7m23FNbc_A1V',
35 'ext': 'mp4',
36 'title': 'Switch_ROS_ND0904-H264.mov',
37 'duration': 2324.758,
38 },
39 'params': {
40 'skip_download': True,
41 },
42 'add_ie': ['Ooyala'],
43 }]
44
45 def _real_extract(self, url):
46 page_id = self._match_id(url)
47
48 webpage = self._download_webpage(url, page_id)
49
50 entries = [
51 OoyalaIE._build_url_result(m.group('code'))
52 for m in re.finditer(
53 r'data-(?:video-id|directVideoId)=(["\'])(?P<code>(?:(?!\1).)+)\1', webpage)]
54
55 title = self._html_search_regex(
56 r'(?s)<(?:span|div)[^>]+class="(?:title|wrapper)"[^>]*>.*?<h1>(.+?)</h1>',
57 webpage, 'title', fatal=False)
58
59 return self.playlist_result(
60 entries, page_id, title)