From 8904290454ce678a8f9ca35852f2cc6e81157b80 Mon Sep 17 00:00:00 2001 From: 80002462 <80002462@sf-express.com> Date: Thu, 9 May 2019 13:27:26 +0800 Subject: [PATCH] fix artist's dict cannot be found exception --- app.py | 7 ++++--- requirements.txt | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index c47d771..8d94f14 100644 --- a/app.py +++ b/app.py @@ -54,9 +54,9 @@ def validate_collision(path): def name_format(path, meta): information = { - 'artist': ','.join([artist[0] for artist in meta['artist']]), - 'title': meta['musicName'], - 'album': meta['album'] + 'artist': ','.join([artist[0] for artist in (meta.get('artist') if meta.get('artist') is not None else [])]), + 'title': meta.get('musicName'), + 'album': meta.get('album') } def substitute(matched): @@ -91,6 +91,7 @@ for path in args.input: continue if os.path.isdir(path): files += [os.path.join(path, name) for name in os.listdir(path) if os.path.splitext(name)[-1] == '.ncm'] + print(files) else: files += [path] diff --git a/requirements.txt b/requirements.txt index 97a6859..db67121 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ +Crypto mutagen pycryptodome