]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/sbs.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 class SBSIE(InfoExtractor
):
12 IE_DESC
= 'sbs.com.au'
13 _VALID_URL
= r
'https?://(?:www\.)?sbs\.com\.au/(?:ondemand(?:/video/(?:single/)?|.*?\bplay=)|news/(?:embeds/)?video/)(?P<id>[0-9]+)'
16 # Original URL is handled by the generic IE which finds the iframe:
17 # http://www.sbs.com.au/thefeed/blog/2014/08/21/dingo-conservation
18 'url': 'http://www.sbs.com.au/ondemand/video/single/320403011771/?source=drupal&vertical=thefeed',
19 'md5': '3150cf278965eeabb5b4cea1c963fe0a',
23 'title': 'Dingo Conservation (The Feed)',
24 'description': 'md5:f250a9856fca50d22dec0b5b8015f8a5',
25 'thumbnail': r
're:http://.*\.jpg',
27 'timestamp': 1408613220,
28 'upload_date': '20140821',
32 'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed',
33 'only_matching': True,
35 'url': 'http://www.sbs.com.au/news/video/471395907773/The-Feed-July-9',
36 'only_matching': True,
38 'url': 'https://www.sbs.com.au/ondemand/?play=1836638787723',
39 'only_matching': True,
41 'url': 'https://www.sbs.com.au/ondemand/program/inside-windsor-castle?play=1283505731842',
42 'only_matching': True,
44 'url': 'https://www.sbs.com.au/news/embeds/video/1840778819866',
45 'only_matching': True,
48 def _real_extract(self
, url
):
49 video_id
= self
._match
_id
(url
)
50 player_params
= self
._download
_json
(
51 'http://www.sbs.com.au/api/video_pdkvars/id/%s?form=json' % video_id
, video_id
)
53 error
= player_params
.get('error')
55 error_message
= 'Sorry, The video you are looking for does not exist.'
56 video_data
= error
.get('results') or {}
57 error_code
= error
.get('errorCode')
58 if error_code
== 'ComingSoon':
59 error_message
= '%s is not yet available.' % video_data
.get('title', '')
60 elif error_code
in ('Forbidden', 'intranetAccessOnly'):
61 error_message
= 'Sorry, This video cannot be accessed via this website'
62 elif error_code
== 'Expired':
63 error_message
= 'Sorry, %s is no longer available.' % video_data
.get('title', '')
64 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, error_message
), expected
=True)
66 urls
= player_params
['releaseUrls']
67 theplatform_url
= (urls
.get('progressive') or urls
.get('html')
68 or urls
.get('standard') or player_params
['relatedItemsURL'])
71 '_type': 'url_transparent',
72 'ie_key': 'ThePlatform',
74 'url': smuggle_url(self
._proto
_relative
_url
(theplatform_url
), {'force_smil_url': True}
),