logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

nick.py (11055B)


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