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.

148 lines
6.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .mtv import MTVServicesInfoExtractor
  5. from ..utils import update_url_query
  6. class NickIE(MTVServicesInfoExtractor):
  7. # None of videos on the website are still alive?
  8. IE_NAME = 'nick.com'
  9. _VALID_URL = r'https?://(?:(?:www|beta)\.)?nick(?:jr)?\.com/(?:[^/]+/)?(?:videos/clip|[^/]+/videos)/(?P<id>[^/?#.]+)'
  10. _FEED_URL = 'http://udat.mtvnservices.com/service1/dispatch.htm'
  11. _GEO_COUNTRIES = ['US']
  12. _TESTS = [{
  13. 'url': 'http://www.nick.com/videos/clip/alvinnn-and-the-chipmunks-112-full-episode.html',
  14. 'playlist': [
  15. {
  16. 'md5': '6e5adc1e28253bbb1b28ab05403dd4d4',
  17. 'info_dict': {
  18. 'id': 'be6a17b0-412d-11e5-8ff7-0026b9414f30',
  19. 'ext': 'mp4',
  20. 'title': 'ALVINNN!!! and The Chipmunks: "Mojo Missing/Who\'s The Animal" S1',
  21. 'description': 'Alvin is convinced his mojo was in a cap he gave to a fan, and must find a way to get his hat back before the Chipmunks’ big concert.\nDuring a costume visit to the zoo, Alvin finds himself mistaken for the real Tasmanian devil.',
  22. }
  23. },
  24. {
  25. 'md5': 'd7be441fc53a1d4882fa9508a1e5b3ce',
  26. 'info_dict': {
  27. 'id': 'be6b8f96-412d-11e5-8ff7-0026b9414f30',
  28. 'ext': 'mp4',
  29. 'title': 'ALVINNN!!! and The Chipmunks: "Mojo Missing/Who\'s The Animal" S2',
  30. 'description': 'Alvin is convinced his mojo was in a cap he gave to a fan, and must find a way to get his hat back before the Chipmunks’ big concert.\nDuring a costume visit to the zoo, Alvin finds himself mistaken for the real Tasmanian devil.',
  31. }
  32. },
  33. {
  34. 'md5': 'efffe1728a234b2b0d2f2b343dd1946f',
  35. 'info_dict': {
  36. 'id': 'be6cf7e6-412d-11e5-8ff7-0026b9414f30',
  37. 'ext': 'mp4',
  38. 'title': 'ALVINNN!!! and The Chipmunks: "Mojo Missing/Who\'s The Animal" S3',
  39. 'description': 'Alvin is convinced his mojo was in a cap he gave to a fan, and must find a way to get his hat back before the Chipmunks’ big concert.\nDuring a costume visit to the zoo, Alvin finds himself mistaken for the real Tasmanian devil.',
  40. }
  41. },
  42. {
  43. 'md5': '1ec6690733ab9f41709e274a1d5c7556',
  44. 'info_dict': {
  45. 'id': 'be6e3354-412d-11e5-8ff7-0026b9414f30',
  46. 'ext': 'mp4',
  47. 'title': 'ALVINNN!!! and The Chipmunks: "Mojo Missing/Who\'s The Animal" S4',
  48. 'description': 'Alvin is convinced his mojo was in a cap he gave to a fan, and must find a way to get his hat back before the Chipmunks’ big concert.\nDuring a costume visit to the zoo, Alvin finds himself mistaken for the real Tasmanian devil.',
  49. }
  50. },
  51. ],
  52. }, {
  53. 'url': 'http://www.nickjr.com/paw-patrol/videos/pups-save-a-goldrush-s3-ep302-full-episode/',
  54. 'only_matching': True,
  55. }, {
  56. 'url': 'http://beta.nick.com/nicky-ricky-dicky-and-dawn/videos/nicky-ricky-dicky-dawn-301-full-episode/',
  57. 'only_matching': True,
  58. }]
  59. def _get_feed_query(self, uri):
  60. return {
  61. 'feed': 'nick_arc_player_prime',
  62. 'mgid': uri,
  63. }
  64. def _extract_mgid(self, webpage):
  65. return self._search_regex(r'data-contenturi="([^"]+)', webpage, 'mgid')
  66. class NickDeIE(MTVServicesInfoExtractor):
  67. IE_NAME = 'nick.de'
  68. _VALID_URL = r'https?://(?:www\.)?(?P<host>nick\.(?:de|com\.pl)|nickelodeon\.(?:nl|at))/[^/]+/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  69. _TESTS = [{
  70. 'url': 'http://www.nick.de/playlist/3773-top-videos/videos/episode/17306-zu-wasser-und-zu-land-rauchende-erdnusse',
  71. 'only_matching': True,
  72. }, {
  73. 'url': 'http://www.nick.de/shows/342-icarly',
  74. 'only_matching': True,
  75. }, {
  76. 'url': 'http://www.nickelodeon.nl/shows/474-spongebob/videos/17403-een-kijkje-in-de-keuken-met-sandy-van-binnenuit',
  77. 'only_matching': True,
  78. }, {
  79. 'url': 'http://www.nickelodeon.at/playlist/3773-top-videos/videos/episode/77993-das-letzte-gefecht',
  80. 'only_matching': True,
  81. }, {
  82. 'url': 'http://www.nick.com.pl/seriale/474-spongebob-kanciastoporty/wideo/17412-teatr-to-jest-to-rodeo-oszolom',
  83. 'only_matching': True,
  84. }]
  85. def _extract_mrss_url(self, webpage, host):
  86. return update_url_query(self._search_regex(
  87. r'data-mrss=(["\'])(?P<url>http.+?)\1', webpage, 'mrss url', group='url'),
  88. {'siteKey': host})
  89. def _real_extract(self, url):
  90. mobj = re.match(self._VALID_URL, url)
  91. video_id = mobj.group('id')
  92. host = mobj.group('host')
  93. webpage = self._download_webpage(url, video_id)
  94. mrss_url = self._extract_mrss_url(webpage, host)
  95. return self._get_videos_info_from_url(mrss_url, video_id)
  96. class NickNightIE(NickDeIE):
  97. IE_NAME = 'nicknight'
  98. _VALID_URL = r'https?://(?:www\.)(?P<host>nicknight\.(?:de|at|tv))/(?:playlist|shows)/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  99. _TESTS = [{
  100. 'url': 'http://www.nicknight.at/shows/977-awkward/videos/85987-nimmer-beste-freunde',
  101. 'only_matching': True,
  102. }, {
  103. 'url': 'http://www.nicknight.at/shows/977-awkward',
  104. 'only_matching': True,
  105. }, {
  106. 'url': 'http://www.nicknight.at/shows/1900-faking-it',
  107. 'only_matching': True,
  108. }]
  109. def _extract_mrss_url(self, webpage, *args):
  110. return self._search_regex(
  111. r'mrss\s*:\s*(["\'])(?P<url>http.+?)\1', webpage,
  112. 'mrss url', group='url')
  113. class NickRuIE(MTVServicesInfoExtractor):
  114. IE_NAME = 'nickelodeonru'
  115. _VALID_URL = r'https?://(?:www\.)nickelodeon\.ru/(?:playlist|shows|videos)/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  116. _TESTS = [{
  117. 'url': 'http://www.nickelodeon.ru/shows/henrydanger/videos/episodes/3-sezon-15-seriya-licenziya-na-polyot/pmomfb#playlist/7airc6',
  118. 'only_matching': True,
  119. }, {
  120. 'url': 'http://www.nickelodeon.ru/videos/smotri-na-nickelodeon-v-iyule/g9hvh7',
  121. 'only_matching': True,
  122. }]
  123. def _real_extract(self, url):
  124. video_id = self._match_id(url)
  125. webpage = self._download_webpage(url, video_id)
  126. mgid = self._extract_mgid(webpage)
  127. return self.url_result('http://media.mtvnservices.com/embed/%s' % mgid)