]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/hark.py
Merge remote-tracking branch 'upstream/master'
[youtube-dl.git] / youtube_dl / extractor / hark.py
1 # -*- coding: utf-8 -*-
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import determine_ext
7
8 class HarkIE(InfoExtractor):
9     _VALID_URL = r'https?://www\.hark\.com/clips/(.+?)-.+'
10     _TEST = {
11         u'url': u'http://www.hark.com/clips/mmbzyhkgny-obama-beyond-the-afghan-theater-we-only-target-al-qaeda-on-may-23-2013',
12         u'file': u'mmbzyhkgny.mp3',
13         u'md5': u'6783a58491b47b92c7c1af5a77d4cbee',
14         u'info_dict': {
15             u"title": u"Obama: 'Beyond The Afghan Theater, We Only Target Al Qaeda' On May 23, 2013 ",
16         }
17     }
18
19     def _real_extract(self, url):
20         mobj = re.match(self._VALID_URL, url)
21         video_id = mobj.group(1)
22         embed_url = "http://www.hark.com/clips/%s/homepage_embed" %(video_id)
23         webpage = self._download_webpage(embed_url, video_id)
24
25         final_url = self._search_regex(r'src="(.+?).mp3"',
26                                 webpage, 'video url')+'.mp3'
27         title = self._html_search_regex(r'<title>(.+?)</title>',
28                                 webpage, 'video title').replace(' Sound Clip and Quote - Hark','').replace(
29                                 'Sound Clip , Quote, MP3, and Ringtone - Hark','')
30
31         return {'id': video_id,
32                 'url' : final_url,
33                 'title': title,
34                 'ext': determine_ext(final_url),
35                 }