This commit is contained in:
mungai-njoroge 2023-07-17 11:30:05 +03:00
parent 861a854f91
commit e70d787580
4 changed files with 26 additions and 7 deletions

View File

@ -2,9 +2,11 @@
Contains methods relating to albums.
"""
from tqdm import tqdm
from alive_progress import alive_bar
from app.store.albums import AlbumStore
from app.store.tracks import TrackStore
from app.logger import log
def validate_albums():
@ -17,6 +19,9 @@ def validate_albums():
album_hashes = {t.albumhash for t in TrackStore.tracks}
albums = AlbumStore.albums
for album in tqdm(albums, desc="Validating albums"):
if album.albumhash not in album_hashes:
AlbumStore.remove_album(album)
with alive_bar(len(albums)) as bar:
log.info("Validating albums")
for album in albums:
if album.albumhash not in album_hashes:
AlbumStore.remove_album(album)
bar()

View File

@ -53,7 +53,7 @@ class ProcessAlbumColors:
"""
def __init__(self) -> None:
albums = [a for a in AlbumStore.albums if len(a.colors) == 0]
albums = [a for a in AlbumStore.albums if a is None or len(a.colors) == 0]
with SQLiteManager() as cur:
try:

View File

@ -186,6 +186,7 @@ def add_track(filepath: str) -> None:
extract_thumb(filepath, track.image)
def remove_track(filepath: str) -> None:
"""
Removes a track from the music dict.
@ -311,7 +312,11 @@ class Handler(PatternMatchingEventHandler):
time.sleep(5)
# Check the file size again
current_size = os.path.getsize(event.src_path)
try:
current_size = os.path.getsize(event.src_path)
except FileNotFoundError:
# File was deleted
return
if current_size == previous_size:
try:
@ -322,7 +327,7 @@ class Handler(PatternMatchingEventHandler):
self.files_to_process_windows.remove(event.src_path)
del self.file_sizes[event.src_path]
except OSError:
# File is locked, skipping
# File is locked
pass
return

View File

@ -12,6 +12,7 @@ from app.setup import run_setup
from app.start_info_logger import log_startup_info
from app.utils.filesystem import get_home_res_path
from app.utils.threading import background
from alive_progress import config_handler
werkzeug = logging.getLogger("werkzeug")
werkzeug.setLevel(logging.ERROR)
@ -47,7 +48,15 @@ def start_watchdog():
WatchDog().run()
def configure_alive_bar():
"""
Sets the default alive bar settings.
"""
config_handler.set_global(spinner="classic", bar="classic2", enrich_print=False)
if __name__ == "__main__":
configure_alive_bar()
HandleArgs()
log_startup_info()
bg_run_setup()