1 from .common
import InfoExtractor
14 class ServusIE(InfoExtractor
):
19 servus\.com/(?:(?:at|de)/p/[^/]+|tv/videos)|
20 (?:servustv|pm-wissen)\.com/(?:[^/]+/)?v(?:ideos)?
22 /(?P<id>[aA]{2}-?\w+|\d+-\d+)
26 'url': 'https://www.servustv.com/natur/v/aa-28bycqnh92111/',
28 'id': 'AA-28BYCQNH92111',
30 'title': 'Vie Ferrate - Klettersteige in den Alpen',
31 'description': 'md5:25e47ddd83a009a0f9789ba18f2850ce',
32 'thumbnail': r
're:^https?://.*\.jpg',
34 'timestamp': 1655752333,
35 'upload_date': '20220620',
36 'series': 'Bergwelten',
37 'season': 'Season 11',
39 'episode': 'Episode 8 - Vie Ferrate – Klettersteige in den Alpen',
41 'categories': ['Bergwelten'],
43 'params': {'skip_download': 'm3u8'},
45 'url': 'https://www.servustv.com/natur/v/aa-1xg5xwmgw2112/',
46 'only_matching': True,
48 'url': 'https://www.servustv.com/natur/v/aansszcx3yi9jmlmhdc1/',
49 'only_matching': True,
52 'url': 'https://www.servustv.com/videos/aa-1t6vbu5pw1w12/',
53 'only_matching': True,
56 'url': 'https://www.servus.com/de/p/Die-Gr%C3%BCnen-aus-Sicht-des-Volkes/AA-1T6VBU5PW1W12/',
57 'only_matching': True,
59 'url': 'https://www.servus.com/at/p/Wie-das-Leben-beginnt/1309984137314-381415152/',
60 'only_matching': True,
62 'url': 'https://www.servus.com/tv/videos/aa-1t6vbu5pw1w12/',
63 'only_matching': True,
65 'url': 'https://www.servus.com/tv/videos/1380889096408-1235196658/',
66 'only_matching': True,
68 'url': 'https://www.pm-wissen.com/videos/aa-24mus4g2w2112/',
69 'only_matching': True,
72 def _real_extract(self
, url
):
73 video_id
= self
._match
_id
(url
).upper()
75 webpage
= self
._download
_webpage
(url
, video_id
)
76 next_data
= self
._search
_nextjs
_data
(webpage
, video_id
, fatal
=False)
78 video
= self
._download
_json
(
79 'https://api-player.redbull.com/stv/servus-tv-playnet',
80 video_id
, 'Downloading video JSON', query
={'videoId': video_id
})
81 if not video
.get('videoUrl'):
82 self
._report
_errors
(video
)
83 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(
84 video
['videoUrl'], video_id
, 'mp4', m3u8_id
='hls')
86 season
= video
.get('season')
87 season_number
= int_or_none(self
._search
_regex
(
88 r
'Season (\d+)', season
or '', 'season number', default
=None))
89 episode
= video
.get('chapter')
90 episode_number
= int_or_none(self
._search
_regex
(
91 r
'Episode (\d+)', episode
or '', 'episode number', default
=None))
95 'title': video
.get('title'),
96 'description': self
._get
_description
(next_data
) or video
.get('description'),
97 'thumbnail': video
.get('poster'),
98 'duration': float_or_none(video
.get('duration')),
99 'timestamp': unified_timestamp(video
.get('currentSunrise')),
100 'series': video
.get('label'),
102 'season_number': season_number
,
104 'episode_number': episode_number
,
106 'subtitles': subtitles
,
107 **traverse_obj(next_data
, ('props', 'pageProps', 'data', {
108 'title': ('title', 'rendered', {str}
),
109 'timestamp': ('stv_date', 'raw', {int}
),
110 'duration': ('stv_duration', {float_or_none}
),
111 'categories': ('category_names', ..., {str}
),
115 def _get_description(self
, next_data
):
116 return join_nonempty(*traverse_obj(next_data
, (
117 'props', 'pageProps', 'data',
118 ('stv_short_description', 'stv_long_description'), {str}
,
119 {lambda x
: x
.replace('\n\n', '\n')}, {unescapeHTML}
)), delim
='\n\n')
121 def _report_errors(self
, video
):
122 playability_errors
= traverse_obj(video
, ('playabilityErrors', ...))
123 if not playability_errors
:
124 raise ExtractorError('No videoUrl and no information about errors')
126 elif 'FSK_BLOCKED' in playability_errors
:
127 details
= traverse_obj(video
, ('playabilityErrorDetails', 'FSK_BLOCKED'), expected_type
=dict)
128 message
= format_field(''.join((
129 format_field(details
, 'minEveningHour', ' from %02d:00'),
130 format_field(details
, 'maxMorningHour', ' to %02d:00'),
131 format_field(details
, 'minAge', ' (Minimum age %d)'),
132 )), None, 'Only available%s') or 'Blocked by FSK with unknown availability'
134 elif 'NOT_YET_AVAILABLE' in playability_errors
:
135 message
= format_field(
136 video
, (('playabilityErrorDetails', 'NOT_YET_AVAILABLE', 'availableFrom'), 'currentSunrise'),
137 'Only available from %s') or 'Video not yet available with unknown availability'
140 message
= f
'Video unavailable: {", ".join(playability_errors)}'
142 raise ExtractorError(message
, expected
=True)