]>
Commit | Line | Data |
---|---|---|
cd0abcc0 | 1 | # coding: utf-8 |
0568c352 PH |
2 | from __future__ import unicode_literals |
3 | ||
cd0abcc0 | 4 | import re |
cd0abcc0 PR |
5 | |
6 | from .common import InfoExtractor | |
b1bf0635 | 7 | from ..utils import parse_duration |
cd0abcc0 | 8 | |
e86ea47c | 9 | |
cd0abcc0 | 10 | class Canalc2IE(InfoExtractor): |
6b361ad5 | 11 | IE_NAME = 'canalc2.tv' |
ef6c868f | 12 | _VALID_URL = r'https?://(?:www\.)?canalc2\.tv/video/(?P<id>\d+)' |
cd0abcc0 PR |
13 | |
14 | _TEST = { | |
b0f001a6 | 15 | 'url': 'http://www.canalc2.tv/video/12163', |
0568c352 PH |
16 | 'md5': '060158428b650f896c542dfbb3d6487f', |
17 | 'info_dict': { | |
18 | 'id': '12163', | |
608945d4 S |
19 | 'ext': 'flv', |
20 | 'title': 'Terrasses du Numérique', | |
21 | 'duration': 122, | |
b0f001a6 | 22 | }, |
23 | 'params': { | |
24 | 'skip_download': True, # Requires rtmpdump | |
cd0abcc0 PR |
25 | } |
26 | } | |
27 | ||
28 | def _real_extract(self, url): | |
b0f001a6 | 29 | video_id = self._match_id(url) |
cd0abcc0 | 30 | webpage = self._download_webpage(url, video_id) |
b0f001a6 | 31 | video_url = self._search_regex( |
ef6c868f S |
32 | r'jwplayer\((["\'])Player\1\)\.setup\({[^}]*file\s*:\s*(["\'])(?P<file>.+?)\2', |
33 | webpage, 'video_url', group='file') | |
b0f001a6 | 34 | formats = [{'url': video_url}] |
35 | if video_url.startswith('rtmp://'): | |
6682049d | 36 | rtmp = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+/))(?P<play_path>mp4:.+)$', video_url) |
b0f001a6 | 37 | formats[0].update({ |
6682049d | 38 | 'url': rtmp.group('url'), |
14bddf35 | 39 | 'ext': 'flv', |
b0f001a6 | 40 | 'app': rtmp.group('app'), |
41 | 'play_path': rtmp.group('play_path'), | |
6682049d | 42 | 'page_url': url, |
b0f001a6 | 43 | }) |
ff242459 | 44 | |
e86ea47c | 45 | title = self._html_search_regex( |
b0f001a6 | 46 | r'(?s)class="[^"]*col_description[^"]*">.*?<h3>(.*?)</h3>', webpage, 'title') |
b1bf0635 S |
47 | duration = parse_duration(self._search_regex( |
48 | r'id=["\']video_duree["\'][^>]*>([^<]+)', | |
49 | webpage, 'duration', fatal=False)) | |
0568c352 PH |
50 | |
51 | return { | |
52 | 'id': video_id, | |
0568c352 | 53 | 'title': title, |
b1bf0635 S |
54 | 'duration': duration, |
55 | 'formats': formats, | |
0568c352 | 56 | } |