You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

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