mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
misc
This commit is contained in:
@@ -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()
|
||||
|
||||
+1
-1
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user