]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tele5.py
Update README.md
[youtubedl] / 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 .jwplatform import JWPlatformIE
8 from .nexx import NexxIE
9 from ..compat import compat_urlparse
10 from ..utils import (
11 NO_DEFAULT,
12 smuggle_url,
13 )
14
15
16 class Tele5IE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?tele5\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)'
18 _GEO_COUNTRIES = ['DE']
19 _TESTS = [{
20 'url': 'https://www.tele5.de/mediathek/filme-online/videos?vid=1549416',
21 'info_dict': {
22 'id': '1549416',
23 'ext': 'mp4',
24 'upload_date': '20180814',
25 'timestamp': 1534290623,
26 'title': 'Pandorum',
27 },
28 'params': {
29 'skip_download': True,
30 },
31 }, {
32 # jwplatform, nexx unavailable
33 'url': 'https://www.tele5.de/filme/ghoul-das-geheimnis-des-friedhofmonsters/',
34 'info_dict': {
35 'id': 'WJuiOlUp',
36 'ext': 'mp4',
37 'upload_date': '20200603',
38 'timestamp': 1591214400,
39 'title': 'Ghoul - Das Geheimnis des Friedhofmonsters',
40 'description': 'md5:42002af1d887ff3d5b2b3ca1f8137d97',
41 },
42 'params': {
43 'skip_download': True,
44 },
45 'add_ie': [JWPlatformIE.ie_key()],
46 }, {
47 'url': 'https://www.tele5.de/kalkofes-mattscheibe/video-clips/politik-und-gesellschaft?ve_id=1551191',
48 'only_matching': True,
49 }, {
50 'url': 'https://www.tele5.de/video-clip/?ve_id=1609440',
51 'only_matching': True,
52 }, {
53 'url': 'https://www.tele5.de/filme/schlefaz-dragon-crusaders/',
54 'only_matching': True,
55 }, {
56 'url': 'https://www.tele5.de/filme/making-of/avengers-endgame/',
57 'only_matching': True,
58 }, {
59 'url': 'https://www.tele5.de/star-trek/raumschiff-voyager/ganze-folge/das-vinculum/',
60 'only_matching': True,
61 }, {
62 'url': 'https://www.tele5.de/anders-ist-sevda/',
63 'only_matching': True,
64 }]
65
66 def _real_extract(self, url):
67 qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
68 video_id = (qs.get('vid') or qs.get('ve_id') or [None])[0]
69
70 NEXX_ID_RE = r'\d{6,}'
71 JWPLATFORM_ID_RE = r'[a-zA-Z0-9]{8}'
72
73 def nexx_result(nexx_id):
74 return self.url_result(
75 'https://api.nexx.cloud/v3/759/videos/byid/%s' % nexx_id,
76 ie=NexxIE.ie_key(), video_id=nexx_id)
77
78 nexx_id = jwplatform_id = None
79
80 if video_id:
81 if re.match(NEXX_ID_RE, video_id):
82 return nexx_result(video_id)
83 elif re.match(JWPLATFORM_ID_RE, video_id):
84 jwplatform_id = video_id
85
86 if not nexx_id:
87 display_id = self._match_id(url)
88 webpage = self._download_webpage(url, display_id)
89
90 def extract_id(pattern, name, default=NO_DEFAULT):
91 return self._html_search_regex(
92 (r'id\s*=\s*["\']video-player["\'][^>]+data-id\s*=\s*["\'](%s)' % pattern,
93 r'\s+id\s*=\s*["\']player_(%s)' % pattern,
94 r'\bdata-id\s*=\s*["\'](%s)' % pattern), webpage, name,
95 default=default)
96
97 nexx_id = extract_id(NEXX_ID_RE, 'nexx id', default=None)
98 if nexx_id:
99 return nexx_result(nexx_id)
100
101 if not jwplatform_id:
102 jwplatform_id = extract_id(JWPLATFORM_ID_RE, 'jwplatform id')
103
104 return self.url_result(
105 smuggle_url(
106 'jwplatform:%s' % jwplatform_id,
107 {'geo_countries': self._GEO_COUNTRIES}),
108 ie=JWPlatformIE.ie_key(), video_id=jwplatform_id)