From 40e6e478b86caa609ec8e3ec50dbe4634a7ecbfd Mon Sep 17 00:00:00 2001 From: nmrugg Date: Sat, 14 Mar 2015 12:38:18 +0800 Subject: [PATCH 1/2] 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) From f65c404408b99b8053a74d2d8f909b22e78533e3 Mon Sep 17 00:00:00 2001 From: nmrugg Date: Sat, 14 Mar 2015 14:59:24 +0800 Subject: [PATCH 2/2] Add TestDownload.test_Livestream_2 JSON test. --- youtube_dl/extractor/livestream.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/youtube_dl/extractor/livestream.py b/youtube_dl/extractor/livestream.py index 0f7baa20e..3f52b50bf 100644 --- a/youtube_dl/extractor/livestream.py +++ b/youtube_dl/extractor/livestream.py @@ -43,6 +43,13 @@ class LivestreamIE(InfoExtractor): }, { 'url': 'https://new.livestream.com/accounts/362/events/3557232/videos/67864563/player?autoPlay=false&height=360&mute=false&width=640', 'only_matching': True, + }, { + 'url': 'http://new.livestream.com/api/accounts/1504418/events/3705884/feed.json?&id=74703579&newer=-1&type=video', + 'info_dict': { + 'id': 'unknown', + 'title': 'unknown', + }, + 'playlist_mincount': 10, }] def _parse_smil(self, video_id, smil_url):