fix favorites on homescreen

+ reduce tagger process count
This commit is contained in:
cwilvx
2025-03-10 12:23:25 +03:00
parent 26c4c599d5
commit 9725fd427b
10 changed files with 44 additions and 33 deletions
+11 -1
View File
@@ -98,10 +98,20 @@ def recover_items(items: list[dict]):
"item": serialize_playlist(playlist),
}
elif item["type"] == "favorite":
image = None
last_trackhash = FavoritesTable.get_last_trackhash()
if last_trackhash:
trackhash = last_trackhash.replace("track_", "")
entry = TrackStore.trackhashmap.get(trackhash)
if entry:
image = entry.tracks[0].image
recovered_item = {
"type": "favorite",
"item": {
"count": FavoritesTable.count(),
"count": FavoritesTable.count_tracks(),
"image": image,
},
}
elif item["type"] == "track":
+2 -2
View File
@@ -48,8 +48,8 @@ class RecentlyPlayed(HomepageRoutine):
if (
store_entry
and item
and store_entry["type"] + store_entry["hash"]
== item["type"] + item["hash"]
and store_entry.get("type", "") + store_entry.get("hash", "")
== item.get("type", "") + item.get("hash", "")
):
# If the item is the same as the one in the store
# only update the timestamp
+2 -1
View File
@@ -1,3 +1,4 @@
import math
import os
from functools import partial
from multiprocessing import Pool, cpu_count
@@ -139,7 +140,7 @@ class IndexTracks:
config = UserConfig()
# Create process pool with worker function
with Pool(processes=cpu_count()) as pool:
with Pool(processes=math.floor(cpu_count() / 2)) as pool:
worker = partial(self._process_file, config=config, key=key)
# Process files and track progress
+3 -3
View File
@@ -193,7 +193,7 @@ def get_tags(filepath: str, config: UserConfig):
if no_artist and not no_albumartist:
# INFO: If no artist, use the albumartist
metadata["artist"] = tags.albumartist
metadata["artists"] = tags.albumartist
parse_data = None
@@ -255,7 +255,7 @@ def get_tags(filepath: str, config: UserConfig):
)
metadata["trackhash"] = create_hash(
metadata.get("artist", ""), metadata.get("album", ""), metadata.get("title", "")
metadata.get("artists", ""), metadata.get("album", ""), metadata.get("title", "")
)
extra: dict[str, Any] = {
@@ -267,7 +267,7 @@ def get_tags(filepath: str, config: UserConfig):
"format": "[:5]+[-5:]", # first 5 + last 5 chars
}
to_pop = ["filename", "artist", "albumartist", "year"]
to_pop = ["filename", "artists", "albumartist", "year"]
# REMOVE EMPTY VALUES
for key, value in extra.items():