]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[d8] inherit from CanalplusIE
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Tue, 19 Nov 2013 19:43:49 +0000 (20:43 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Tue, 19 Nov 2013 19:44:20 +0000 (20:44 +0100)
it reuses the same extraction process

youtube_dl/extractor/canalplus.py
youtube_dl/extractor/d8.py

index 1db9b24cf204cc26d68b1a1bdaff93577c3ae903..bfa2a8b4063163729b3d8c11d63d7567a81ab59e 100644 (file)
@@ -5,6 +5,7 @@ import xml.etree.ElementTree
 from .common import InfoExtractor
 from ..utils import unified_strdate
 
+
 class CanalplusIE(InfoExtractor):
     _VALID_URL = r'https?://(www\.canalplus\.fr/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>\d+))'
     _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s'
@@ -25,7 +26,7 @@ class CanalplusIE(InfoExtractor):
 
     def _real_extract(self, url):
         mobj = re.match(self._VALID_URL, url)
-        video_id = mobj.group('id')
+        video_id = mobj.groupdict().get('id')
         if video_id is None:
             webpage = self._download_webpage(url, mobj.group('path'))
             video_id = self._search_regex(r'videoId = "(\d+)";', webpage, u'video id')
index 5ce483b16ffa9f71848faa36643c27df7a847b30..a56842b161229e985a25e4baedbb1d480b1160f4 100644 (file)
@@ -1,11 +1,8 @@
 # encoding: utf-8
-import re
-import xml.etree.ElementTree
+from .canalplus import CanalplusIE
 
-from .common import InfoExtractor
-from ..utils import unified_strdate
 
-class D8IE(InfoExtractor):
+class D8IE(CanalplusIE):
     _VALID_URL = r'https?://www\.d8\.tv/.*?/(?P<path>.*)'
     _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/d8/%s'
     IE_NAME = u'd8.tv'
@@ -19,34 +16,7 @@ class D8IE(InfoExtractor):
             u'upload_date': u'20131108',
         },
         u'params': {
+            # rtmp
             u'skip_download': True,
         },
     }
-
-    def _real_extract(self, url):
-        mobj = re.match(self._VALID_URL, url)
-        webpage = self._download_webpage(url, mobj.group('path'))
-        video_id = self._search_regex(r'videoId = "(\d+)";', webpage, u'video 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,
-                'description': infos.find('DESCRIPTION').text,
-                'view_count': int(infos.find('NB_VUES').text),
-                }