mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-08 12:15:39 +00:00
misc
This commit is contained in:
parent
861a854f91
commit
e70d787580
@ -2,9 +2,11 @@
|
|||||||
Contains methods relating to albums.
|
Contains methods relating to albums.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from tqdm import tqdm
|
from alive_progress import alive_bar
|
||||||
|
|
||||||
from app.store.albums import AlbumStore
|
from app.store.albums import AlbumStore
|
||||||
from app.store.tracks import TrackStore
|
from app.store.tracks import TrackStore
|
||||||
|
from app.logger import log
|
||||||
|
|
||||||
|
|
||||||
def validate_albums():
|
def validate_albums():
|
||||||
@ -17,6 +19,9 @@ def validate_albums():
|
|||||||
album_hashes = {t.albumhash for t in TrackStore.tracks}
|
album_hashes = {t.albumhash for t in TrackStore.tracks}
|
||||||
albums = AlbumStore.albums
|
albums = AlbumStore.albums
|
||||||
|
|
||||||
for album in tqdm(albums, desc="Validating albums"):
|
with alive_bar(len(albums)) as bar:
|
||||||
|
log.info("Validating albums")
|
||||||
|
for album in albums:
|
||||||
if album.albumhash not in album_hashes:
|
if album.albumhash not in album_hashes:
|
||||||
AlbumStore.remove_album(album)
|
AlbumStore.remove_album(album)
|
||||||
|
bar()
|
||||||
|
@ -53,7 +53,7 @@ class ProcessAlbumColors:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
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:
|
with SQLiteManager() as cur:
|
||||||
try:
|
try:
|
||||||
|
@ -186,6 +186,7 @@ def add_track(filepath: str) -> None:
|
|||||||
|
|
||||||
extract_thumb(filepath, track.image)
|
extract_thumb(filepath, track.image)
|
||||||
|
|
||||||
|
|
||||||
def remove_track(filepath: str) -> None:
|
def remove_track(filepath: str) -> None:
|
||||||
"""
|
"""
|
||||||
Removes a track from the music dict.
|
Removes a track from the music dict.
|
||||||
@ -311,7 +312,11 @@ class Handler(PatternMatchingEventHandler):
|
|||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
# Check the file size again
|
# Check the file size again
|
||||||
|
try:
|
||||||
current_size = os.path.getsize(event.src_path)
|
current_size = os.path.getsize(event.src_path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
# File was deleted
|
||||||
|
return
|
||||||
|
|
||||||
if current_size == previous_size:
|
if current_size == previous_size:
|
||||||
try:
|
try:
|
||||||
@ -322,7 +327,7 @@ class Handler(PatternMatchingEventHandler):
|
|||||||
self.files_to_process_windows.remove(event.src_path)
|
self.files_to_process_windows.remove(event.src_path)
|
||||||
del self.file_sizes[event.src_path]
|
del self.file_sizes[event.src_path]
|
||||||
except OSError:
|
except OSError:
|
||||||
# File is locked, skipping
|
# File is locked
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ from app.setup import run_setup
|
|||||||
from app.start_info_logger import log_startup_info
|
from app.start_info_logger import log_startup_info
|
||||||
from app.utils.filesystem import get_home_res_path
|
from app.utils.filesystem import get_home_res_path
|
||||||
from app.utils.threading import background
|
from app.utils.threading import background
|
||||||
|
from alive_progress import config_handler
|
||||||
|
|
||||||
werkzeug = logging.getLogger("werkzeug")
|
werkzeug = logging.getLogger("werkzeug")
|
||||||
werkzeug.setLevel(logging.ERROR)
|
werkzeug.setLevel(logging.ERROR)
|
||||||
@ -47,7 +48,15 @@ def start_watchdog():
|
|||||||
WatchDog().run()
|
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__":
|
if __name__ == "__main__":
|
||||||
|
configure_alive_bar()
|
||||||
HandleArgs()
|
HandleArgs()
|
||||||
log_startup_info()
|
log_startup_info()
|
||||||
bg_run_setup()
|
bg_run_setup()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user