mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
handle watching ~/ dir
+ fix bug that caused duplicate album colors in db
This commit is contained in:
+7
-3
@@ -38,9 +38,13 @@ class ProcessAlbumColors:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
db_colors = db.get_all_albums()
|
||||
db_albumhashes = "-".join([album[1] for album in db_colors])
|
||||
|
||||
albums = [a for a in Store.albums if a.albumhash not in db_albumhashes]
|
||||
|
||||
with SQLiteManager() as cur:
|
||||
for album in tqdm(Store.albums, desc="Processing album colors"):
|
||||
for album in tqdm(albums, desc="Processing unprocessed album colors"):
|
||||
if len(album.colors) == 0:
|
||||
colors = self.process_color(album)
|
||||
|
||||
@@ -71,9 +75,9 @@ class ProcessArtistColors:
|
||||
def __init__(self) -> None:
|
||||
db_colors: list[tuple] = list(adb.get_all_artists())
|
||||
db_artisthashes = "-".join([artist[1] for artist in db_colors])
|
||||
all_artists = Store.artists
|
||||
all_artists = [a for a in Store.artists if a.artisthash not in db_artisthashes]
|
||||
|
||||
for artist in tqdm(all_artists, desc="Processing artist colors"):
|
||||
for artist in tqdm(all_artists, desc="Processing unprocessed artist colors"):
|
||||
if artist.artisthash not in db_artisthashes:
|
||||
self.process_color(artist)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import pathlib
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from app.db.store import Store
|
||||
|
||||
+11
-5
@@ -25,7 +25,7 @@ class Populate:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
messages = {
|
||||
text = {
|
||||
"root_unset": "The root directory is not set. Trying to scan the default directory: %s",
|
||||
"default_not_exists": "The directory: %s does not exist. Please open the app in your web browser to set the root directory.",
|
||||
"no_tracks": "No tracks found in: %s. Please open the app in your web browser to set the root directory.",
|
||||
@@ -40,17 +40,23 @@ class Populate:
|
||||
def_dir = "~/Music"
|
||||
|
||||
if len(dirs_to_scan) == 0:
|
||||
log.warning(messages["root_unset"], def_dir)
|
||||
log.warning(text["root_unset"], def_dir)
|
||||
print("...")
|
||||
|
||||
exists = os.path.exists(settings.MUSIC_DIR)
|
||||
|
||||
if not exists:
|
||||
log.warning(messages["default_not_exists"], def_dir)
|
||||
log.warning(text["default_not_exists"], def_dir)
|
||||
return
|
||||
|
||||
dirs_to_scan = [settings.MUSIC_DIR]
|
||||
|
||||
try:
|
||||
if dirs_to_scan[0] == "$home":
|
||||
dirs_to_scan = [settings.USER_HOME_DIR]
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
files = []
|
||||
|
||||
for _dir in dirs_to_scan:
|
||||
@@ -59,7 +65,7 @@ class Populate:
|
||||
untagged = self.filter_untagged(tracks, files)
|
||||
|
||||
if initial_dirs_count == 0 and len(untagged) == 0:
|
||||
log.warning(messages["no_tracks"], def_dir)
|
||||
log.warning(text["no_tracks"], def_dir)
|
||||
return
|
||||
|
||||
if initial_dirs_count == 0 and len(untagged) > 0:
|
||||
@@ -76,7 +82,7 @@ class Populate:
|
||||
settings.TCOLOR.ENDC,
|
||||
)
|
||||
sdb.add_root_dirs(dirs_to_scan)
|
||||
return
|
||||
# return
|
||||
|
||||
if len(untagged) == 0:
|
||||
log.info("All clear, no unread files.")
|
||||
|
||||
Reference in New Issue
Block a user