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.

62 lines
2.0 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. parse_duration,
  8. int_or_none,
  9. )
  10. class Lecture2GoIE(InfoExtractor):
  11. _VALID_URL = r'https?://lecture2go\.uni-hamburg\.de/veranstaltungen/-/v/(?P<id>\d+)'
  12. _TEST = {
  13. 'url': 'https://lecture2go.uni-hamburg.de/veranstaltungen/-/v/17473',
  14. 'md5': 'ac02b570883020d208d405d5a3fd2f7f',
  15. 'info_dict': {
  16. 'id': '17473',
  17. 'ext': 'flv',
  18. 'title': '2 - Endliche Automaten und reguläre Sprachen',
  19. 'creator': 'Frank Heitmann',
  20. 'duration': 5220,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. title = self._html_search_regex(r'<em[^>]+class="title">(.+)</em>', webpage, 'title')
  27. formats = []
  28. for url in set(re.findall(r'"src","([^"]+)"', webpage)):
  29. ext = determine_ext(url)
  30. if ext == 'f4m':
  31. formats.extend(self._extract_f4m_formats(url, video_id))
  32. elif ext == 'm3u8':
  33. formats.extend(self._extract_m3u8_formats(url, video_id))
  34. else:
  35. formats.append({
  36. 'url': url,
  37. })
  38. self._sort_formats(formats)
  39. creator = self._html_search_regex(
  40. r'<div[^>]+id="description">([^<]+)</div>', webpage, 'creator', fatal=False)
  41. duration = parse_duration(self._html_search_regex(
  42. r'Duration:\s*</em>\s*<em[^>]*>([^<]+)</em>', webpage, 'duration', fatal=False))
  43. view_count = int_or_none(self._html_search_regex(
  44. r'Views:\s*</em>\s*<em[^>]+>(\d+)</em>', webpage, 'view count', fatal=False))
  45. return {
  46. 'id': video_id,
  47. 'title': title,
  48. 'formats': formats,
  49. 'creator': creator,
  50. 'duration': duration,
  51. 'view_count': view_count,
  52. }