add because you listened to artist artists

+ add artists you might like
This commit is contained in:
cwilvx
2024-11-27 10:55:11 +03:00
parent e42ec3afb5
commit 809415ddb4
6 changed files with 138 additions and 9 deletions
+2 -2
View File
@@ -184,7 +184,7 @@ def get_recently_played(
return items
def recover_recently_played_items(items: list[dict]):
def recover_items(items: list[dict]):
custom_playlists = [
{"name": "recentlyadded", "handler": get_recently_added_playlist},
{"name": "recentlyplayed", "handler": get_recently_played_playlist},
@@ -235,7 +235,7 @@ def recover_recently_played_items(items: list[dict]):
},
}
elif item["type"] == "playlist":
if item["is_custom"]:
if item.get("is_custom"):
playlist, _ = next(
i["handler"]()
for i in custom_playlists
+37
View File
@@ -0,0 +1,37 @@
from pprint import pprint
from app.db.userdata import UserTable
from app.lib.recipes import HomepageRoutine
from app.lib.recipes.artistmixes import ArtistMixes
from app.models.mix import Mix
from app.plugins.mixes import MixesPlugin
from app.store.homepage import HomepageStore
class BecauseYouListened(HomepageRoutine):
store_keys = ["because_you_listened_to_artist", "artists_you_might_like"]
@property
def is_valid(self):
return MixesPlugin().enabled
def run(self):
users = UserTable.get_all()
for user in users:
entry: dict[str, Mix] = HomepageStore.entries.get(
ArtistMixes.store_key
).items.get(user.id) # type: ignore
if not entry:
continue
because_you_listened_to_artist, artists_you_might_like = (
MixesPlugin().get_because_items(list(entry.values()))
)
HomepageStore.entries[self.store_keys[0]].items[
user.id
] = because_you_listened_to_artist
HomepageStore.entries[self.store_keys[1]].items[
user.id
] = artists_you_might_like