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.

42 lines
1.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .turner import TurnerBaseIE
  5. class CartoonNetworkIE(TurnerBaseIE):
  6. _VALID_URL = r'https?://(?:www\.)?cartoonnetwork\.com/video/(?:[^/]+/)+(?P<id>[^/?#]+)-(?:clip|episode)\.html'
  7. _TEST = {
  8. 'url': 'http://www.cartoonnetwork.com/video/teen-titans-go/starfire-the-cat-lady-clip.html',
  9. 'info_dict': {
  10. 'id': '8a250ab04ed07e6c014ef3f1e2f9016c',
  11. 'ext': 'mp4',
  12. 'title': 'Starfire the Cat Lady',
  13. 'description': 'Robin decides to become a cat so that Starfire will finally love him.',
  14. },
  15. 'params': {
  16. # m3u8 download
  17. 'skip_download': True,
  18. },
  19. }
  20. def _real_extract(self, url):
  21. display_id = self._match_id(url)
  22. webpage = self._download_webpage(url, display_id)
  23. id_type, video_id = re.search(r"_cnglobal\.cvp(Video|Title)Id\s*=\s*'([^']+)';", webpage).groups()
  24. query = ('id' if id_type == 'Video' else 'titleId') + '=' + video_id
  25. return self._extract_cvp_info(
  26. 'http://www.cartoonnetwork.com/video-seo-svc/episodeservices/getCvpPlaylist?networkName=CN2&' + query, video_id, {
  27. 'secure': {
  28. 'media_src': 'http://androidhls-secure.cdn.turner.com/toon/big',
  29. 'tokenizer_src': 'http://www.cartoonnetwork.com/cntv/mvpd/processors/services/token_ipadAdobe.do',
  30. },
  31. }, {
  32. 'url': url,
  33. 'site_name': 'CartoonNetwork',
  34. 'auth_required': self._search_regex(
  35. r'_cnglobal\.cvpFullOrPreviewAuth\s*=\s*(true|false);',
  36. webpage, 'auth required', default='false') == 'true',
  37. })