You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

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