X-Git-Url: https://git.rapsys.eu/youtubedl/blobdiff_plain/415fdb62500dca2e22067a05008dfbf87c75b662..8e9fdda3f6b19fe564db1cedad8f9aa3f2af2a17:/youtube_dl/extractor/canalplus.py diff --git a/youtube_dl/extractor/canalplus.py b/youtube_dl/extractor/canalplus.py index 0202078..51c11cb 100644 --- a/youtube_dl/extractor/canalplus.py +++ b/youtube_dl/extractor/canalplus.py @@ -1,72 +1,116 @@ -# encoding: utf-8 +# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( + # ExtractorError, + # HEADRequest, + int_or_none, + qualities, unified_strdate, - url_basename, ) 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 = 'mycanal.fr and piwiplus.fr' + _VALID_URL = r'https?://(?:www\.)?(?Pmycanal|piwiplus)\.fr/(?:[^/]+/)*(?P[^?/]+)(?:\.html\?.*\bvid=|/p/)(?P\d+)' + _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s?format=json' + _SITE_ID_MAP = { + 'mycanal': 'cplus', + 'piwiplus': 'teletoon', + } + + # Only works for direct mp4 URLs + _GEO_COUNTRIES = ['FR'] - _TEST = { - 'url': 'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470', - 'md5': '3db39fb48b9685438ecf33a1078023e4', + _TESTS = [{ + 'url': 'https://www.mycanal.fr/d17-emissions/lolywood/p/1397061', 'info_dict': { - 'id': '922470', - 'ext': 'flv', - 'title': 'Zapping - 26/08/13', - 'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013', - 'upload_date': '20130826', + 'id': '1397061', + 'display_id': 'lolywood', + 'ext': 'mp4', + 'title': 'Euro 2016 : Je préfère te prévenir - Lolywood - Episode 34', + 'description': 'md5:7d97039d455cb29cdba0d652a0efaa5e', + 'upload_date': '20160602', }, - } + }, { + # geo restricted, bypassed + 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190', + 'info_dict': { + 'id': '1108190', + 'display_id': 'pid1405-le-labyrinthe-boing-super-ranger', + 'ext': 'mp4', + 'title': 'BOING SUPER RANGER - Ep : Le labyrinthe', + 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff', + 'upload_date': '20140724', + }, + 'expected_warnings': ['HTTP Error 403: Forbidden'], + }] def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - video_id = mobj.groupdict().get('id') + site, display_id, video_id = re.match(self._VALID_URL, url).groups() - # Beware, some subclasses do not define an id group - display_id = url_basename(mobj.group('path')) + site_id = self._SITE_ID_MAP[site] - if video_id is None: - webpage = self._download_webpage(url, display_id) - video_id = self._search_regex(r'