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