]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/unistra.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / unistra.py
CommitLineData
f527115b
JMF
1import re
2
3from .common import InfoExtractor
a2f0cdc0
S
4from ..utils import qualities
5
f527115b
JMF
6
7class UnistraIE(InfoExtractor):
5886b38d 8 _VALID_URL = r'https?://utv\.unistra\.fr/(?:index|video)\.php\?id_video\=(?P<id>\d+)'
a2f0cdc0
S
9
10 _TESTS = [
11 {
12 'url': 'http://utv.unistra.fr/video.php?id_video=154',
13 'md5': '736f605cfdc96724d55bb543ab3ced24',
14 'info_dict': {
15 'id': '154',
16 'ext': 'mp4',
17 'title': 'M!ss Yella',
18 'description': 'md5:104892c71bd48e55d70b902736b81bbf',
19 },
f527115b 20 },
a2f0cdc0
S
21 {
22 'url': 'http://utv.unistra.fr/index.php?id_video=437',
23 'md5': '1ddddd6cccaae76f622ce29b8779636d',
24 'info_dict': {
25 'id': '437',
26 'ext': 'mp4',
27 'title': 'Prix Louise Weiss 2014',
28 'description': 'md5:cc3a8735f079f4fb6b0b570fc10c135a',
29 },
add96eb9 30 },
a2f0cdc0 31 ]
f527115b
JMF
32
33 def _real_extract(self, url):
5ad28e7f 34 mobj = self._match_valid_url(url)
a2f0cdc0
S
35 video_id = mobj.group('id')
36
af8812bb 37 webpage = self._download_webpage(url, video_id)
a2f0cdc0 38
5cc9c5df 39 files = set(re.findall(r'file\s*:\s*"(/[^"]+)"', webpage))
a2f0cdc0
S
40
41 quality = qualities(['SD', 'HD'])
42 formats = []
43 for file_path in files:
44 format_id = 'HD' if file_path.endswith('-HD.mp4') else 'SD'
af8812bb 45 formats.append({
add96eb9 46 'url': f'http://vod-flash.u-strasbg.fr:8080{file_path}',
a2f0cdc0 47 'format_id': format_id,
add96eb9 48 'quality': quality(format_id),
af8812bb 49 })
a2f0cdc0
S
50
51 title = self._html_search_regex(
52 r'<title>UTV - (.*?)</', webpage, 'title')
53 description = self._html_search_regex(
54 r'<meta name="Description" content="(.*?)"', webpage, 'description', flags=re.DOTALL)
55 thumbnail = self._search_regex(
56 r'image: "(.*?)"', webpage, 'thumbnail')
57
58 return {
59 'id': video_id,
60 'title': title,
61 'description': description,
62 'thumbnail': thumbnail,
add96eb9 63 'formats': formats,
a2f0cdc0 64 }