2017-10-19 09:17:20 -06:00
|
|
|
|
from .common import InfoExtractor
|
2020-11-19 12:22:59 -07:00
|
|
|
|
from ..utils import (
|
2023-02-07 23:05:32 -07:00
|
|
|
|
ExtractorError,
|
2020-11-19 12:22:59 -07:00
|
|
|
|
float_or_none,
|
2023-02-07 23:05:32 -07:00
|
|
|
|
format_field,
|
2020-11-19 12:22:59 -07:00
|
|
|
|
int_or_none,
|
2023-02-07 23:05:32 -07:00
|
|
|
|
join_nonempty,
|
|
|
|
|
traverse_obj,
|
|
|
|
|
unescapeHTML,
|
2020-11-19 12:22:59 -07:00
|
|
|
|
unified_timestamp,
|
|
|
|
|
)
|
2017-10-19 09:17:20 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ServusIE(InfoExtractor):
|
2020-03-02 11:40:48 -07:00
|
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
|
https?://
|
|
|
|
|
(?:www\.)?
|
|
|
|
|
(?:
|
|
|
|
|
servus\.com/(?:(?:at|de)/p/[^/]+|tv/videos)|
|
2023-02-07 23:05:32 -07:00
|
|
|
|
(?:servustv|pm-wissen)\.com/(?:[^/]+/)?v(?:ideos)?
|
2020-03-02 11:40:48 -07:00
|
|
|
|
)
|
2023-02-07 23:05:32 -07:00
|
|
|
|
/(?P<id>[aA]{2}-?\w+|\d+-\d+)
|
2020-03-02 11:40:48 -07:00
|
|
|
|
'''
|
2017-10-19 09:17:20 -06:00
|
|
|
|
_TESTS = [{
|
2023-02-07 23:05:32 -07:00
|
|
|
|
# URL schema v3
|
|
|
|
|
'url': 'https://www.servustv.com/natur/v/aa-28bycqnh92111/',
|
2017-10-19 09:17:20 -06:00
|
|
|
|
'info_dict': {
|
2023-02-07 23:05:32 -07:00
|
|
|
|
'id': 'AA-28BYCQNH92111',
|
2017-10-19 09:17:20 -06:00
|
|
|
|
'ext': 'mp4',
|
2024-09-13 18:14:09 -06:00
|
|
|
|
'title': 'Vie Ferrate - Klettersteige in den Alpen',
|
2023-02-07 23:05:32 -07:00
|
|
|
|
'description': 'md5:25e47ddd83a009a0f9789ba18f2850ce',
|
2019-02-24 09:19:15 -07:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg',
|
2023-02-07 23:05:32 -07:00
|
|
|
|
'duration': 2823,
|
|
|
|
|
'timestamp': 1655752333,
|
|
|
|
|
'upload_date': '20220620',
|
|
|
|
|
'series': 'Bergwelten',
|
|
|
|
|
'season': 'Season 11',
|
|
|
|
|
'season_number': 11,
|
|
|
|
|
'episode': 'Episode 8 - Vie Ferrate – Klettersteige in den Alpen',
|
|
|
|
|
'episode_number': 8,
|
2024-09-13 18:14:09 -06:00
|
|
|
|
'categories': ['Bergwelten'],
|
2023-02-07 23:05:32 -07:00
|
|
|
|
},
|
2024-06-11 17:09:58 -06:00
|
|
|
|
'params': {'skip_download': 'm3u8'},
|
2023-02-07 23:05:32 -07:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.servustv.com/natur/v/aa-1xg5xwmgw2112/',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.servustv.com/natur/v/aansszcx3yi9jmlmhdc1/',
|
|
|
|
|
'only_matching': True,
|
2020-03-02 11:40:48 -07:00
|
|
|
|
}, {
|
2023-02-07 23:05:32 -07:00
|
|
|
|
# URL schema v2
|
|
|
|
|
'url': 'https://www.servustv.com/videos/aa-1t6vbu5pw1w12/',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}, {
|
|
|
|
|
# URL schema v1
|
2020-03-02 11:40:48 -07:00
|
|
|
|
'url': 'https://www.servus.com/de/p/Die-Gr%C3%BCnen-aus-Sicht-des-Volkes/AA-1T6VBU5PW1W12/',
|
|
|
|
|
'only_matching': True,
|
2017-10-19 09:17:20 -06:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.servus.com/at/p/Wie-das-Leben-beginnt/1309984137314-381415152/',
|
|
|
|
|
'only_matching': True,
|
2019-02-24 09:19:15 -07:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.servus.com/tv/videos/aa-1t6vbu5pw1w12/',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.servus.com/tv/videos/1380889096408-1235196658/',
|
|
|
|
|
'only_matching': True,
|
2020-11-19 12:22:59 -07:00
|
|
|
|
}, {
|
|
|
|
|
'url': 'https://www.pm-wissen.com/videos/aa-24mus4g2w2112/',
|
|
|
|
|
'only_matching': True,
|
2017-10-19 09:17:20 -06:00
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2019-02-24 09:19:15 -07:00
|
|
|
|
video_id = self._match_id(url).upper()
|
2017-10-19 09:17:20 -06:00
|
|
|
|
|
2024-09-13 18:14:09 -06:00
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
next_data = self._search_nextjs_data(webpage, video_id, fatal=False)
|
|
|
|
|
|
2020-11-19 12:22:59 -07:00
|
|
|
|
video = self._download_json(
|
2024-09-13 18:14:09 -06:00
|
|
|
|
'https://api-player.redbull.com/stv/servus-tv-playnet',
|
2023-02-07 23:05:32 -07:00
|
|
|
|
video_id, 'Downloading video JSON', query={'videoId': video_id})
|
|
|
|
|
if not video.get('videoUrl'):
|
|
|
|
|
self._report_errors(video)
|
|
|
|
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
|
|
|
|
video['videoUrl'], video_id, 'mp4', m3u8_id='hls')
|
2020-11-19 12:22:59 -07:00
|
|
|
|
|
2023-02-07 23:05:32 -07:00
|
|
|
|
season = video.get('season')
|
2020-11-19 12:22:59 -07:00
|
|
|
|
season_number = int_or_none(self._search_regex(
|
|
|
|
|
r'Season (\d+)', season or '', 'season number', default=None))
|
2023-02-07 23:05:32 -07:00
|
|
|
|
episode = video.get('chapter')
|
2020-11-19 12:22:59 -07:00
|
|
|
|
episode_number = int_or_none(self._search_regex(
|
|
|
|
|
r'Episode (\d+)', episode or '', 'episode number', default=None))
|
|
|
|
|
|
2017-10-19 09:17:20 -06:00
|
|
|
|
return {
|
|
|
|
|
'id': video_id,
|
2023-02-07 23:05:32 -07:00
|
|
|
|
'title': video.get('title'),
|
2024-09-13 18:14:09 -06:00
|
|
|
|
'description': self._get_description(next_data) or video.get('description'),
|
2023-02-07 23:05:32 -07:00
|
|
|
|
'thumbnail': video.get('poster'),
|
|
|
|
|
'duration': float_or_none(video.get('duration')),
|
|
|
|
|
'timestamp': unified_timestamp(video.get('currentSunrise')),
|
|
|
|
|
'series': video.get('label'),
|
2020-11-19 12:22:59 -07:00
|
|
|
|
'season': season,
|
|
|
|
|
'season_number': season_number,
|
|
|
|
|
'episode': episode,
|
|
|
|
|
'episode_number': episode_number,
|
2017-10-19 09:17:20 -06:00
|
|
|
|
'formats': formats,
|
2023-02-07 23:05:32 -07:00
|
|
|
|
'subtitles': subtitles,
|
2024-09-13 18:14:09 -06:00
|
|
|
|
**traverse_obj(next_data, ('props', 'pageProps', 'data', {
|
|
|
|
|
'title': ('title', 'rendered', {str}),
|
|
|
|
|
'timestamp': ('stv_date', 'raw', {int}),
|
|
|
|
|
'duration': ('stv_duration', {float_or_none}),
|
|
|
|
|
'categories': ('category_names', ..., {str}),
|
|
|
|
|
})),
|
2017-10-19 09:17:20 -06:00
|
|
|
|
}
|
2023-02-07 23:05:32 -07:00
|
|
|
|
|
2024-09-13 18:14:09 -06:00
|
|
|
|
def _get_description(self, next_data):
|
|
|
|
|
return join_nonempty(*traverse_obj(next_data, (
|
|
|
|
|
'props', 'pageProps', 'data',
|
|
|
|
|
('stv_short_description', 'stv_long_description'), {str},
|
|
|
|
|
{lambda x: x.replace('\n\n', '\n')}, {unescapeHTML})), delim='\n\n')
|
2023-02-07 23:05:32 -07:00
|
|
|
|
|
|
|
|
|
def _report_errors(self, video):
|
|
|
|
|
playability_errors = traverse_obj(video, ('playabilityErrors', ...))
|
|
|
|
|
if not playability_errors:
|
|
|
|
|
raise ExtractorError('No videoUrl and no information about errors')
|
|
|
|
|
|
|
|
|
|
elif 'FSK_BLOCKED' in playability_errors:
|
|
|
|
|
details = traverse_obj(video, ('playabilityErrorDetails', 'FSK_BLOCKED'), expected_type=dict)
|
|
|
|
|
message = format_field(''.join((
|
|
|
|
|
format_field(details, 'minEveningHour', ' from %02d:00'),
|
|
|
|
|
format_field(details, 'maxMorningHour', ' to %02d:00'),
|
|
|
|
|
format_field(details, 'minAge', ' (Minimum age %d)'),
|
|
|
|
|
)), None, 'Only available%s') or 'Blocked by FSK with unknown availability'
|
|
|
|
|
|
|
|
|
|
elif 'NOT_YET_AVAILABLE' in playability_errors:
|
|
|
|
|
message = format_field(
|
|
|
|
|
video, (('playabilityErrorDetails', 'NOT_YET_AVAILABLE', 'availableFrom'), 'currentSunrise'),
|
|
|
|
|
'Only available from %s') or 'Video not yet available with unknown availability'
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
message = f'Video unavailable: {", ".join(playability_errors)}'
|
|
|
|
|
|
|
|
|
|
raise ExtractorError(message, expected=True)
|