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