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.

37 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import determine_ext
  6. class HarkIE(InfoExtractor):
  7. _VALID_URL = r'https?://www\.hark\.com/clips/(.+?)-.+'
  8. _TEST = {
  9. u'url': u'http://www.hark.com/clips/mmbzyhkgny-obama-beyond-the-afghan-theater-we-only-target-al-qaeda-on-may-23-2013',
  10. u'file': u'mmbzyhkgny.mp3',
  11. u'md5': u'6783a58491b47b92c7c1af5a77d4cbee',
  12. u'info_dict': {
  13. u'title': u"Obama: 'Beyond The Afghan Theater, We Only Target Al Qaeda' on May 23, 2013",
  14. u'description': u'President Barack Obama addressed the nation live on May 23, 2013 in a speech aimed at addressing counter-terrorism policies including the use of drone strikes, detainees at Guantanamo Bay prison facility, and American citizens who are terrorists.',
  15. u'duration': 11,
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group(1)
  21. json_url = "http://www.hark.com/clips/%s.json" %(video_id)
  22. info_json = self._download_webpage(json_url, video_id)
  23. info = json.loads(info_json)
  24. final_url = info['url']
  25. return {'id': video_id,
  26. 'url' : final_url,
  27. 'title': info['name'],
  28. 'ext': determine_ext(final_url),
  29. 'description': info['description'],
  30. 'thumbnail': info['image_original'],
  31. 'duration': info['duration'],
  32. }