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