elearning.py: fix bug when video has no description
This commit is contained in:
parent
1165fc4f79
commit
04a62c834b
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user