aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/canalplus.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-07-13 12:10:35 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-07-13 13:36:15 +0200
commitffca4b5c32280e416131faf43afa0cb26c55c8b0 (patch)
tree6c9a351671394390520917207e8dfa439ba05eae /youtube_dl/extractor/canalplus.py
parentb0e72bcf34a9eb8f62f055a7ccbf2d40d4f96c09 (diff)
Add CanalplusIE (closes #59 and closes #918)
Diffstat (limited to 'youtube_dl/extractor/canalplus.py')
-rw-r--r--youtube_dl/extractor/canalplus.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/youtube_dl/extractor/canalplus.py b/youtube_dl/extractor/canalplus.py
new file mode 100644
index 000000000..3b1c88876
--- /dev/null
+++ b/youtube_dl/extractor/canalplus.py
@@ -0,0 +1,46 @@
+import re
+import xml.etree.ElementTree
+
+from .common import InfoExtractor
+from ..utils import unified_strdate
+
+class CanalplusIE(InfoExtractor):
+ _VALID_URL = r'https?://www\.canalplus\.fr/.*?\?vid=(?P<id>\d+)'
+ _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s'
+ IE_NAME = u'canalplus.fr'
+
+ _TEST = {
+ u'url': u'http://www.canalplus.fr/c-divertissement/pid3351-c-le-petit-journal.html?vid=889861',
+ u'file': u'889861.flv',
+ u'md5': u'590a888158b5f0d6832f84001fbf3e99',
+ u'info_dict': {
+ u'title': u'Le Petit Journal 20/06/13 - La guerre des drone',
+ u'upload_date': u'20130620',
+ },
+ u'skip': u'Requires rtmpdump'
+ }
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ video_id = mobj.group('id')
+ info_url = self._VIDEO_INFO_TEMPLATE % video_id
+ info_page = self._download_webpage(info_url,video_id,
+ u'Downloading video info')
+
+ self.report_extraction(video_id)
+ doc = xml.etree.ElementTree.fromstring(info_page.encode('utf-8'))
+ video_info = [video for video in doc if video.find('ID').text == video_id][0]
+ infos = video_info.find('INFOS')
+ media = video_info.find('MEDIA')
+ formats = [media.find('VIDEOS/%s' % format)
+ for format in ['BAS_DEBIT', 'HAUT_DEBIT', 'HD']]
+ video_url = [format.text for format in formats if format is not None][-1]
+
+ return {'id': video_id,
+ 'title': u'%s - %s' % (infos.find('TITRAGE/TITRE').text,
+ infos.find('TITRAGE/SOUS_TITRE').text),
+ 'url': video_url,
+ 'ext': 'flv',
+ 'upload_date': unified_strdate(infos.find('PUBLICATION/DATE').text),
+ 'thumbnail': media.find('IMAGES/GRAND').text,
+ }