Skip to content

Commit ec9f392

Browse files
committed
write path hash on image property
1 parent fe39cad commit ec9f392

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

app/api/scrobble/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def get_stats():
357357
else "—"
358358
),
359359
(
360-
tracks[0].image + "?pathhash=" + tracks[0].pathhash
360+
tracks[0].image
361361
if len(tracks) > 0
362362
else None
363363
),

app/models/album.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def toggle_favorite_user(self, userid: int):
5454
self.fav_userids.append(userid)
5555

5656
def __post_init__(self):
57-
self.image = self.albumhash + ".webp"
57+
self.image = self.albumhash + ".webp" + "?pathhash=" + self.pathhash
5858
self.populate_versions()
5959
self.weakhash = create_hash(
6060
self.og_title, ",".join(a["name"] for a in self.albumartists)

app/models/track.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ class Track:
5252
image: str = ""
5353
explicit: bool = False
5454
fav_userids: list[int] = field(default_factory=list)
55-
pathhash: str = ""
5655

5756
@property
5857
def is_favorite(self):
5958
return get_current_userid() in self.fav_userids
6059

60+
@property
61+
def pathhash(self):
62+
return create_hash(self.folder)
63+
6164
def toggle_favorite_user(self, userid: int):
6265
"""
6366
Toggles the favorite status of the track for a given user.
@@ -82,9 +85,8 @@ def __post_init__(self):
8285
self.weakhash = create_hash(self.title, self.artists)
8386
explicit_tag = self.extra.get("explicit", ["0"])
8487
self.explicit = int(explicit_tag[0]) == 1
85-
self.pathhash = create_hash(self.folder)
8688

87-
self.image = self.albumhash + ".webp"
89+
self.image = self.albumhash + ".webp" + "?pathhash=" + self.pathhash
8890
self.extra = {
8991
"disc_total": self.extra.get("disc_total", 0),
9092
"track_total": self.extra.get("track_total", 0),

app/utils/stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def get_track_group_stats(tracks: list[Track], is_album: bool = False):
233233
"toptrack",
234234
f"top track ({seconds_to_time_string(top_track.playduration)} listened)",
235235
f"{top_track.title}",
236-
top_track.image + "?pathhash=" + top_track.pathhash if top_track else None,
236+
top_track.image if top_track else None,
237237
)
238238
if top_track
239239
else StatItem(
@@ -251,7 +251,7 @@ def get_track_group_stats(tracks: list[Track], is_album: bool = False):
251251
"playcount": 0,
252252
"playduration": 0,
253253
"title": track.album,
254-
"image": track.image + "?pathhash=" + track.pathhash if track.image else None,
254+
"image": track.image if track.image else None,
255255
}
256256

257257
albums_map[track.albumhash]["playcount"] += 1

0 commit comments

Comments
 (0)