]>
Commit | Line | Data |
---|---|---|
f1155409 TS |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
795704f0 YCH |
4 | import re |
5 | ||
f1155409 | 6 | from .common import InfoExtractor |
e9c6deff YCH |
7 | from ..utils import ( |
8 | determine_ext, | |
73d93f94 | 9 | determine_protocol, |
e9c6deff YCH |
10 | parse_duration, |
11 | int_or_none, | |
12 | ) | |
f1155409 TS |
13 | |
14 | ||
15 | class Lecture2GoIE(InfoExtractor): | |
981b9cdc | 16 | _VALID_URL = r'https?://lecture2go\.uni-hamburg\.de/veranstaltungen/-/v/(?P<id>\d+)' |
f1155409 TS |
17 | _TEST = { |
18 | 'url': 'https://lecture2go.uni-hamburg.de/veranstaltungen/-/v/17473', | |
1e124295 | 19 | 'md5': 'ac02b570883020d208d405d5a3fd2f7f', |
f1155409 TS |
20 | 'info_dict': { |
21 | 'id': '17473', | |
73d93f94 | 22 | 'ext': 'mp4', |
1e124295 YCH |
23 | 'title': '2 - Endliche Automaten und reguläre Sprachen', |
24 | 'creator': 'Frank Heitmann', | |
e9c6deff | 25 | 'duration': 5220, |
73d93f94 YCH |
26 | }, |
27 | 'params': { | |
28 | # m3u8 download | |
29 | 'skip_download': True, | |
f1155409 TS |
30 | } |
31 | } | |
32 | ||
33 | def _real_extract(self, url): | |
34 | video_id = self._match_id(url) | |
35 | webpage = self._download_webpage(url, video_id) | |
36 | ||
981b9cdc | 37 | title = self._html_search_regex(r'<em[^>]+class="title">(.+)</em>', webpage, 'title') |
795704f0 YCH |
38 | |
39 | formats = [] | |
73d93f94 | 40 | for url in set(re.findall(r'var\s+playerUri\d+\s*=\s*"([^"]+)"', webpage)): |
795704f0 | 41 | ext = determine_ext(url) |
73d93f94 | 42 | protocol = determine_protocol({'url': url}) |
795704f0 | 43 | if ext == 'f4m': |
73d93f94 | 44 | formats.extend(self._extract_f4m_formats(url, video_id, f4m_id='hds')) |
795704f0 | 45 | elif ext == 'm3u8': |
73d93f94 | 46 | formats.extend(self._extract_m3u8_formats(url, video_id, ext='mp4', m3u8_id='hls')) |
795704f0 | 47 | else: |
73d93f94 YCH |
48 | if protocol == 'rtmp': |
49 | continue # XXX: currently broken | |
795704f0 | 50 | formats.append({ |
73d93f94 | 51 | 'format_id': protocol, |
795704f0 YCH |
52 | 'url': url, |
53 | }) | |
54 | ||
55 | self._sort_formats(formats) | |
56 | ||
40101dc3 YCH |
57 | creator = self._html_search_regex( |
58 | r'<div[^>]+id="description">([^<]+)</div>', webpage, 'creator', fatal=False) | |
e9c6deff YCH |
59 | duration = parse_duration(self._html_search_regex( |
60 | r'Duration:\s*</em>\s*<em[^>]*>([^<]+)</em>', webpage, 'duration', fatal=False)) | |
61 | view_count = int_or_none(self._html_search_regex( | |
62 | r'Views:\s*</em>\s*<em[^>]+>(\d+)</em>', webpage, 'view count', fatal=False)) | |
f1155409 TS |
63 | |
64 | return { | |
65 | 'id': video_id, | |
66 | 'title': title, | |
795704f0 | 67 | 'formats': formats, |
e9c6deff YCH |
68 | 'creator': creator, |
69 | 'duration': duration, | |
70 | 'view_count': view_count, | |
f1155409 | 71 | } |