]>
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, | |
9 | parse_duration, | |
10 | int_or_none, | |
11 | ) | |
f1155409 TS |
12 | |
13 | ||
14 | class Lecture2GoIE(InfoExtractor): | |
981b9cdc | 15 | _VALID_URL = r'https?://lecture2go\.uni-hamburg\.de/veranstaltungen/-/v/(?P<id>\d+)' |
f1155409 TS |
16 | _TEST = { |
17 | 'url': 'https://lecture2go.uni-hamburg.de/veranstaltungen/-/v/17473', | |
1e124295 | 18 | 'md5': 'ac02b570883020d208d405d5a3fd2f7f', |
f1155409 TS |
19 | 'info_dict': { |
20 | 'id': '17473', | |
1e124295 YCH |
21 | 'ext': 'flv', |
22 | 'title': '2 - Endliche Automaten und reguläre Sprachen', | |
23 | 'creator': 'Frank Heitmann', | |
e9c6deff | 24 | 'duration': 5220, |
f1155409 TS |
25 | } |
26 | } | |
27 | ||
28 | def _real_extract(self, url): | |
29 | video_id = self._match_id(url) | |
30 | webpage = self._download_webpage(url, video_id) | |
31 | ||
981b9cdc | 32 | title = self._html_search_regex(r'<em[^>]+class="title">(.+)</em>', webpage, 'title') |
795704f0 YCH |
33 | |
34 | formats = [] | |
35 | for url in set(re.findall(r'"src","([^"]+)"', webpage)): | |
36 | ext = determine_ext(url) | |
37 | if ext == 'f4m': | |
38 | formats.extend(self._extract_f4m_formats(url, video_id)) | |
39 | elif ext == 'm3u8': | |
40 | formats.extend(self._extract_m3u8_formats(url, video_id)) | |
41 | else: | |
42 | formats.append({ | |
43 | 'url': url, | |
44 | }) | |
45 | ||
46 | self._sort_formats(formats) | |
47 | ||
40101dc3 YCH |
48 | creator = self._html_search_regex( |
49 | r'<div[^>]+id="description">([^<]+)</div>', webpage, 'creator', fatal=False) | |
e9c6deff YCH |
50 | duration = parse_duration(self._html_search_regex( |
51 | r'Duration:\s*</em>\s*<em[^>]*>([^<]+)</em>', webpage, 'duration', fatal=False)) | |
52 | view_count = int_or_none(self._html_search_regex( | |
53 | r'Views:\s*</em>\s*<em[^>]+>(\d+)</em>', webpage, 'view count', fatal=False)) | |
f1155409 TS |
54 | |
55 | return { | |
56 | 'id': video_id, | |
57 | 'title': title, | |
795704f0 | 58 | 'formats': formats, |
e9c6deff YCH |
59 | 'creator': creator, |
60 | 'duration': duration, | |
61 | 'view_count': view_count, | |
f1155409 | 62 | } |