From 72975729c89a5b0c73ecb4e5dccca38ed2dfb013 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sergey=20M=E2=80=A4?= Date: Fri, 31 Oct 2014 20:19:30 +0700 Subject: [PATCH] [canalplus] Tweak extractor to support piwiplus (Closes #4046) --- youtube_dl/extractor/canalplus.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/canalplus.py b/youtube_dl/extractor/canalplus.py index 0202078b0..4ee65c763 100644 --- a/youtube_dl/extractor/canalplus.py +++ b/youtube_dl/extractor/canalplus.py @@ -11,11 +11,15 @@ from ..utils import ( class CanalplusIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.canalplus\.fr/.*?/(?P.*)|player\.canalplus\.fr/#/(?P[0-9]+))' - _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' - IE_NAME = 'canalplus.fr' + IE_DESC = 'canalplus.fr and piwiplus.fr' + _VALID_URL = r'https?://(?:www\.(?Pcanal|piwi)plus\.fr/.*?/(?P.*)|player\.canalplus\.fr/#/(?P[0-9]+))' + _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s' + _SITE_ID_MAP = { + 'canal': 'cplus', + 'piwi': 'teletoon', + } - _TEST = { + _TESTS = [{ 'url': 'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470', 'md5': '3db39fb48b9685438ecf33a1078023e4', 'info_dict': { @@ -25,20 +29,33 @@ class CanalplusIE(InfoExtractor): 'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013', 'upload_date': '20130826', }, - } + }, { + 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190', + 'md5': '3db39fb48b9685438ecf33a1078023e4', + 'info_dict': { + 'id': '1108190', + 'ext': 'flv', + 'title': 'Le labyrinthe - Boing super ranger', + 'description': 'md5:', + 'upload_date': '20140724', + }, + }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.groupdict().get('id') + site_id = self._SITE_ID_MAP[mobj.group('site') or 'canal'] + # Beware, some subclasses do not define an id group display_id = url_basename(mobj.group('path')) if video_id is None: webpage = self._download_webpage(url, display_id) - video_id = self._search_regex(r']+?videoId="(\d+)"', webpage, 'video id') - info_url = self._VIDEO_INFO_TEMPLATE % video_id + info_url = self._VIDEO_INFO_TEMPLATE % (site_id, video_id) doc = self._download_xml(info_url, video_id, 'Downloading video XML') video_info = [video for video in doc if video.find('ID').text == video_id][0] -- 2.22.2