mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix artist color mapping
This commit is contained in:
@@ -18,7 +18,6 @@ class Mixes(CronJob):
|
||||
"""
|
||||
Creates the artist mixes
|
||||
"""
|
||||
print("⭐⭐⭐⭐ Mixes cron job running")
|
||||
ArtistMixes()
|
||||
|
||||
# INFO: Because you listened to artist items are generated using
|
||||
|
||||
+17
-6
@@ -474,7 +474,7 @@ class LibDataTable(Base):
|
||||
result = cls.execute(
|
||||
select(cls.itemhash, cls.color).where(cls.itemtype == type)
|
||||
)
|
||||
return [{"itemhash": r[0], "color": r[1]} for r in result.fetchall()]
|
||||
return [{"itemhash": r[0].replace(type, ''), "color": r[1]} for r in result.fetchall()]
|
||||
|
||||
|
||||
class MixTable(Base):
|
||||
@@ -610,26 +610,37 @@ class PageTable(Base):
|
||||
|
||||
@classmethod
|
||||
def get_all(cls):
|
||||
result = cls.execute(select(cls))
|
||||
result = cls.execute(select(cls).where(cls.userid == get_current_userid()))
|
||||
return [cls.to_dict(entry) for entry in result.fetchall()]
|
||||
|
||||
@classmethod
|
||||
def get_by_id(cls, id: int):
|
||||
result = cls.execute(select(cls).where(cls.id == id))
|
||||
result = cls.execute(
|
||||
select(cls).where(and_(cls.id == id, cls.userid == get_current_userid()))
|
||||
)
|
||||
return cls.to_dict(result.fetchone())
|
||||
|
||||
@classmethod
|
||||
def delete_by_id(cls, id: int):
|
||||
return cls.execute(delete(cls).where(cls.id == id), commit=True)
|
||||
return cls.execute(
|
||||
delete(cls).where(and_(cls.id == id, cls.userid == get_current_userid())),
|
||||
commit=True,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def update_items(cls, id: int, items: list[dict[str, Any]]):
|
||||
return cls.execute(
|
||||
update(cls).where(cls.id == id).values(items=items), commit=True
|
||||
update(cls)
|
||||
.where(and_(cls.id == id, cls.userid == get_current_userid()))
|
||||
.values(items=items),
|
||||
commit=True,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def update_one(cls, payload: dict[str, Any]):
|
||||
return cls.execute(
|
||||
update(cls).where(cls.id == payload["id"]).values(payload), commit=True
|
||||
update(cls)
|
||||
.where(and_(cls.id == payload["id"], cls.userid == get_current_userid()))
|
||||
.values(payload),
|
||||
commit=True,
|
||||
)
|
||||
|
||||
+5
-5
@@ -84,7 +84,11 @@ class ProcessAlbumColors:
|
||||
# INFO: Write to the database.
|
||||
if albumrecord is None:
|
||||
LibDataTable.insert_one(
|
||||
{"itemhash": albumhash, "color": colors[0], "itemtype": "album"}
|
||||
{
|
||||
"itemhash": "album" + albumhash,
|
||||
"color": colors[0],
|
||||
"itemtype": "album",
|
||||
}
|
||||
)
|
||||
else:
|
||||
LibDataTable.update_one(albumhash, {"color": colors[0]})
|
||||
@@ -109,7 +113,6 @@ class ProcessArtistColors:
|
||||
)
|
||||
|
||||
record = LibDataTable.find_one(artisthash, "artist")
|
||||
|
||||
if (record is not None) and (record.color is not None):
|
||||
continue
|
||||
|
||||
@@ -123,9 +126,6 @@ class ProcessArtistColors:
|
||||
if artist:
|
||||
artist.set_color(colors[0])
|
||||
|
||||
# INFO: Write to the database.
|
||||
print("RECORD")
|
||||
print(record)
|
||||
if record is None:
|
||||
LibDataTable.insert_one(
|
||||
{
|
||||
|
||||
@@ -100,7 +100,7 @@ class MixesPlugin(Plugin):
|
||||
print("Failed to decode JSON response from recommendation server")
|
||||
return [], [], []
|
||||
|
||||
trackhashes: list[str] = results["tracks"]
|
||||
trackhashes: list[str] = results.get("tracks", [])
|
||||
|
||||
trackmatches = TrackStore.get_flat_list()
|
||||
trackmatches = [t for t in trackmatches if t.weakhash in trackhashes]
|
||||
@@ -234,8 +234,6 @@ class MixesPlugin(Plugin):
|
||||
indexed.add(artist["artisthash"])
|
||||
period["created"] += 1
|
||||
|
||||
print(f"⭐⭐⭐⭐ Created {len(mixes)} mixes")
|
||||
print([m.title for m in mixes])
|
||||
return mixes
|
||||
|
||||
@classmethod
|
||||
@@ -286,8 +284,6 @@ class MixesPlugin(Plugin):
|
||||
|
||||
db_mix = MixTable.get_by_sourcehash(sourcehash)
|
||||
if db_mix:
|
||||
print(f"🔍 Found existing mix for {_artist.artist.name}")
|
||||
print(db_mix.title)
|
||||
return db_mix
|
||||
|
||||
mix_tracks, albums, artists = self.get_track_mix_data(tracks)
|
||||
|
||||
@@ -15,7 +15,8 @@ def log_startup_info():
|
||||
adresses = [FLASKVARS.get_flask_host()]
|
||||
|
||||
if FLASKVARS.get_flask_host() == "0.0.0.0":
|
||||
adresses = ["localhost", get_ip()]
|
||||
remote_ip = get_ip()
|
||||
adresses = ["localhost"] + ([remote_ip] if remote_ip else [])
|
||||
|
||||
print("Started app on:")
|
||||
for address in adresses:
|
||||
|
||||
@@ -77,7 +77,6 @@ def get_date_range(duration: str, units_ago: int = 0):
|
||||
seconds_ago = (
|
||||
pendulum.now() - pendulum.now().subtract().start_of(duration)
|
||||
).total_seconds() * units_ago
|
||||
print("seconds_ago", duration, str(seconds_ago))
|
||||
|
||||
match duration:
|
||||
case "day" | "week" | "month" | "year":
|
||||
|
||||
@@ -22,7 +22,10 @@ def get_ip():
|
||||
Returns the IP address of this device.
|
||||
"""
|
||||
soc = Socket.socket(Socket.AF_INET, Socket.SOCK_DGRAM)
|
||||
soc.connect(("8.8.8.8", 80))
|
||||
try:
|
||||
soc.connect(("8.8.8.8", 80))
|
||||
except OSError:
|
||||
return None
|
||||
ip_address = str(soc.getsockname()[0])
|
||||
soc.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user