diff options
author | Jordan <me@jordan.im> | 2020-06-27 22:02:31 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2020-06-27 22:02:31 -0700 |
commit | 0f672bf0796250125003d770b19a082c93165bff (patch) | |
tree | bf14190a66a8ac3bb37ead7718c6cfd2a0f7cb61 | |
parent | f870d8ce4a2e5271ea02d07e5a2c26e12ec7e4bf (diff) | |
download | roka-0f672bf0796250125003d770b19a082c93165bff.tar.gz roka-0f672bf0796250125003d770b19a082c93165bff.zip |
housekeeping
-rwxr-xr-x | rebuild.py | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -8,7 +8,7 @@ from datetime import timedelta from flask import Flask from lib.tinytag import TinyTag -def get_books(root_path, cache=None): +def get_books(root_path, cache=dict()): ''' Discover audiobooks under :root_path: and populate books object @@ -20,9 +20,10 @@ def get_books(root_path, cache=None): # '/home/user/audiobooks/book': d815c7a3cc11f08558b4d91ca93de023 existing_books = {} - if cache: - for k, _ in cache.items(): - existing_books[cache[k]['path']] = k + for k, _ in cache.items(): + path = cache[k]['path'] + if os.path.exists(path): + existing_books[path] = k book_dirs = list() for root, dirs, _ in os.walk(root_path): @@ -62,6 +63,7 @@ def is_book(book_path): # a book_path is only a book if it contains at least one track is_book = False + for f in os.listdir(book_path): file_path = os.path.join(book_path, f) @@ -76,7 +78,7 @@ def is_book(book_path): # previous conditions met, we're a book! :D is_book = True - print('[+] processing: %s' % book_path) + print('[+] processing: %s' % f) # update collective hash of folder with MD5 of current file BLOCK = 1024 |