]>
Commit | Line | Data |
---|---|---|
2ef6fcb5 | 1 | from .common import InfoExtractor |
a646a8cf | 2 | from ..utils import ( |
3 | smuggle_url, | |
4 | ExtractorError, | |
5 | ) | |
2ef6fcb5 PH |
6 | |
7 | ||
8 | class SBSIE(InfoExtractor): | |
9 | IE_DESC = 'sbs.com.au' | |
d52cd2f5 | 10 | _VALID_URL = r'''(?x) |
11 | https?://(?:www\.)?sbs\.com\.au/(?: | |
12 | ondemand(?: | |
13 | /video/(?:single/)?| | |
14 | /movie/[^/]+/| | |
15 | .*?\bplay=|/watch/ | |
16 | )|news/(?:embeds/)?video/ | |
17 | )(?P<id>[0-9]+)''' | |
bfd973ec | 18 | _EMBED_REGEX = [r'''(?x)] |
19 | (?: | |
20 | <meta\s+property="og:video"\s+content=| | |
21 | <iframe[^>]+?src= | |
22 | ) | |
23 | (["\'])(?P<url>https?://(?:www\.)?sbs\.com\.au/ondemand/video/.+?)\1'''] | |
2ef6fcb5 PH |
24 | |
25 | _TESTS = [{ | |
26 | # Original URL is handled by the generic IE which finds the iframe: | |
27 | # http://www.sbs.com.au/thefeed/blog/2014/08/21/dingo-conservation | |
28 | 'url': 'http://www.sbs.com.au/ondemand/video/single/320403011771/?source=drupal&vertical=thefeed', | |
29 | 'md5': '3150cf278965eeabb5b4cea1c963fe0a', | |
30 | 'info_dict': { | |
00dd0cd5 | 31 | 'id': '_rFBPRPO4pMR', |
e35cb78c | 32 | 'ext': 'mp4', |
3c283a38 S |
33 | 'title': 'Dingo Conservation (The Feed)', |
34 | 'description': 'md5:f250a9856fca50d22dec0b5b8015f8a5', | |
ec85ded8 | 35 | 'thumbnail': r're:http://.*\.jpg', |
3c283a38 | 36 | 'duration': 308, |
79ba9140 | 37 | 'timestamp': 1408613220, |
38 | 'upload_date': '20140821', | |
39 | 'uploader': 'SBSC', | |
2ef6fcb5 | 40 | }, |
9e1a5b84 | 41 | }, { |
63cddb64 JMF |
42 | 'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed', |
43 | 'only_matching': True, | |
3c283a38 S |
44 | }, { |
45 | 'url': 'http://www.sbs.com.au/news/video/471395907773/The-Feed-July-9', | |
46 | 'only_matching': True, | |
00dd0cd5 | 47 | }, { |
48 | 'url': 'https://www.sbs.com.au/ondemand/?play=1836638787723', | |
49 | 'only_matching': True, | |
50 | }, { | |
51 | 'url': 'https://www.sbs.com.au/ondemand/program/inside-windsor-castle?play=1283505731842', | |
52 | 'only_matching': True, | |
53 | }, { | |
54 | 'url': 'https://www.sbs.com.au/news/embeds/video/1840778819866', | |
55 | 'only_matching': True, | |
cce889b9 | 56 | }, { |
57 | 'url': 'https://www.sbs.com.au/ondemand/watch/1698704451971', | |
58 | 'only_matching': True, | |
d52cd2f5 | 59 | }, { |
60 | 'url': 'https://www.sbs.com.au/ondemand/movie/coherence/1469404227931', | |
61 | 'only_matching': True, | |
62 | }, { | |
63 | 'note': 'Live stream', | |
64 | 'url': 'https://www.sbs.com.au/ondemand/video/1726824003663/sbs-24x7-live-stream-nsw', | |
65 | 'only_matching': True, | |
2ef6fcb5 PH |
66 | }] |
67 | ||
68 | def _real_extract(self, url): | |
ef2dcbe4 | 69 | video_id = self._match_id(url) |
a646a8cf | 70 | player_params = self._download_json( |
71 | 'http://www.sbs.com.au/api/video_pdkvars/id/%s?form=json' % video_id, video_id) | |
72 | ||
73 | error = player_params.get('error') | |
74 | if error: | |
75 | error_message = 'Sorry, The video you are looking for does not exist.' | |
76 | video_data = error.get('results') or {} | |
77 | error_code = error.get('errorCode') | |
78 | if error_code == 'ComingSoon': | |
79 | error_message = '%s is not yet available.' % video_data.get('title', '') | |
80 | elif error_code in ('Forbidden', 'intranetAccessOnly'): | |
81 | error_message = 'Sorry, This video cannot be accessed via this website' | |
82 | elif error_code == 'Expired': | |
83 | error_message = 'Sorry, %s is no longer available.' % video_data.get('title', '') | |
84 | raise ExtractorError('%s said: %s' % (self.IE_NAME, error_message), expected=True) | |
2ef6fcb5 | 85 | |
3c283a38 | 86 | urls = player_params['releaseUrls'] |
3089bc74 S |
87 | theplatform_url = (urls.get('progressive') or urls.get('html') |
88 | or urls.get('standard') or player_params['relatedItemsURL']) | |
2ef6fcb5 PH |
89 | |
90 | return { | |
91 | '_type': 'url_transparent', | |
79ba9140 | 92 | 'ie_key': 'ThePlatform', |
2ef6fcb5 | 93 | 'id': video_id, |
79ba9140 | 94 | 'url': smuggle_url(self._proto_relative_url(theplatform_url), {'force_smil_url': True}), |
d52cd2f5 | 95 | 'is_live': player_params.get('streamType') == 'live', |
2ef6fcb5 | 96 | } |