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.

47 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. class ABCIE(InfoExtractor):
  6. IE_NAME = 'abc.net.au'
  7. _VALID_URL = r'http://www\.abc\.net\.au/news/[^/]+/[^/]+/(?P<id>\d+)'
  8. _TEST = {
  9. 'url': 'http://www.abc.net.au/news/2014-11-05/australia-to-staff-ebola-treatment-centre-in-sierra-leone/5868334',
  10. 'md5': 'cb3dd03b18455a661071ee1e28344d9f',
  11. 'info_dict': {
  12. 'id': '5868334',
  13. 'ext': 'mp4',
  14. 'title': 'Australia to help staff Ebola treatment centre in Sierra Leone',
  15. 'description': 'md5:809ad29c67a05f54eb41f2a105693a67',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. urls_info_json = self._search_regex(
  22. r'inlineVideoData\.push\((.*?)\);', webpage, 'video urls',
  23. flags=re.DOTALL)
  24. urls_info = json.loads(urls_info_json.replace('\'', '"'))
  25. formats = [{
  26. 'url': url_info['url'],
  27. 'width': int(url_info['width']),
  28. 'height': int(url_info['height']),
  29. 'tbr': int(url_info['bitrate']),
  30. 'filesize': int(url_info['filesize']),
  31. } for url_info in urls_info]
  32. self._sort_formats(formats)
  33. return {
  34. 'id': video_id,
  35. 'title': self._og_search_title(webpage),
  36. 'formats': formats,
  37. 'description': self._og_search_description(webpage),
  38. 'thumbnail': self._og_search_thumbnail(webpage),
  39. }