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