You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.3 KiB

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