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