mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-01 00:52:58 +01:00
[hark] Modernize
This commit is contained in:
parent
8efd06aa42
commit
cdc5cb7c2b
@ -1,37 +1,33 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
import re
|
|
||||||
import json
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import determine_ext
|
|
||||||
|
|
||||||
class HarkIE(InfoExtractor):
|
class HarkIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://www\.hark\.com/clips/(.+?)-.+'
|
_VALID_URL = r'https?://www\.hark\.com/clips/(?P<id>.+?)-.+'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://www.hark.com/clips/mmbzyhkgny-obama-beyond-the-afghan-theater-we-only-target-al-qaeda-on-may-23-2013',
|
'url': 'http://www.hark.com/clips/mmbzyhkgny-obama-beyond-the-afghan-theater-we-only-target-al-qaeda-on-may-23-2013',
|
||||||
u'file': u'mmbzyhkgny.mp3',
|
'md5': '6783a58491b47b92c7c1af5a77d4cbee',
|
||||||
u'md5': u'6783a58491b47b92c7c1af5a77d4cbee',
|
'info_dict': {
|
||||||
u'info_dict': {
|
'id': 'mmbzyhkgny',
|
||||||
u'title': u"Obama: 'Beyond The Afghan Theater, We Only Target Al Qaeda' on May 23, 2013",
|
'ext': 'mp3',
|
||||||
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.',
|
'title': 'Obama: \'Beyond The Afghan Theater, We Only Target Al Qaeda\' on May 23, 2013',
|
||||||
u'duration': 11,
|
'description': '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.',
|
||||||
|
'duration': 11,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
video_id = self._match_id(url)
|
||||||
video_id = mobj.group(1)
|
data = self._download_json(
|
||||||
json_url = "http://www.hark.com/clips/%s.json" %(video_id)
|
'http://www.hark.com/clips/%s.json' % video_id, video_id)
|
||||||
info_json = self._download_webpage(json_url, video_id)
|
|
||||||
info = json.loads(info_json)
|
|
||||||
final_url = info['url']
|
|
||||||
|
|
||||||
return {'id': video_id,
|
return {
|
||||||
'url' : final_url,
|
'id': video_id,
|
||||||
'title': info['name'],
|
'url': data['url'],
|
||||||
'ext': determine_ext(final_url),
|
'title': data['name'],
|
||||||
'description': info['description'],
|
'description': data.get('description'),
|
||||||
'thumbnail': info['image_original'],
|
'thumbnail': data.get('image_original'),
|
||||||
'duration': info['duration'],
|
'duration': data.get('duration'),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user