]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/telemb.py
Merge branch 'Lovius-master'
[yt-dlp.git] / youtube_dl / extractor / telemb.py
CommitLineData
adf2c098
S
1# coding: utf-8
2from __future__ import unicode_literals
3
09334400 4import re
09334400 5
adf2c098
S
6from .common import InfoExtractor
7from ..utils import remove_start
09334400 8
09334400 9
adf2c098
S
10class TeleMBIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?telemb\.be/(?P<display_id>.+?)_d_(?P<id>\d+)\.html'
12 _TESTS = [
13 {
14 'url': 'http://www.telemb.be/mons-cook-with-danielle-des-cours-de-cuisine-en-anglais-_d_13466.html',
15 'md5': 'f45ea69878516ba039835794e0f8f783',
16 'info_dict': {
17 'id': '13466',
18 'display_id': 'mons-cook-with-danielle-des-cours-de-cuisine-en-anglais-',
19 'ext': 'mp4',
20 'title': 'Mons - Cook with Danielle : des cours de cuisine en anglais ! - Les reportages',
21 'description': 'md5:bc5225f47b17c309761c856ad4776265',
22 'thumbnail': 're:^http://.*\.(?:jpg|png)$',
23 }
24 },
25 {
26 'url': 'http://telemb.be/les-reportages-havre-incendie-mortel_d_13514.html',
27 'md5': '6e9682736e5ccd4eab7f21e855350733',
28 'info_dict': {
29 'id': '13514',
30 'display_id': 'les-reportages-havre-incendie-mortel',
31 'ext': 'mp4',
32 'title': 'Havré - Incendie mortel - Les reportages',
33 'description': 'md5:5e54cb449acb029c2b7734e2d946bd4a',
34 'thumbnail': 're:^http://.*\.(?:jpg|png)$',
35 }
36 },
37 ]
09334400
L
38
39 def _real_extract(self, url):
40 mobj = re.match(self._VALID_URL, url)
09334400 41 video_id = mobj.group('id')
adf2c098 42 display_id = mobj.group('display_id')
09334400 43
adf2c098 44 webpage = self._download_webpage(url, display_id)
09334400 45
adf2c098
S
46 formats = []
47 for video_url in re.findall(r'file\s*:\s*"([^"]+)"', webpage):
48 fmt = {
49 'url': video_url,
50 'format_id': video_url.split(':')[0]
51 }
52 rtmp = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+))/(?P<playpath>mp4:.+)$', video_url)
53 if rtmp:
54 fmt.update({
55 'play_path': rtmp.group('playpath'),
56 'app': rtmp.group('app'),
57 'player_url': 'http://p.jwpcdn.com/6/10/jwplayer.flash.swf',
58 'page_url': 'http://www.telemb.be',
59 'preference': -1,
60 })
61 formats.append(fmt)
62 self._sort_formats(formats)
09334400 63
adf2c098
S
64 title = remove_start(self._og_search_title(webpage), 'TéléMB : ')
65 description = self._html_search_regex(
66 r'<meta property="og:description" content="(.+?)" />',
67 webpage, 'description', fatal=False)
68 thumbnail = self._og_search_thumbnail(webpage)
09334400 69
adf2c098
S
70 return {
71 'id': video_id,
72 'display_id': display_id,
73 'title': title,
74 'description': description,
75 'thumbnail': thumbnail,
76 'formats': formats,
77 }