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.1 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. js_to_json,
  7. remove_end,
  8. )
  9. class SBSIE(InfoExtractor):
  10. IE_DESC = 'sbs.com.au'
  11. _VALID_URL = r'https?://(?:www\.)?sbs\.com\.au/ondemand/video/(?:single/)?(?P<id>[0-9]+)'
  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',
  19. 'ext': 'mp4',
  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'],
  25. }, {
  26. 'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed',
  27. 'only_matching': True,
  28. }]
  29. def _real_extract(self, url):
  30. video_id = self._match_id(url)
  31. webpage = self._download_webpage(url, video_id)
  32. player = self._search_regex(
  33. r'(?s)playerParams\.releaseUrls\s*=\s*(\{.*?\n\});\n',
  34. webpage, 'player')
  35. player = re.sub(r"'\s*\+\s*[\da-zA-Z_]+\s*\+\s*'", '', player)
  36. release_urls = self._parse_json(js_to_json(player), video_id)
  37. theplatform_url = release_urls.get('progressive') or release_urls['standard']
  38. title = remove_end(self._og_search_title(webpage), ' (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. }