]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hark.py
Initiate release.
[youtubedl] / youtube_dl / extractor / hark.py
1 # -*- coding: utf-8 -*-
2
3 import re
4 import json
5
6 from .common import InfoExtractor
7 from ..utils import determine_ext
8
9 class HarkIE(InfoExtractor):
10 _VALID_URL = r'https?://www\.hark\.com/clips/(.+?)-.+'
11 _TEST = {
12 u'url': u'http://www.hark.com/clips/mmbzyhkgny-obama-beyond-the-afghan-theater-we-only-target-al-qaeda-on-may-23-2013',
13 u'file': u'mmbzyhkgny.mp3',
14 u'md5': u'6783a58491b47b92c7c1af5a77d4cbee',
15 u'info_dict': {
16 u'title': u"Obama: 'Beyond The Afghan Theater, We Only Target Al Qaeda' on May 23, 2013",
17 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.',
18 u'duration': 11,
19 }
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 video_id = mobj.group(1)
25 json_url = "http://www.hark.com/clips/%s.json" %(video_id)
26 info_json = self._download_webpage(json_url, video_id)
27 info = json.loads(info_json)
28 final_url = info['url']
29
30 return {'id': video_id,
31 'url' : final_url,
32 'title': info['name'],
33 'ext': determine_ext(final_url),
34 'description': info['description'],
35 'thumbnail': info['image_original'],
36 'duration': info['duration'],
37 }