logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

rbgtum.py (3305B)


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