minor edits

This commit is contained in:
cwilvx
2024-10-29 01:57:01 +03:00
parent f6373292aa
commit 2ee501cc64
3 changed files with 20 additions and 17 deletions
+4 -2
View File
@@ -13,7 +13,6 @@ class Mix:
title: str
description: str
tracks: list[str]
image: dict
timestamp: int = field(default_factory=lambda: int(time.time()))
extra: dict = field(default_factory=dict)
@@ -25,7 +24,10 @@ class Mix:
_dict = asdict(self)
_dict["tracks"] = serialized_tracks
_dict["images"] = get_first_4_images(tracks)
if not self.extra.get("image"):
_dict["images"] = get_first_4_images(tracks)
_dict["duration"] = seconds_to_time_string(sum(t.duration for t in tracks))
_dict["trackcount"] = len(tracks)
+12 -13
View File
@@ -96,7 +96,7 @@ class MixesPlugin(Plugin):
return self.get_track_mix(tracks[: self.MAX_TRACKS_TO_FETCH])
@plugin_method
def create_artist_mixes(self, limit: int = 10):
def create_artist_mixes(self):
mixes: list[Mix] = []
indexed = set()
@@ -107,7 +107,7 @@ class MixesPlugin(Plugin):
artists = {
"today": {
"max": 2,
"max": 3,
"artists": get_artists_in_period(today_start, today_end),
"created": 0,
},
@@ -178,29 +178,29 @@ class MixesPlugin(Plugin):
"""
Given an artist dict, creates an artist mix.
"""
mix_tracks = self.get_artist_mix(artist["artisthash"])
if len(mix_tracks) < self.MIN_TRACK_MIX_LENGTH:
return None
_artist = ArtistStore.get_artist_by_hash(artist["artisthash"])
if not _artist:
return None
mix_tracks = self.get_artist_mix(artist["artisthash"])
if len(mix_tracks) < self.MIN_TRACK_MIX_LENGTH:
return None
return Mix(
# the a prefix indicates that this is an artist mix
id=f"a{artist['artisthash']}",
title=artist["artist"],
title=artist["artist"] + " Radio",
description=self.get_mix_description(mix_tracks, artist["artisthash"]),
tracks=[t.trackhash for t in mix_tracks],
extra={
"type": "artist",
"artisthash": artist["artisthash"],
},
image={
"image": _artist.image,
"color": _artist.color,
"image": {
"image": _artist.image,
"color": _artist.color,
},
},
)
@@ -243,4 +243,3 @@ class MixesPlugin(Plugin):
# Since the artisthashes are ordered by similarity score, we iterate from the start
# and go forward collecting tracks that aren't in the mix yet.
#
+2
View File
@@ -10,6 +10,8 @@ class HomepageStore:
@classmethod
def set_artist_mixes(cls, mixes: list[Mix], userid: int = 1):
print(f"⭐⭐⭐⭐ Setting {len(mixes)} artist mixes")
print("mix artists", [mix.title for mix in mixes])
idmap = {mix.id: mix for mix in mixes}
cls.entries["artist_mixes"][userid] = idmap