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.

48 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-07-25/bringing-asylum-seekers-to-australia-would-give/5624716',
  10. 'md5': 'dad6f8ad011a70d9ddf887ce6d5d0742',
  11. 'info_dict': {
  12. 'id': '5624716',
  13. 'ext': 'mp4',
  14. 'title': 'Bringing asylum seekers to Australia would give them right to asylum claims: professor',
  15. 'description': 'md5:ba36fa5e27e5c9251fd929d339aea4af',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. webpage = self._download_webpage(url, video_id)
  22. urls_info_json = self._search_regex(
  23. r'inlineVideoData\.push\((.*?)\);', webpage, 'video urls',
  24. flags=re.DOTALL)
  25. urls_info = json.loads(urls_info_json.replace('\'', '"'))
  26. formats = [{
  27. 'url': url_info['url'],
  28. 'width': int(url_info['width']),
  29. 'height': int(url_info['height']),
  30. 'tbr': int(url_info['bitrate']),
  31. 'filesize': int(url_info['filesize']),
  32. } for url_info in urls_info]
  33. self._sort_formats(formats)
  34. return {
  35. 'id': video_id,
  36. 'title': self._og_search_title(webpage),
  37. 'formats': formats,
  38. 'description': self._og_search_description(webpage),
  39. 'thumbnail': self._og_search_thumbnail(webpage),
  40. }