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.

75 lines
3.0 KiB

7 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. extract_attributes,
  7. int_or_none,
  8. )
  9. class PokemonIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?pokemon\.com/[a-z]{2}(?:.*?play=(?P<id>[a-z0-9]{32})|/(?:[^/]+/)+(?P<display_id>[^/?#&]+))'
  11. _TESTS = [{
  12. 'url': 'https://www.pokemon.com/us/pokemon-episodes/20_30-the-ol-raise-and-switch/',
  13. 'md5': '2fe8eaec69768b25ef898cda9c43062e',
  14. 'info_dict': {
  15. 'id': 'afe22e30f01c41f49d4f1d9eab5cd9a4',
  16. 'ext': 'mp4',
  17. 'title': 'The Ol’ Raise and Switch!',
  18. 'description': 'md5:7db77f7107f98ba88401d3adc80ff7af',
  19. 'timestamp': 1511824728,
  20. 'upload_date': '20171127',
  21. },
  22. 'add_id': ['LimelightMedia'],
  23. }, {
  24. # no data-video-title
  25. 'url': 'https://www.pokemon.com/us/pokemon-episodes/pokemon-movies/pokemon-the-rise-of-darkrai-2008',
  26. 'info_dict': {
  27. 'id': '99f3bae270bf4e5097274817239ce9c8',
  28. 'ext': 'mp4',
  29. 'title': 'Pokémon: The Rise of Darkrai',
  30. 'description': 'md5:ea8fbbf942e1e497d54b19025dd57d9d',
  31. 'timestamp': 1417778347,
  32. 'upload_date': '20141205',
  33. },
  34. 'add_id': ['LimelightMedia'],
  35. 'params': {
  36. 'skip_download': True,
  37. },
  38. }, {
  39. 'url': 'http://www.pokemon.com/uk/pokemon-episodes/?play=2e8b5c761f1d4a9286165d7748c1ece2',
  40. 'only_matching': True,
  41. }, {
  42. 'url': 'http://www.pokemon.com/fr/episodes-pokemon/18_09-un-hiver-inattendu/',
  43. 'only_matching': True,
  44. }, {
  45. 'url': 'http://www.pokemon.com/de/pokemon-folgen/01_20-bye-bye-smettbo/',
  46. 'only_matching': True,
  47. }]
  48. def _real_extract(self, url):
  49. video_id, display_id = re.match(self._VALID_URL, url).groups()
  50. webpage = self._download_webpage(url, video_id or display_id)
  51. video_data = extract_attributes(self._search_regex(
  52. r'(<[^>]+data-video-id="%s"[^>]*>)' % (video_id if video_id else '[a-z0-9]{32}'),
  53. webpage, 'video data element'))
  54. video_id = video_data['data-video-id']
  55. title = video_data.get('data-video-title') or self._html_search_meta(
  56. 'pkm-title', webpage, ' title', default=None) or self._search_regex(
  57. r'<h1[^>]+\bclass=["\']us-title[^>]+>([^<]+)', webpage, 'title')
  58. return {
  59. '_type': 'url_transparent',
  60. 'id': video_id,
  61. 'url': 'limelight:media:%s' % video_id,
  62. 'title': title,
  63. 'description': video_data.get('data-video-summary'),
  64. 'thumbnail': video_data.get('data-video-poster'),
  65. 'series': 'Pokémon',
  66. 'season_number': int_or_none(video_data.get('data-video-season')),
  67. 'episode': title,
  68. 'episode_number': int_or_none(video_data.get('data-video-episode')),
  69. 'ie_key': 'LimelightMedia',
  70. }