mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
39 lines
1009 B
Python
39 lines
1009 B
Python
from app.db.userdata import UserTable
|
|
from app.lib.recipes import HomepageRoutine
|
|
from app.plugins.mixes import MixesPlugin
|
|
from app.store.homepage import HomepageStore
|
|
|
|
|
|
class ArtistMixes(HomepageRoutine):
|
|
store_key = "artist_mixes"
|
|
|
|
@property
|
|
def is_valid(self):
|
|
return MixesPlugin().enabled
|
|
|
|
def run(self):
|
|
users = UserTable.get_all()
|
|
|
|
for user in users:
|
|
mix = MixesPlugin()
|
|
mixes = mix.create_artist_mixes(user.id)
|
|
|
|
if not mixes:
|
|
continue
|
|
|
|
HomepageStore.set_mixes(mixes, entrykey=self.store_key, userid=user.id)
|
|
|
|
custom_mixes = []
|
|
for _mix in mixes:
|
|
custom_mix = MixesPlugin.get_track_mix(_mix)
|
|
|
|
if custom_mix:
|
|
custom_mixes.append(custom_mix)
|
|
|
|
HomepageStore.set_mixes(
|
|
custom_mixes, entrykey="custom_mixes", userid=user.id
|
|
)
|
|
|
|
def __init__(self) -> None:
|
|
super().__init__()
|