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
|
|
|
|
|
2019-01-11 20:59:42 -08:00
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
)
|
2016-08-28 16:47:59 +01:00
|
|
|
|
|
|
|
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')
|
2018-09-11 15:52:10 -07:00
|
|
|
title = self._html_search_regex(r'[^>]+.episodeTitle = "(.+?)"', webpage, 'title')
|
2018-09-11 15:38:19 -07:00
|
|
|
description = self._html_search_regex(r'[^>]+description[^>]*>(.+?)<', webpage, 'description', default=None)
|
2019-01-11 20:59:42 -08:00
|
|
|
propertyName = self._html_search_regex(r'[^>]+.propertyName = "(.+?)"', webpage, 'propertyName', default=None)
|
|
|
|
seriesId = self._html_search_regex(r'[^>]+.seriesId = "(.+?)"', webpage, 'seriesId', default=None)
|
|
|
|
seasonNumber = self._html_search_regex(r'[^>]+.seasonNumber = "(.+?)"', webpage, 'seasonNumber', default=None)
|
|
|
|
episodeNumber = self._html_search_regex(r'[^>]+.episodeNumber = "(.+?)"', webpage, 'episodeNumber', default=None)
|
2018-09-05 17:59:56 -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-09-11 15:38:19 -07:00
|
|
|
'auth_required': self._search_regex(
|
|
|
|
r'[^>]+currentVideo.authType = "(auth|unauth)"',
|
|
|
|
webpage, 'auth required', default='false') == 'auth',
|
2018-09-05 17:59:56 -07:00
|
|
|
},
|
|
|
|
)
|
2018-08-18 18:27:16 -07:00
|
|
|
info.update({
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'description': description,
|
2019-01-11 20:59:42 -08:00
|
|
|
'series': propertyName,
|
|
|
|
'season_number': int_or_none(seasonNumber),
|
|
|
|
'season_id': int_or_none(seriesId),
|
|
|
|
'episode_number': int_or_none(episodeNumber),
|
2018-08-18 18:27:16 -07:00
|
|
|
})
|
|
|
|
return info
|