elearning.py: fix bug when video has no description

This commit is contained in:
Michele Guerini Rocco 2020-04-12 09:43:55 +02:00
parent 1165fc4f79
commit 04a62c834b
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

View File

@ -250,6 +250,10 @@ def save_video(infos, files, args):
urls = (i['downloadUrl'] for i in infos) urls = (i['downloadUrl'] for i in infos)
info = infos[0] info = infos[0]
# fallback to name if no description
if not info['description']:
info['description'] = info['name']
# use the description as a filename # use the description as a filename
title = [] title = []
for word in info['description'].split(): for word in info['description'].split():
@ -282,7 +286,7 @@ def save_video(infos, files, args):
ffmpeg = [ ffmpeg = [
'ffmpeg', '-hide_banner', 'ffmpeg', '-hide_banner',
'-loglevel', 'error', '-loglevel', 'error',
'-stats', '-y' '-stats'
] + inputs + maps + args.ffmpeg + [ ] + inputs + maps + args.ffmpeg + [
# video # video
'-c:v', 'libx265', '-preset', 'slow', '-crf', '23', '-c:v', 'libx265', '-preset', 'slow', '-crf', '23',
@ -361,10 +365,10 @@ def main(args):
else: else:
print('url:', info[0]['downloadUrl']) print('url:', info[0]['downloadUrl'])
printr() printr()
if args.json:
output.append(info)
else: else:
save_video(info, files, args) save_video(info, files, args)
if args.json:
output.append(info)
if args.json: if args.json:
print(json.dumps(output)) print(json.dumps(output))