[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / lecture2go.py
blob6157f3da345a33c5d740345723baaef61c2ab78e
1 import re
3 from .common import InfoExtractor
4 from ..utils import (
5 determine_ext,
6 determine_protocol,
7 int_or_none,
8 parse_duration,
12 class Lecture2GoIE(InfoExtractor):
13 _WORKING = False
14 _VALID_URL = r'https?://lecture2go\.uni-hamburg\.de/veranstaltungen/-/v/(?P<id>\d+)'
15 _TEST = {
16 'url': 'https://lecture2go.uni-hamburg.de/veranstaltungen/-/v/17473',
17 'md5': 'ac02b570883020d208d405d5a3fd2f7f',
18 'info_dict': {
19 'id': '17473',
20 'ext': 'mp4',
21 'title': '2 - Endliche Automaten und reguläre Sprachen',
22 'creator': 'Frank Heitmann',
23 'duration': 5220,
25 'params': {
26 # m3u8 download
27 'skip_download': True,
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33 webpage = self._download_webpage(url, video_id)
35 title = self._html_search_regex(r'<em[^>]+class="title">(.+)</em>', webpage, 'title')
37 formats = []
38 for url in set(re.findall(r'var\s+playerUri\d+\s*=\s*"([^"]+)"', webpage)):
39 ext = determine_ext(url)
40 protocol = determine_protocol({'url': url})
41 if ext == 'f4m':
42 formats.extend(self._extract_f4m_formats(url, video_id, f4m_id='hds'))
43 elif ext == 'm3u8':
44 formats.extend(self._extract_m3u8_formats(url, video_id, ext='mp4', m3u8_id='hls'))
45 else:
46 if protocol == 'rtmp':
47 continue # XXX: currently broken
48 formats.append({
49 'format_id': protocol,
50 'url': url,
53 creator = self._html_search_regex(
54 r'<div[^>]+id="description">([^<]+)</div>', webpage, 'creator', fatal=False)
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))
60 return {
61 'id': video_id,
62 'title': title,
63 'formats': formats,
64 'creator': creator,
65 'duration': duration,
66 'view_count': view_count,