From 04a62c834be6bb5f354ae6b1276b1ea225fcfd90 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 12 Apr 2020 09:43:55 +0200 Subject: [PATCH] elearning.py: fix bug when video has no description --- python/elearning.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/elearning.py b/python/elearning.py index b579e1f..8c90510 100755 --- a/python/elearning.py +++ b/python/elearning.py @@ -250,6 +250,10 @@ def save_video(infos, files, args): urls = (i['downloadUrl'] for i in infos) info = infos[0] + # fallback to name if no description + if not info['description']: + info['description'] = info['name'] + # use the description as a filename title = [] for word in info['description'].split(): @@ -282,7 +286,7 @@ def save_video(infos, files, args): ffmpeg = [ 'ffmpeg', '-hide_banner', '-loglevel', 'error', - '-stats', '-y' + '-stats' ] + inputs + maps + args.ffmpeg + [ # video '-c:v', 'libx265', '-preset', 'slow', '-crf', '23', @@ -361,10 +365,10 @@ def main(args): else: print('url:', info[0]['downloadUrl']) printr() - if args.json: - output.append(info) else: save_video(info, files, args) + if args.json: + output.append(info) if args.json: print(json.dumps(output))