]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
2ef6fcb5 PH |
2 | from __future__ import unicode_literals |
3 | ||
2ef6fcb5 | 4 | from .common import InfoExtractor |
a646a8cf | 5 | from ..utils import ( |
6 | smuggle_url, | |
7 | ExtractorError, | |
8 | ) | |
2ef6fcb5 PH |
9 | |
10 | ||
11 | class SBSIE(InfoExtractor): | |
12 | IE_DESC = 'sbs.com.au' | |
cce889b9 | 13 | _VALID_URL = r'https?://(?:www\.)?sbs\.com\.au/(?:ondemand(?:/video/(?:single/)?|.*?\bplay=|/watch/)|news/(?:embeds/)?video/)(?P<id>[0-9]+)' |
2ef6fcb5 PH |
14 | |
15 | _TESTS = [{ | |
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', | |
20 | 'info_dict': { | |
00dd0cd5 | 21 | 'id': '_rFBPRPO4pMR', |
e35cb78c | 22 | 'ext': 'mp4', |
3c283a38 S |
23 | 'title': 'Dingo Conservation (The Feed)', |
24 | 'description': 'md5:f250a9856fca50d22dec0b5b8015f8a5', | |
ec85ded8 | 25 | 'thumbnail': r're:http://.*\.jpg', |
3c283a38 | 26 | 'duration': 308, |
79ba9140 | 27 | 'timestamp': 1408613220, |
28 | 'upload_date': '20140821', | |
29 | 'uploader': 'SBSC', | |
2ef6fcb5 | 30 | }, |
9e1a5b84 | 31 | }, { |
63cddb64 JMF |
32 | 'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed', |
33 | 'only_matching': True, | |
3c283a38 S |
34 | }, { |
35 | 'url': 'http://www.sbs.com.au/news/video/471395907773/The-Feed-July-9', | |
36 | 'only_matching': True, | |
00dd0cd5 | 37 | }, { |
38 | 'url': 'https://www.sbs.com.au/ondemand/?play=1836638787723', | |
39 | 'only_matching': True, | |
40 | }, { | |
41 | 'url': 'https://www.sbs.com.au/ondemand/program/inside-windsor-castle?play=1283505731842', | |
42 | 'only_matching': True, | |
43 | }, { | |
44 | 'url': 'https://www.sbs.com.au/news/embeds/video/1840778819866', | |
45 | 'only_matching': True, | |
cce889b9 | 46 | }, { |
47 | 'url': 'https://www.sbs.com.au/ondemand/watch/1698704451971', | |
48 | 'only_matching': True, | |
2ef6fcb5 PH |
49 | }] |
50 | ||
51 | def _real_extract(self, url): | |
ef2dcbe4 | 52 | video_id = self._match_id(url) |
a646a8cf | 53 | player_params = self._download_json( |
54 | 'http://www.sbs.com.au/api/video_pdkvars/id/%s?form=json' % video_id, video_id) | |
55 | ||
56 | error = player_params.get('error') | |
57 | if error: | |
58 | error_message = 'Sorry, The video you are looking for does not exist.' | |
59 | video_data = error.get('results') or {} | |
60 | error_code = error.get('errorCode') | |
61 | if error_code == 'ComingSoon': | |
62 | error_message = '%s is not yet available.' % video_data.get('title', '') | |
63 | elif error_code in ('Forbidden', 'intranetAccessOnly'): | |
64 | error_message = 'Sorry, This video cannot be accessed via this website' | |
65 | elif error_code == 'Expired': | |
66 | error_message = 'Sorry, %s is no longer available.' % video_data.get('title', '') | |
67 | raise ExtractorError('%s said: %s' % (self.IE_NAME, error_message), expected=True) | |
2ef6fcb5 | 68 | |
3c283a38 | 69 | urls = player_params['releaseUrls'] |
3089bc74 S |
70 | theplatform_url = (urls.get('progressive') or urls.get('html') |
71 | or urls.get('standard') or player_params['relatedItemsURL']) | |
2ef6fcb5 PH |
72 | |
73 | return { | |
74 | '_type': 'url_transparent', | |
79ba9140 | 75 | 'ie_key': 'ThePlatform', |
2ef6fcb5 | 76 | 'id': video_id, |
79ba9140 | 77 | 'url': smuggle_url(self._proto_relative_url(theplatform_url), {'force_smil_url': True}), |
2ef6fcb5 | 78 | } |