1 from .turner
import TurnerBaseIE
2 from ..utils
import int_or_none
5 class CartoonNetworkIE(TurnerBaseIE
):
6 _VALID_URL
= r
'https?://(?:www\.)?cartoonnetwork\.com/video/(?:[^/]+/)+(?P<id>[^/?#]+)-(?:clip|episode)\.html'
8 'url': 'https://www.cartoonnetwork.com/video/ben-10/how-to-draw-upgrade-episode.html',
10 'id': '6e3375097f63874ebccec7ef677c1c3845fa850e',
12 'title': 'How to Draw Upgrade',
13 'description': 'md5:2061d83776db7e8be4879684eefe8c0f',
17 'skip_download': True,
21 def _real_extract(self
, url
):
22 display_id
= self
._match
_id
(url
)
23 webpage
= self
._download
_webpage
(url
, display_id
)
25 def find_field(global_re
, name
, content_re
=None, value_re
='[^"]+', fatal
=False):
28 metadata_re
= r
'|video_metadata\.content_' + content_re
29 return self
._search
_regex
(
30 rf
'(?:_cnglobal\.currentVideo\.{global_re}{metadata_re})\s*=\s*"({value_re})";',
31 webpage
, name
, fatal
=fatal
)
33 media_id
= find_field('mediaId', 'media id', 'id', '[0-9a-f]{40}', True)
34 title
= find_field('episodeTitle', 'title', '(?:episodeName|name)', fatal
=True)
36 info
= self
._extract
_ngtv
_info
(
37 media_id
, {'networkId': 'cartoonnetwork'}, {
39 'site_name': 'CartoonNetwork',
40 'auth_required': find_field('authType', 'auth type') != 'unauth',
44 'propertyName', 'series', 'showName') or self
._html
_search
_meta
('partOfSeries', webpage
)
47 'display_id': display_id
,
49 'description': self
._html
_search
_meta
('description', webpage
),
54 for field
in ('season', 'episode'):
55 field_name
= field
+ 'Number'
56 info
[field
+ '_number'] = int_or_none(find_field(
57 field_name
, field
+ ' number', value_re
=r
'\d+') or self
._html
_search
_meta
(field_name
, webpage
))