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