diff options
Diffstat (limited to 'src/library/command.py')
-rw-r--r-- | src/library/command.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/library/command.py b/src/library/command.py new file mode 100644 index 0000000..6b8577e --- /dev/null +++ b/src/library/command.py @@ -0,0 +1,21 @@ +import glob +import json +import os +import tomllib + +def run(book_library): + print(get(book_library)) + +def get(book_library): + metadatas = [] + + for path in glob.glob(f'{book_library}/**/metadata.toml', recursive=True): + with open(path, 'rb') as f: + directory = os.path.dirname(os.path.realpath(path)) + metadata = tomllib.load(f) + for p in glob.glob(f'{directory}/cover.*'): + metadata['cover'] = p + break + metadatas.append(metadata) + + return json.dumps(metadatas) |