aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/common.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-01-07 09:35:34 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-01-07 09:35:34 +0100
commit3d3538e422a711aab238f4d1ab667d72cc9bbdbf (patch)
treee268f0ce37ded1226eccf65d17dffb16cd9b01ee /youtube_dl/extractor/common.py
parent0cdad20c75d9bb4be2b5ea131baab18a45773ea8 (diff)
[khanacademy] Add support (Fixes #2066)
Diffstat (limited to 'youtube_dl/extractor/common.py')
-rw-r--r--youtube_dl/extractor/common.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 2a5e8076c..0ec365eaa 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -1,4 +1,5 @@
import base64
+import json
import os
import re
import socket
@@ -260,6 +261,15 @@ class InfoExtractor(object):
xml_string = transform_source(xml_string)
return xml.etree.ElementTree.fromstring(xml_string.encode('utf-8'))
+ def _download_json(self, url_or_request, video_id,
+ note=u'Downloading JSON metadata',
+ errnote=u'Unable to download JSON metadata'):
+ json_string = self._download_webpage(url_or_request, video_id, note, errnote)
+ try:
+ return json.loads(json_string)
+ except ValueError as ve:
+ raise ExtractorError('Failed to download JSON', cause=ve)
+
def report_warning(self, msg, video_id=None):
idstr = u'' if video_id is None else u'%s: ' % video_id
self._downloader.report_warning(