[tele5] Add extractor
[youtube-dl] / youtube_dl / extractor / tele5.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from .nexx import NexxIE
8
9
10 class Tele5IE(InfoExtractor):
11     _VALID_URL = r'https://www\.tele5\.de/(?:mediathek/filme-online/videos\?vid=|tv/)(?P<display_id>[\w-]+)'
12
13     _TESTS = [{
14         'url': 'https://www.tele5.de/mediathek/filme-online/videos?vid=1550589',
15         'info_dict': {
16             'id': '1550589',
17             'ext': 'mp4',
18             'upload_date': '20180822',
19             'timestamp': 1534927316,
20             'title': 'SchleFaZ: Atomic Shark',
21         }
22     }, {
23         'url': 'https://www.tele5.de/tv/dark-matter/videos',
24         'only_matching': True,
25     }]
26
27     def _real_extract(self, url):
28         mobj = re.match(self._VALID_URL, url)
29         display_id = mobj.group('display_id')
30
31         webpage = self._download_webpage(url, display_id)
32
33         video_id = self._html_search_regex(
34             r'id\s*=\s*["\']video-player["\']\s*data-id\s*=\s*["\']([0-9]+)["\']',
35             webpage, 'video_id')
36
37         return self.url_result(
38             'https://api.nexx.cloud/v3/759/videos/byid/%s' % video_id,
39             ie=NexxIE.ie_key(), video_id=video_id)