]>
Commit | Line | Data |
---|---|---|
45b2ee6f | 1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
4 | ||
5 | ||
6 | class RbgTumIE(InfoExtractor): | |
7 | _VALID_URL = r'https://live\.rbg\.tum\.de/w/(?P<id>.+)' | |
8 | _TESTS = [{ | |
9 | # Combined view | |
10 | 'url': 'https://live.rbg.tum.de/w/cpp/22128', | |
11 | 'md5': '53a5e7b3e07128e33bbf36687fe1c08f', | |
12 | 'info_dict': { | |
13 | 'id': 'cpp/22128', | |
14 | 'ext': 'mp4', | |
15 | 'title': 'Lecture: October 18. 2022', | |
16 | 'series': 'Concepts of C++ programming (IN2377)', | |
17 | } | |
18 | }, { | |
19 | # Presentation only | |
20 | 'url': 'https://live.rbg.tum.de/w/I2DL/12349/PRES', | |
21 | 'md5': '36c584272179f3e56b0db5d880639cba', | |
22 | 'info_dict': { | |
23 | 'id': 'I2DL/12349/PRES', | |
24 | 'ext': 'mp4', | |
25 | 'title': 'Lecture 3: Introduction to Neural Networks', | |
26 | 'series': 'Introduction to Deep Learning (IN2346)', | |
27 | } | |
28 | }, { | |
29 | # Camera only | |
30 | 'url': 'https://live.rbg.tum.de/w/fvv-info/16130/CAM', | |
31 | 'md5': 'e04189d92ff2f56aedf5cede65d37aad', | |
32 | 'info_dict': { | |
33 | 'id': 'fvv-info/16130/CAM', | |
34 | 'ext': 'mp4', | |
35 | 'title': 'Fachschaftsvollversammlung', | |
36 | 'series': 'Fachschaftsvollversammlung Informatik', | |
37 | } | |
38 | }, ] | |
39 | ||
40 | def _real_extract(self, url): | |
41 | video_id = self._match_id(url) | |
42 | webpage = self._download_webpage(url, video_id) | |
43 | ||
44 | m3u8 = self._html_search_regex(r'(https://.+?\.m3u8)', webpage, 'm3u8') | |
45 | lecture_title = self._html_search_regex(r'(?si)<h1.*?>(.*)</h1>', webpage, 'title') | |
46 | lecture_series_title = self._html_search_regex( | |
47 | r'(?s)<title\b[^>]*>\s*(?:TUM-Live\s\|\s?)?([^:]+):?.*?</title>', webpage, 'series') | |
48 | ||
49 | formats = self._extract_m3u8_formats(m3u8, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls') | |
50 | ||
51 | return { | |
52 | 'id': video_id, | |
53 | 'title': lecture_title, | |
54 | 'series': lecture_series_title, | |
55 | 'formats': formats, | |
56 | } | |
57 | ||
58 | ||
59 | class RbgTumCourseIE(InfoExtractor): | |
60 | _VALID_URL = r'https://live\.rbg\.tum\.de/course/(?P<id>.+)' | |
61 | _TESTS = [{ | |
62 | 'url': 'https://live.rbg.tum.de/course/2022/S/fpv', | |
63 | 'info_dict': { | |
64 | 'title': 'Funktionale Programmierung und Verifikation (IN0003)', | |
65 | 'id': '2022/S/fpv', | |
66 | }, | |
67 | 'params': { | |
68 | 'noplaylist': False, | |
69 | }, | |
70 | 'playlist_count': 13, | |
71 | }, { | |
72 | 'url': 'https://live.rbg.tum.de/course/2022/W/set', | |
73 | 'info_dict': { | |
74 | 'title': 'SET FSMPIC', | |
75 | 'id': '2022/W/set', | |
76 | }, | |
77 | 'params': { | |
78 | 'noplaylist': False, | |
79 | }, | |
80 | 'playlist_count': 6, | |
81 | }, ] | |
82 | ||
83 | def _real_extract(self, url): | |
84 | course_id = self._match_id(url) | |
85 | webpage = self._download_webpage(url, course_id) | |
86 | ||
87 | lecture_series_title = self._html_search_regex(r'(?si)<h1.*?>(.*)</h1>', webpage, 'title') | |
88 | ||
89 | lecture_urls = [] | |
90 | for lecture_url in re.findall(r'(?i)href="/w/(.+)(?<!/cam)(?<!/pres)(?<!/chat)"', webpage): | |
91 | lecture_urls.append(self.url_result('https://live.rbg.tum.de/w/' + lecture_url, ie=RbgTumIE.ie_key())) | |
92 | ||
93 | return self.playlist_result(lecture_urls, course_id, lecture_series_title) |