]> asedeno.scripts.mit.edu Git - youtube-dl.git/blob - youtube_dl/extractor/tele5.py
[NHK] Use new API URL
[youtube-dl.git] / youtube_dl / extractor / tele5.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from ..compat import compat_urlparse
5 from ..utils import (
6     ExtractorError,
7     extract_attributes,
8 )
9
10 from .dplay import DPlayIE
11
12
13 class Tele5IE(DPlayIE):
14     _VALID_URL = r'https?://(?:www\.)?tele5\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)'
15     _GEO_COUNTRIES = ['DE']
16     _TESTS = [{
17         'url': 'https://www.tele5.de/mediathek/filme-online/videos?vid=1549416',
18         'info_dict': {
19             'id': '1549416',
20             'ext': 'mp4',
21             'upload_date': '20180814',
22             'timestamp': 1534290623,
23             'title': 'Pandorum',
24         },
25         'params': {
26             'skip_download': True,
27         },
28         'skip': 'No longer available: "404 Seite nicht gefunden"',
29     }, {
30         # jwplatform, nexx unavailable
31         'url': 'https://www.tele5.de/filme/ghoul-das-geheimnis-des-friedhofmonsters/',
32         'info_dict': {
33             'id': 'WJuiOlUp',
34             'ext': 'mp4',
35             'upload_date': '20200603',
36             'timestamp': 1591214400,
37             'title': 'Ghoul - Das Geheimnis des Friedhofmonsters',
38             'description': 'md5:42002af1d887ff3d5b2b3ca1f8137d97',
39         },
40         'params': {
41             'skip_download': True,
42         },
43         'skip': 'No longer available, redirects to Filme page',
44     }, {
45         'url': 'https://tele5.de/mediathek/angel-of-mine/',
46         'info_dict': {
47             'id': '1252360',
48             'ext': 'mp4',
49             'upload_date': '20220109',
50             'timestamp': 1641762000,
51             'title': 'Angel of Mine',
52             'description': 'md5:a72546a175e1286eb3251843a52d1ad7',
53         },
54         'params': {
55             'format': 'bestvideo',
56         },
57     }, {
58         'url': 'https://www.tele5.de/kalkofes-mattscheibe/video-clips/politik-und-gesellschaft?ve_id=1551191',
59         'only_matching': True,
60     }, {
61         'url': 'https://www.tele5.de/video-clip/?ve_id=1609440',
62         'only_matching': True,
63     }, {
64         'url': 'https://www.tele5.de/filme/schlefaz-dragon-crusaders/',
65         'only_matching': True,
66     }, {
67         'url': 'https://www.tele5.de/filme/making-of/avengers-endgame/',
68         'only_matching': True,
69     }, {
70         'url': 'https://www.tele5.de/star-trek/raumschiff-voyager/ganze-folge/das-vinculum/',
71         'only_matching': True,
72     }, {
73         'url': 'https://www.tele5.de/anders-ist-sevda/',
74         'only_matching': True,
75     }]
76
77     def _real_extract(self, url):
78         video_id = self._match_id(url)
79         webpage = self._download_webpage(url, video_id)
80         player_element = self._search_regex(r'(<hyoga-player\b[^>]+?>)', webpage, 'video player')
81         player_info = extract_attributes(player_element)
82         asset_id, country, realm = (player_info[x] for x in ('assetid', 'locale', 'realm', ))
83         endpoint = compat_urlparse.urlparse(player_info['endpoint']).hostname
84         source_type = player_info.get('sourcetype')
85         if source_type:
86             endpoint = '%s-%s' % (source_type, endpoint)
87         try:
88             return self._get_disco_api_info(url, asset_id, endpoint, realm, country)
89         except ExtractorError as e:
90             if getattr(e, 'message', '') == 'Missing deviceId in context':
91                 raise ExtractorError('DRM protected', cause=e, expected=True)
92             raise