]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/canalc2.py
[canalc2] fix info extraction
[yt-dlp.git] / 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'https?://(www\.)?canalc2\.tv/video/(?P<id>\d+)'
12
13 _TEST = {
14 'url': 'http://www.canalc2.tv/video/12163',
15 'md5': '060158428b650f896c542dfbb3d6487f',
16 'info_dict': {
17 'id': '12163',
18 'ext': 'mp4',
19 'title': 'Terrasses du Numérique'
20 },
21 'params': {
22 'skip_download': True, # Requires rtmpdump
23 }
24 }
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id)
29 video_url = self._search_regex(
30 r'jwplayer\("Player"\).setup\({[^}]*file: "([^"]+)"',
31 webpage, 'video_url')
32 formats = [{'url': video_url}]
33 if video_url.startswith('rtmp://'):
34 rtmp = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<play_path>mp4:.+)$', video_url)
35 formats[0].update({
36 'app': rtmp.group('app'),
37 'play_path': rtmp.group('play_path'),
38 })
39
40 title = self._html_search_regex(
41 r'(?s)class="[^"]*col_description[^"]*">.*?<h3>(.*?)</h3>', webpage, 'title')
42
43 return {
44 'id': video_id,
45 'formats': formats,
46 'title': title,
47 }