]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/canalc2.py
Implement a different adult sites checking algorithm
[youtube-dl] / youtube_dl / extractor / canalc2.py
1 # coding: utf-8
2 import re
3
4 from .common import InfoExtractor
5
6
7 class Canalc2IE(InfoExtractor):
8     IE_NAME = 'canalc2.tv'
9     _VALID_URL = r'http://.*?\.canalc2\.tv/video\.asp\?.*?idVideo=(?P<id>\d+)'
10
11     _TEST = {
12         u'url': u'http://www.canalc2.tv/video.asp?idVideo=12163&voir=oui',
13         u'file': u'12163.mp4',
14         u'md5': u'060158428b650f896c542dfbb3d6487f',
15         u'info_dict': {
16             u'title': u'Terrasses du Numérique'
17         }
18     }
19
20     def _real_extract(self, url):
21         video_id = re.match(self._VALID_URL, url).group('id')
22         # We need to set the voir field for getting the file name
23         url = 'http://www.canalc2.tv/video.asp?idVideo=%s&voir=oui' % video_id
24         webpage = self._download_webpage(url, video_id)
25         file_name = self._search_regex(
26             r"so\.addVariable\('file','(.*?)'\);",
27             webpage, 'file name')
28         video_url = 'http://vod-flash.u-strasbg.fr:8080/' + file_name
29
30         title = self._html_search_regex(
31             r'class="evenement8">(.*?)</a>', webpage, u'title')
32         
33         return {'id': video_id,
34                 'ext': 'mp4',
35                 'url': video_url,
36                 'title': title,
37                 }