]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/sbs.py
1 from .common
import InfoExtractor
14 class SBSIE(InfoExtractor
):
15 IE_DESC
= 'sbs.com.au'
17 https?://(?:www\.)?sbs\.com\.au/(?:
20 /(?:movie|tv-program)/[^/]+/|
21 /(?:tv|news)-series/(?:[^/]+/){3}|
23 )|news/(?:embeds/)?video/
25 _EMBED_REGEX
= [r
'''(?x)]
27 <meta\s+property="og:video"\s+content=|
30 (["\'])(?P
<url
>https?
://(?
:www\
.)?sbs\
.com\
.au
/ondemand
/video
/.+?
)\
1''']
33 # Original URL is handled by the generic IE which finds the iframe:
34 # http://www.sbs.com.au/thefeed/blog/2014/08/21/dingo-conservation
35 'url': 'http://www.sbs.com.au/ondemand/video/single/320403011771/?source=drupal&vertical=thefeed',
36 'md5': '31f84a7a19b53635db63c73f8ab0c4a7',
38 'id': '320403011771', # '_rFBPRPO4pMR',
40 'title': 'Dingo Conservation (The Feed)',
41 'description': 'md5:f250a9856fca50d22dec0b5b8015f8a5',
42 'thumbnail': r're:https?://.*\.jpg',
44 'timestamp': 1408613220,
45 'upload_date': '20140821',
50 'expected_warnings': ['Unable to download JSON metadata'],
52 'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed',
53 'only_matching': True,
55 'url': 'http://www.sbs.com.au/news/video/471395907773/The-Feed-July-9',
56 'only_matching': True,
58 'url': 'https://www.sbs.com.au/ondemand/?play=1836638787723',
59 'only_matching': True,
61 'url': 'https://www.sbs.com.au/ondemand/program/inside-windsor-castle?play=1283505731842',
62 'only_matching': True,
64 'url': 'https://www.sbs.com.au/news/embeds/video/1840778819866',
65 'only_matching': True,
67 'url': 'https://www.sbs.com.au/ondemand/watch/1698704451971',
68 'only_matching': True,
70 'url': 'https://www.sbs.com.au/ondemand/movie/coherence/1469404227931',
71 'only_matching': True,
73 'note': 'Live stream',
74 'url': 'https://www.sbs.com.au/ondemand/video/1726824003663/sbs-24x7-live-stream-nsw',
75 'only_matching': True,
77 'url': 'https://www.sbs.com.au/ondemand/news-series/dateline/dateline-2022/dateline-s2022-ep26/2072245827515',
78 'only_matching': True,
80 'url': 'https://www.sbs.com.au/ondemand/tv-series/the-handmaids-tale/season-5/the-handmaids-tale-s5-ep1/2065631811776',
81 'only_matching': True,
83 'url': 'https://www.sbs.com.au/ondemand/tv-program/autun-romes-forgotten-sister/2116212803602',
84 'only_matching': True,
87 _GEO_COUNTRIES = ['AU']
88 _AUS_TV_PARENTAL_GUIDELINES = {
98 _PLAYER_API = 'https://www.sbs.com.au/api/v3'
100 def _real_extract(self, url):
101 video_id = self._match_id(url)
102 formats, subtitles = self._extract_smil_formats_and_subtitles(
103 update_url_query(f'{self._PLAYER_API}/video_smil', {'id': video_id}), video_id)
106 urlh = self._request_webpage(
107 HEADRequest('https://sbs-vod-prod-01.akamaized.net/'), video_id,
108 note='Checking geo-restriction', fatal=False, expected_status=403)
110 error_reasons = urlh.headers.get_all('x-error-reason') or []
111 if 'geo-blocked' in error_reasons:
112 self.raise_geo_restricted(countries=['AU'])
113 self.raise_no_formats('No formats are available', video_id=video_id)
115 media = traverse_obj(self._download_json(
116 f'{self._PLAYER_API}/video_stream', video_id, fatal=False,
117 query={'id': video_id, 'context': 'tv'}), ('video_object', {dict})) or {}
119 media.update(self._download_json(
120 f'https://catalogue.pr.sbsod.com/mpx-media/{video_id}',
121 video_id, fatal=not media) or {})
123 # For named episodes, use the catalogue's title to set episode, rather than generic 'Episode N'.
124 if traverse_obj(media, ('partOfSeries', {dict})):
125 media['epName'] = traverse_obj(media, ('title', {str}))
129 **traverse_obj(media, {
130 'title': ('name', {str}),
131 'description': ('description', {str}),
132 'channel': ('taxonomy', 'channel', 'name', {str}),
133 'series': ((('partOfSeries', 'name'), 'seriesTitle'), {str}),
134 'series_id': ((('partOfSeries', 'uuid'), 'seriesID'), {str}),
135 'season_number': ('seasonNumber', {int_or_none}),
136 'episode': ('epName', {str}),
137 'episode_number': ('episodeNumber', {int_or_none}),
138 'timestamp': (('datePublished', ('publication', 'startDate')), {parse_iso8601}),
139 'release_year': ('releaseYear', {int_or_none}),
140 'duration': ('duration', ({float_or_none}, {parse_duration})),
141 'is_live': ('liveStream', {bool}),
143 ('classificationID', 'contentRating'), {str.upper}, {self._AUS_TV_PARENTAL_GUIDELINES.get}),
145 **traverse_obj(media, {
146 'categories': (('genres', ...), ('taxonomy', ('genre', 'subgenre'), 'name'), {str}),
147 'tags': (('consumerAdviceTexts', ('sbsSubCertification', 'consumerAdvice')), ..., {str}),
148 'thumbnails': ('thumbnails', lambda _, v: url_or_none(v['contentUrl']), {
149 'id': ('name', {str}),
151 'width': ('width', {int_or_none}),
152 'height': ('height', {int_or_none}),
156 'subtitles': subtitles,