]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/sbs.py
Merge remote-tracking branch 'olebowle/gameone'
[yt-dlp.git] / youtube_dl / extractor / sbs.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 import json
5 import re
6 from .common import InfoExtractor
7 from ..utils import (
8 js_to_json,
9 remove_end,
10 )
11
12
13 class SBSIE(InfoExtractor):
14 IE_DESC = 'sbs.com.au'
15 _VALID_URL = r'https?://(?:www\.)?sbs\.com\.au/ondemand/video/single/(?P<id>[0-9]+)/'
16
17 _TESTS = [{
18 # Original URL is handled by the generic IE which finds the iframe:
19 # http://www.sbs.com.au/thefeed/blog/2014/08/21/dingo-conservation
20 'url': 'http://www.sbs.com.au/ondemand/video/single/320403011771/?source=drupal&vertical=thefeed',
21 'md5': '3150cf278965eeabb5b4cea1c963fe0a',
22 'info_dict': {
23 'id': '320403011771',
24 'ext': 'flv',
25 'title': 'Dingo Conservation',
26 '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',
27 'thumbnail': 're:http://.*\.jpg',
28 },
29 'add_ies': ['generic'],
30 }]
31
32 def _real_extract(self, url):
33 mobj = re.match(self._VALID_URL, url)
34 video_id = mobj.group('id')
35 webpage = self._download_webpage(url, video_id)
36
37 release_urls_json = js_to_json(self._search_regex(
38 r'(?s)playerParams\.releaseUrls\s*=\s*(\{.*?\n\});\n',
39 webpage, ''))
40 release_urls = json.loads(release_urls_json)
41 theplatform_url = (
42 release_urls.get('progressive') or release_urls.get('standard'))
43
44 title = remove_end(self._og_search_title(webpage), ' (The Feed)')
45 description = self._html_search_meta('description', webpage)
46 thumbnail = self._og_search_thumbnail(webpage)
47
48 return {
49 '_type': 'url_transparent',
50 'id': video_id,
51 'url': theplatform_url,
52
53 'title': title,
54 'description': description,
55 'thumbnail': thumbnail,
56 }