justin.tv tweaks

- download all parts of a broadcast, fixes #614
- set "uploader" variable to channel_name if available
- catch api errors even if http status is 200
This commit is contained in:
atomizer 2013-01-07 16:59:39 +04:00
parent 0aa3068e9e
commit fa1bf9c653
1 changed files with 9 additions and 3 deletions

View File

@ -3524,17 +3524,23 @@ class JustinTVIE(InfoExtractor):
return return
response = json.loads(webpage) response = json.loads(webpage)
if type(response) != list:
error_text = response.get('error', 'unknown error')
self._downloader.trouble(u'ERROR: Justin.tv API: %s' % error_text)
return
info = [] info = []
for clip in response: for clip in response:
video_url = clip['video_file_url'] video_url = clip['video_file_url']
if video_url: if video_url:
video_extension = os.path.splitext(video_url)[1][1:] video_extension = os.path.splitext(video_url)[1][1:]
video_date = re.sub('-', '', clip['created_on'][:10]) video_date = re.sub('-', '', clip['start_time'][:10])
video_uploader_id = clip.get('user_id', clip.get('channel_id'))
info.append({ info.append({
'id': clip['id'], 'id': clip['id'],
'url': video_url, 'url': video_url,
'title': clip['title'], 'title': clip['title'],
'uploader': clip.get('user_id', clip.get('channel_id')), 'uploader': clip.get('channel_name', video_uploader_id),
'uploader_id': video_uploader_id,
'upload_date': video_date, 'upload_date': video_date,
'ext': video_extension, 'ext': video_extension,
}) })
@ -3553,7 +3559,7 @@ class JustinTVIE(InfoExtractor):
paged = True paged = True
api += '/channel/archives/%s.json' api += '/channel/archives/%s.json'
else: else:
api += '/clip/show/%s.json' api += '/broadcast/by_archive/%s.json'
api = api % (video_id,) api = api % (video_id,)
self.report_extraction(video_id) self.report_extraction(video_id)