]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/lecture2go.py
[dailymotion] Error spelling
[youtube-dl] / youtube_dl / extractor / lecture2go.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8     determine_ext,
9     parse_duration,
10     int_or_none,
11 )
12
13
14 class Lecture2GoIE(InfoExtractor):
15     _VALID_URL = r'https?://lecture2go\.uni-hamburg\.de/veranstaltungen/-/v/(?P<id>\d+)'
16     _TEST = {
17         'url': 'https://lecture2go.uni-hamburg.de/veranstaltungen/-/v/17473',
18         'md5': 'ac02b570883020d208d405d5a3fd2f7f',
19         'info_dict': {
20             'id': '17473',
21             'ext': 'flv',
22             'title': '2 - Endliche Automaten und reguläre Sprachen',
23             'creator': 'Frank Heitmann',
24             'duration': 5220,
25         }
26     }
27
28     def _real_extract(self, url):
29         video_id = self._match_id(url)
30         webpage = self._download_webpage(url, video_id)
31
32         title = self._html_search_regex(r'<em[^>]+class="title">(.+)</em>', webpage, 'title')
33
34         formats = []
35         for url in set(re.findall(r'"src","([^"]+)"', webpage)):
36             ext = determine_ext(url)
37             if ext == 'f4m':
38                 formats.extend(self._extract_f4m_formats(url, video_id))
39             elif ext == 'm3u8':
40                 formats.extend(self._extract_m3u8_formats(url, video_id))
41             else:
42                 formats.append({
43                     'url': url,
44                 })
45
46         self._sort_formats(formats)
47
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
55         return {
56             'id': video_id,
57             'title': title,
58             'formats': formats,
59             'creator': creator,
60             'duration': duration,
61             'view_count': view_count,
62         }