From 40e6e478b86caa609ec8e3ec50dbe4634a7ecbfd Mon Sep 17 00:00:00 2001 From: nmrugg Date: Sat, 14 Mar 2015 12:38:18 +0800 Subject: [PATCH] Be able to download videos directly from a Livesteam JSON feed. Example URL: http://new.livestream.com/api/accounts/1504418/events/3705884/feed.json?&id=74703579&newer=-1&type=video --- youtube_dl/extractor/livestream.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/livestream.py b/youtube_dl/extractor/livestream.py index 3642089f7..0f7baa20e 100644 --- a/youtube_dl/extractor/livestream.py +++ b/youtube_dl/extractor/livestream.py @@ -134,9 +134,18 @@ class LivestreamIE(InfoExtractor): api_url, video_id, 'Downloading video info')) return self._extract_video_info(info) - config_json = self._search_regex( - r'window.config = ({.*?});', webpage, 'window config') - info = json.loads(config_json)['event'] + # Is this JSON? + if webpage[0] == "{": + info = json.loads(webpage) + # We cannot tell this information from a JSON feed. + info['id'] = 'unknown' + info['full_name'] = 'unknown' + # Change the JSON structure to match the window.config structure. + info['feed'] = info + else: + config_json = self._search_regex( + r'window.config = ({.*?});', webpage, 'window config') + info = json.loads(config_json)['event'] def is_relevant(vdata, vid): result = vdata['type'] == 'video' @@ -236,7 +245,7 @@ class LivestreamOriginalIE(InfoExtractor): class LivestreamShortenerIE(InfoExtractor): IE_NAME = 'livestream:shortener' IE_DESC = False # Do not list - _VALID_URL = r'https?://livestre\.am/(?P.+)' + _VALID_URL = r'https?://(new\.)?livestre\.am/(?P.+)' def _real_extract(self, url): mobj = re.match(self._VALID_URL, url)