]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/unistra.py
Add support for https for all extractors as preventive and future-proof measure
[yt-dlp.git] / youtube_dl / extractor / unistra.py
CommitLineData
a2f0cdc0
S
1from __future__ import unicode_literals
2
f527115b
JMF
3import re
4
5from .common import InfoExtractor
a2f0cdc0
S
6from ..utils import qualities
7
f527115b
JMF
8
9class 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 })
a2f0cdc0
S
52
53 title = self._html_search_regex(
54 r'<title>UTV - (.*?)</', webpage, 'title')
55 description = self._html_search_regex(
56 r'<meta name="Description" content="(.*?)"', webpage, 'description', flags=re.DOTALL)
57 thumbnail = self._search_regex(
58 r'image: "(.*?)"', webpage, 'thumbnail')
59
60 return {
61 'id': video_id,
62 'title': title,
63 'description': description,
64 'thumbnail': thumbnail,
65 'formats': formats
66 }