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.

229 lines
10 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?://(?P<domain>(?:(?: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 _real_extract(self, url):
  65. domain, display_id = re.match(self._VALID_URL, url).groups()
  66. video_data = self._download_json(
  67. 'http://%s/data/video.endLevel.json' % domain,
  68. display_id, query={
  69. 'urlKey': display_id,
  70. })
  71. return self._get_videos_info(video_data['player'] + video_data['id'])
  72. class NickBrIE(MTVServicesInfoExtractor):
  73. IE_NAME = 'nickelodeon:br'
  74. _VALID_URL = r'https?://(?P<domain>(?:www\.)?nickjr|mundonick\.uol)\.com\.br/(?:programas/)?[^/]+/videos/(?:episodios/)?(?P<id>[^/?#.]+)'
  75. _TESTS = [{
  76. 'url': 'http://www.nickjr.com.br/patrulha-canina/videos/210-labirinto-de-pipoca/',
  77. 'only_matching': True,
  78. }, {
  79. 'url': 'http://mundonick.uol.com.br/programas/the-loud-house/videos/muitas-irmas/7ljo9j',
  80. 'only_matching': True,
  81. }]
  82. def _real_extract(self, url):
  83. domain, display_id = re.match(self._VALID_URL, url).groups()
  84. webpage = self._download_webpage(url, display_id)
  85. uri = self._search_regex(
  86. r'data-(?:contenturi|mgid)="([^"]+)', webpage, 'mgid')
  87. video_id = self._id_from_uri(uri)
  88. config = self._download_json(
  89. 'http://media.mtvnservices.com/pmt/e1/access/index.html',
  90. video_id, query={
  91. 'uri': uri,
  92. 'configtype': 'edge',
  93. }, headers={
  94. 'Referer': url,
  95. })
  96. info_url = self._remove_template_parameter(config['feedWithQueryParams'])
  97. if info_url == 'None':
  98. if domain.startswith('www.'):
  99. domain = domain[4:]
  100. content_domain = {
  101. 'mundonick.uol': 'mundonick.com.br',
  102. 'nickjr': 'br.nickelodeonjunior.tv',
  103. }[domain]
  104. query = {
  105. 'mgid': uri,
  106. 'imageEp': content_domain,
  107. 'arcEp': content_domain,
  108. }
  109. if domain == 'nickjr.com.br':
  110. query['ep'] = 'c4b16088'
  111. info_url = update_url_query(
  112. 'http://feeds.mtvnservices.com/od/feed/intl-mrss-player-feed', query)
  113. return self._get_videos_info_from_url(info_url, video_id)
  114. class NickDeIE(MTVServicesInfoExtractor):
  115. IE_NAME = 'nick.de'
  116. _VALID_URL = r'https?://(?:www\.)?(?P<host>nick\.(?:de|com\.pl|ch)|nickelodeon\.(?:nl|be|at|dk|no|se))/[^/]+/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  117. _TESTS = [{
  118. 'url': 'http://www.nick.de/playlist/3773-top-videos/videos/episode/17306-zu-wasser-und-zu-land-rauchende-erdnusse',
  119. 'only_matching': True,
  120. }, {
  121. 'url': 'http://www.nick.de/shows/342-icarly',
  122. 'only_matching': True,
  123. }, {
  124. 'url': 'http://www.nickelodeon.nl/shows/474-spongebob/videos/17403-een-kijkje-in-de-keuken-met-sandy-van-binnenuit',
  125. 'only_matching': True,
  126. }, {
  127. 'url': 'http://www.nickelodeon.at/playlist/3773-top-videos/videos/episode/77993-das-letzte-gefecht',
  128. 'only_matching': True,
  129. }, {
  130. 'url': 'http://www.nick.com.pl/seriale/474-spongebob-kanciastoporty/wideo/17412-teatr-to-jest-to-rodeo-oszolom',
  131. 'only_matching': True,
  132. }, {
  133. 'url': 'http://www.nickelodeon.no/program/2626-bulderhuset/videoer/90947-femteklasse-veronica-vs-vanzilla',
  134. 'only_matching': True,
  135. }, {
  136. 'url': 'http://www.nickelodeon.dk/serier/2626-hojs-hus/videoer/761-tissepause',
  137. 'only_matching': True,
  138. }, {
  139. 'url': 'http://www.nickelodeon.se/serier/2626-lugn-i-stormen/videos/998-',
  140. 'only_matching': True,
  141. }, {
  142. 'url': 'http://www.nick.ch/shows/2304-adventure-time-abenteuerzeit-mit-finn-und-jake',
  143. 'only_matching': True,
  144. }, {
  145. 'url': 'http://www.nickelodeon.be/afspeellijst/4530-top-videos/videos/episode/73917-inval-broodschapper-lariekoek-arie',
  146. 'only_matching': True,
  147. }]
  148. def _extract_mrss_url(self, webpage, host):
  149. return update_url_query(self._search_regex(
  150. r'data-mrss=(["\'])(?P<url>http.+?)\1', webpage, 'mrss url', group='url'),
  151. {'siteKey': host})
  152. def _real_extract(self, url):
  153. mobj = re.match(self._VALID_URL, url)
  154. video_id = mobj.group('id')
  155. host = mobj.group('host')
  156. webpage = self._download_webpage(url, video_id)
  157. mrss_url = self._extract_mrss_url(webpage, host)
  158. return self._get_videos_info_from_url(mrss_url, video_id)
  159. class NickNightIE(NickDeIE):
  160. IE_NAME = 'nicknight'
  161. _VALID_URL = r'https?://(?:www\.)(?P<host>nicknight\.(?:de|at|tv))/(?:playlist|shows)/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  162. _TESTS = [{
  163. 'url': 'http://www.nicknight.at/shows/977-awkward/videos/85987-nimmer-beste-freunde',
  164. 'only_matching': True,
  165. }, {
  166. 'url': 'http://www.nicknight.at/shows/977-awkward',
  167. 'only_matching': True,
  168. }, {
  169. 'url': 'http://www.nicknight.at/shows/1900-faking-it',
  170. 'only_matching': True,
  171. }]
  172. def _extract_mrss_url(self, webpage, *args):
  173. return self._search_regex(
  174. r'mrss\s*:\s*(["\'])(?P<url>http.+?)\1', webpage,
  175. 'mrss url', group='url')
  176. class NickRuIE(MTVServicesInfoExtractor):
  177. IE_NAME = 'nickelodeonru'
  178. _VALID_URL = r'https?://(?:www\.)nickelodeon\.(?:ru|fr|es|pt|ro|hu)/[^/]+/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  179. _TESTS = [{
  180. 'url': 'http://www.nickelodeon.ru/shows/henrydanger/videos/episodes/3-sezon-15-seriya-licenziya-na-polyot/pmomfb#playlist/7airc6',
  181. 'only_matching': True,
  182. }, {
  183. 'url': 'http://www.nickelodeon.ru/videos/smotri-na-nickelodeon-v-iyule/g9hvh7',
  184. 'only_matching': True,
  185. }, {
  186. 'url': 'http://www.nickelodeon.fr/programmes/bob-l-eponge/videos/le-marathon-de-booh-kini-bottom-mardi-31-octobre/nfn7z0',
  187. 'only_matching': True,
  188. }, {
  189. 'url': 'http://www.nickelodeon.es/videos/nickelodeon-consejos-tortitas/f7w7xy',
  190. 'only_matching': True,
  191. }, {
  192. 'url': 'http://www.nickelodeon.pt/series/spongebob-squarepants/videos/a-bolha-de-tinta-gigante/xutq1b',
  193. 'only_matching': True,
  194. }, {
  195. 'url': 'http://www.nickelodeon.ro/emisiuni/shimmer-si-shine/video/nahal-din-bomboane/uw5u2k',
  196. 'only_matching': True,
  197. }, {
  198. 'url': 'http://www.nickelodeon.hu/musorok/spongyabob-kockanadrag/videok/episodes/buborekfujas-az-elszakadt-nadrag/q57iob#playlist/k6te4y',
  199. 'only_matching': True,
  200. }]
  201. def _real_extract(self, url):
  202. video_id = self._match_id(url)
  203. webpage = self._download_webpage(url, video_id)
  204. mgid = self._extract_mgid(webpage)
  205. return self.url_result('http://media.mtvnservices.com/embed/%s' % mgid)