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