]> git.bitcoin.ninja Git - youtube-dl/blob - sbs.py
d4bd1a0d72624e65bc9a5890f371b492451a9486
[youtube-dl] / sbs.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 import re
5 from .common import InfoExtractor
6 from ..utils import (
7     js_to_json,
8     remove_end,
9 )
10
11
12 class SBSIE(InfoExtractor):
13     IE_DESC = 'sbs.com.au'
14     _VALID_URL = r'https?://(?:www\.)?sbs\.com\.au/ondemand/video/(?:single/)?(?P<id>[0-9]+)'
15
16     _TESTS = [{
17         # Original URL is handled by the generic IE which finds the iframe:
18         # http://www.sbs.com.au/thefeed/blog/2014/08/21/dingo-conservation
19         'url': 'http://www.sbs.com.au/ondemand/video/single/320403011771/?source=drupal&vertical=thefeed',
20         'md5': '3150cf278965eeabb5b4cea1c963fe0a',
21         'info_dict': {
22             'id': '320403011771',
23             'ext': 'mp4',
24             'title': 'Dingo Conservation',
25             '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',
26             'thumbnail': 're:http://.*\.jpg',
27         },
28         'add_ies': ['generic'],
29     }, {
30         'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed',
31         'only_matching': True,
32     }]
33
34     def _real_extract(self, url):
35         video_id = self._match_id(url)
36
37         webpage = self._download_webpage(url, video_id)
38
39         player = self._search_regex(
40             r'(?s)playerParams\.releaseUrls\s*=\s*(\{.*?\n\});\n',
41             webpage, 'player')
42         player = re.sub(r"'\s*\+\s*[\da-zA-Z_]+\s*\+\s*'", '', player)
43
44         release_urls = self._parse_json(js_to_json(player), video_id)
45
46         theplatform_url = release_urls.get('progressive') or release_urls['standard']
47
48         title = remove_end(self._og_search_title(webpage), ' (The Feed)')
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,
56             'title': title,
57             'description': description,
58             'thumbnail': thumbnail,
59         }