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.

51 lines
1.8 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class SBSIE(InfoExtractor):
  5. IE_DESC = 'sbs.com.au'
  6. _VALID_URL = r'https?://(?:www\.)?sbs\.com\.au/(?:ondemand|news)/video/(?:single/)?(?P<id>[0-9]+)'
  7. _TESTS = [{
  8. # Original URL is handled by the generic IE which finds the iframe:
  9. # http://www.sbs.com.au/thefeed/blog/2014/08/21/dingo-conservation
  10. 'url': 'http://www.sbs.com.au/ondemand/video/single/320403011771/?source=drupal&vertical=thefeed',
  11. 'md5': '3150cf278965eeabb5b4cea1c963fe0a',
  12. 'info_dict': {
  13. 'id': '320403011771',
  14. 'ext': 'mp4',
  15. 'title': 'Dingo Conservation (The Feed)',
  16. 'description': 'md5:f250a9856fca50d22dec0b5b8015f8a5',
  17. 'thumbnail': 're:http://.*\.jpg',
  18. 'duration': 308,
  19. },
  20. }, {
  21. 'url': 'http://www.sbs.com.au/ondemand/video/320403011771/Dingo-Conservation-The-Feed',
  22. 'only_matching': True,
  23. }, {
  24. 'url': 'http://www.sbs.com.au/news/video/471395907773/The-Feed-July-9',
  25. 'only_matching': True,
  26. }]
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. webpage = self._download_webpage(
  30. 'http://www.sbs.com.au/ondemand/video/single/%s?context=web' % video_id, video_id)
  31. player_params = self._parse_json(
  32. self._search_regex(
  33. r'(?s)var\s+playerParams\s*=\s*({.+?});', webpage, 'playerParams'),
  34. video_id)
  35. urls = player_params['releaseUrls']
  36. theplatform_url = (urls.get('progressive') or urls.get('standard') or
  37. urls.get('html') or player_params['relatedItemsURL'])
  38. return {
  39. '_type': 'url_transparent',
  40. 'id': video_id,
  41. 'url': theplatform_url,
  42. }