diff --git a/build_library.py b/build_library.py index 38ca474..0949ccf 100644 --- a/build_library.py +++ b/build_library.py @@ -20,10 +20,10 @@ def read_track(filepath): """ t = tinytag.TinyTag.get(filepath) - filepath = os.path.relpath(filepath, config.music_dir) + fpath_mod = os.path.relpath(filepath, config.music_dir) d = { - 'filepath': filepath, + 'filepath': fpath_mod, 'artist': t.artist, 'albumartist': t.albumartist, 'album': t.album, @@ -41,7 +41,7 @@ def read_track(filepath): async def build_library(root_dir): """Walks the directory and builds a library from tracks discovered.""" - print("Building library") + print("Scanning library") db_pool = await asyncpg.create_pool(**config.db) async with db_pool.acquire() as conn: @@ -65,13 +65,15 @@ async def build_library(root_dir): def worker(args): """Worker for multi-processing tracks.""" filepath, last_modified = args - track_prev = tracks_prev.get(filepath) + fpath_mod = os.path.relpath(filepath, config.music_dir) + track_prev = tracks_prev.get(fpath_mod) if track_prev: if track_prev['last_modified'] >= last_modified: return data = read_track(filepath) return data + print("Processing...") with multiprocessing.Pool() as pool: mapping = pool.imap(worker, filepaths) tracks = []