]>
Commit | Line | Data |
---|---|---|
2ef6fcb5 PH |
1 | # -*- coding: utf-8 -*- |
2 | from __future__ import unicode_literals | |
3 | ||
2ef6fcb5 | 4 | from .common import InfoExtractor |
75a40b22 | 5 | from ..utils import remove_end |
2ef6fcb5 PH |
6 | |
7 | ||
8 | class SBSIE(InfoExtractor): | |
9 | IE_DESC = 'sbs.com.au' | |
63cddb64 | 10 | _VALID_URL = r'https?://(?:www\.)?sbs\.com\.au/ondemand/video/(?:single/)?(?P<id>[0-9]+)' |
2ef6fcb5 PH |
11 | |
12 | _TESTS = [{ | |
13 | # Original URL is handled by the generic IE which finds the iframe: | |
14 | # http://www.sbs.com.au/thefeed/blog/2014/08/21/dingo-conservation | |
15 | 'url': 'http://www.sbs.com.au/ondemand/video/single/320403011771/?source=drupal&vertical=thefeed', | |
16 | 'md5': '3150cf278965eeabb5b4cea1c963fe0a', | |
17 | 'info_dict': { | |
18 | 'id': '320403011771', | |
e35cb78c | 19 | 'ext': 'mp4', |
2ef6fcb5 PH |
20 | 'title': 'Dingo Conservation', |
21 | 'description': 'Dingoes are on the brink of extinction; most of the animals we think are dingoes are in fact crossbred with wild dogs. This family run a dingo conservation park to prevent their extinction', | |
22 | 'thumbnail': 're:http://.*\.jpg', | |
23 | }, | |
24 | 'add_ies': ['generic'], | |
9e1a5b84 | 25 | }, { |
63cddb64 JMF |
26 | 'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed', |
27 | 'only_matching': True, | |
2ef6fcb5 PH |
28 | }] |
29 | ||
30 | def _real_extract(self, url): | |
ef2dcbe4 S |
31 | video_id = self._match_id(url) |
32 | ||
75a40b22 SP |
33 | # the video is in the following iframe |
34 | iframe_url = 'http://www.sbs.com.au/ondemand/video/single/' + video_id + '?context=web' | |
35 | webpage = self._download_webpage(iframe_url, video_id) | |
2ef6fcb5 | 36 | |
75a40b22 SP |
37 | player_params = self._search_regex( |
38 | r'(?s)(playerParams.+?releaseUrls.+?\n)', | |
39 | webpage, 'playerParams') | |
40 | player_params_js = self._search_regex( | |
41 | r'({.*})', | |
42 | player_params, 'player_param_js') | |
ef2dcbe4 | 43 | |
75a40b22 | 44 | player_params_json = self._parse_json(player_params_js, video_id) |
ef2dcbe4 | 45 | |
75a40b22 | 46 | theplatform_url = player_params_json.get('releaseUrls')['progressive'] or player_params_json.get('releaseUrls')['standard'] |
2ef6fcb5 | 47 | |
75a40b22 | 48 | title = remove_end(self._og_search_title(webpage, default=video_id, fatal=False), ' (The Feed)') |
2ef6fcb5 PH |
49 | description = self._html_search_meta('description', webpage) |
50 | thumbnail = self._og_search_thumbnail(webpage) | |
51 | ||
52 | return { | |
53 | '_type': 'url_transparent', | |
54 | 'id': video_id, | |
55 | 'url': theplatform_url, | |
2ef6fcb5 PH |
56 | 'title': title, |
57 | 'description': description, | |
58 | 'thumbnail': thumbnail, | |
59 | } |