]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/servus.py
1 from .common
import InfoExtractor
12 class ServusIE(InfoExtractor
):
17 servus\.com/(?:(?:at|de)/p/[^/]+|tv/videos)|
18 (?:servustv|pm-wissen)\.com/videos
20 /(?P<id>[aA]{2}-\w+|\d+-\d+)
24 'url': 'https://www.servustv.com/videos/aa-1t6vbu5pw1w12/',
25 'md5': '60474d4c21f3eb148838f215c37f02b9',
27 'id': 'AA-1T6VBU5PW1W12',
29 'title': 'Die GrĂ¼nen aus Sicht des Volkes',
30 'alt_title': 'Talk im Hangar-7 Voxpops Gruene',
31 'description': 'md5:1247204d85783afe3682644398ff2ec4',
32 'thumbnail': r
're:^https?://.*\.jpg',
34 'timestamp': 1605193976,
35 'upload_date': '20201112',
36 'series': 'Talk im Hangar-7',
39 'episode': 'Episode 31 - September 14',
44 'url': 'https://www.servus.com/de/p/Die-Gr%C3%BCnen-aus-Sicht-des-Volkes/AA-1T6VBU5PW1W12/',
45 'only_matching': True,
47 'url': 'https://www.servus.com/at/p/Wie-das-Leben-beginnt/1309984137314-381415152/',
48 'only_matching': True,
50 'url': 'https://www.servus.com/tv/videos/aa-1t6vbu5pw1w12/',
51 'only_matching': True,
53 'url': 'https://www.servus.com/tv/videos/1380889096408-1235196658/',
54 'only_matching': True,
56 'url': 'https://www.pm-wissen.com/videos/aa-24mus4g2w2112/',
57 'only_matching': True,
60 def _real_extract(self
, url
):
61 video_id
= self
._match
_id
(url
).upper()
63 token
= self
._download
_json
(
64 'https://auth.redbullmediahouse.com/token', video_id
,
65 'Downloading token', data
=urlencode_postdata({
66 'grant_type': 'client_credentials',
68 'Authorization': 'Basic SVgtMjJYNEhBNFdEM1cxMTpEdDRVSkFLd2ZOMG5IMjB1NGFBWTBmUFpDNlpoQ1EzNA==',
70 access_token
= token
['access_token']
71 token_type
= token
.get('token_type', 'Bearer')
73 video
= self
._download
_json
(
74 'https://sparkle-api.liiift.io/api/v1/stv/channels/international/assets/%s' % video_id
,
75 video_id
, 'Downloading video JSON', headers
={
76 'Authorization': '%s %s' % (token_type
, access_token
),
81 for resource
in video
['resources']:
82 if not isinstance(resource
, dict):
84 format_url
= url_or_none(resource
.get('url'))
87 extension
= resource
.get('extension')
88 type_
= resource
.get('type')
89 if extension
== 'jpg' or type_
== 'reference_keyframe':
90 thumbnail
= format_url
92 ext
= determine_ext(format_url
)
93 if type_
== 'dash' or ext
== 'mpd':
94 formats
.extend(self
._extract
_mpd
_formats
(
95 format_url
, video_id
, mpd_id
='dash', fatal
=False))
96 elif type_
== 'hls' or ext
== 'm3u8':
97 formats
.extend(self
._extract
_m
3u8_formats
(
98 format_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
99 m3u8_id
='hls', fatal
=False))
100 elif extension
== 'mp4' or ext
== 'mp4':
104 'width': int_or_none(resource
.get('width')),
105 'height': int_or_none(resource
.get('height')),
107 self
._sort
_formats
(formats
)
110 for attribute
in video
['attributes']:
111 if not isinstance(attribute
, dict):
113 key
= attribute
.get('fieldKey')
114 value
= attribute
.get('fieldValue')
115 if not key
or not value
:
119 title
= attrs
.get('title_stv') or video_id
120 alt_title
= attrs
.get('title')
121 description
= attrs
.get('long_description') or attrs
.get('short_description')
122 series
= attrs
.get('label')
123 season
= attrs
.get('season')
124 episode
= attrs
.get('chapter')
125 duration
= float_or_none(attrs
.get('duration'), scale
=1000)
126 season_number
= int_or_none(self
._search
_regex
(
127 r
'Season (\d+)', season
or '', 'season number', default
=None))
128 episode_number
= int_or_none(self
._search
_regex
(
129 r
'Episode (\d+)', episode
or '', 'episode number', default
=None))
134 'alt_title': alt_title
,
135 'description': description
,
136 'thumbnail': thumbnail
,
137 'duration': duration
,
138 'timestamp': unified_timestamp(video
.get('lastPublished')),
141 'season_number': season_number
,
143 'episode_number': episode_number
,