2016-08-28 16:47:59 +01:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2018-08-27 18:17:30 -07:00
|
|
|
import re
|
|
|
|
|
2016-08-28 16:47:59 +01:00
|
|
|
from .turner import TurnerBaseIE
|
|
|
|
|
|
|
|
|
|
|
|
class CartoonNetworkIE(TurnerBaseIE):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?cartoonnetwork\.com/video/(?:[^/]+/)+(?P<id>[^/?#]+)-(?:clip|episode)\.html'
|
|
|
|
_TEST = {
|
2018-08-27 15:23:56 -07:00
|
|
|
'url': 'https://www.cartoonnetwork.com/video/steven-universe/garnet-gets-a-job-clip.html',
|
2016-08-28 16:47:59 +01:00
|
|
|
'info_dict': {
|
2018-08-27 15:23:56 -07:00
|
|
|
'id': '96bc363957a17bc03d16feb86b8391a321f7e670',
|
2016-08-28 16:47:59 +01:00
|
|
|
'ext': 'mp4',
|
2018-08-27 15:23:56 -07:00
|
|
|
'title': 'Garnet Gets a Job',
|
|
|
|
'description': 'Garnet and Steven explore the most unlikely timelines in Beach City.',
|
|
|
|
},
|
2016-08-28 16:47:59 +01:00
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
2018-08-27 18:17:30 -07:00
|
|
|
video_id = self._html_search_regex(r'[^>]+.mediaId = "(.+?)"', webpage, 'video_id')
|
|
|
|
title = self._html_search_regex(r'[^>]+.episodeTitle = "(.+?)"', webpage, 'title')
|
2018-09-04 16:12:28 -07:00
|
|
|
auth = self._html_search_regex(r'[^>]+.authType = "(.+?)"', webpage, 'authType')
|
|
|
|
if "unauth" in auth:
|
2018-09-04 17:02:17 -07:00
|
|
|
auth_required = ''
|
2018-09-04 16:12:28 -07:00
|
|
|
if "auth" in auth:
|
|
|
|
auth_required = 'true'
|
2018-08-27 18:17:30 -07:00
|
|
|
videoType = self._html_search_regex(r'[^>]+.videoType = "(.+?)"', webpage, 'videoType')
|
2018-08-27 16:03:37 -07:00
|
|
|
if 'short' in videoType:
|
|
|
|
description = ''
|
|
|
|
else:
|
2018-09-04 16:12:28 -07:00
|
|
|
description = self._html_search_regex(r'id="[^>]+description[^>]*>(.+?)</div>', webpage, 'description')
|
2018-08-18 18:27:16 -07:00
|
|
|
info = self._extract_ngtv_info(
|
|
|
|
video_id,
|
|
|
|
{'networkId': 'cartoonnetwork'},
|
|
|
|
{
|
2016-09-20 18:51:29 +01:00
|
|
|
'url': url,
|
|
|
|
'site_name': 'CartoonNetwork',
|
2018-08-24 17:15:40 -07:00
|
|
|
'auth_required': auth_required,
|
2018-08-18 18:27:16 -07:00
|
|
|
},
|
|
|
|
)
|
|
|
|
info.update({
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'description': description,
|
|
|
|
})
|
|
|
|
return info
|