]>
Commit | Line | Data |
---|---|---|
f527115b JMF |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
a2f0cdc0 S |
4 | from ..utils import qualities |
5 | ||
f527115b JMF |
6 | |
7 | class 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 | }, | |
30 | } | |
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({ |
a2f0cdc0 S |
46 | 'url': 'http://vod-flash.u-strasbg.fr:8080%s' % file_path, |
47 | 'format_id': format_id, | |
48 | 'quality': quality(format_id) | |
af8812bb | 49 | }) |
abc1723e | 50 | self._sort_formats(formats) |
a2f0cdc0 S |
51 | |
52 | title = self._html_search_regex( | |
53 | r'<title>UTV - (.*?)</', webpage, 'title') | |
54 | description = self._html_search_regex( | |
55 | r'<meta name="Description" content="(.*?)"', webpage, 'description', flags=re.DOTALL) | |
56 | thumbnail = self._search_regex( | |
57 | r'image: "(.*?)"', webpage, 'thumbnail') | |
58 | ||
59 | return { | |
60 | 'id': video_id, | |
61 | 'title': title, | |
62 | 'description': description, | |
63 | 'thumbnail': thumbnail, | |
64 | 'formats': formats | |
65 | } |