fix: playcount reset to 1 on remap

This commit is contained in:
cwilvx
2024-09-08 12:08:52 +03:00
parent 30cc5bad0b
commit 3e61d86a19
5 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ class SendTrackFileQuery(BaseModel):
)
)
container: Literal["mp3", "aac", "flac", "webm", "ogg"] = Field(
"flac",
"mp3",
description="The container format of the audio file. Options: mp3, aac, flac, webm, ogg",
)
+3 -3
View File
@@ -33,16 +33,16 @@ def map_scrobble_data():
if track is None:
continue
track.increment_playcount(data["playduration"], data["lastplayed"])
track.increment_playcount(data["playduration"], data["lastplayed"], data["playcount"])
album = AlbumStore.albummap.get(track.tracks[0].albumhash)
if album:
album.increment_playcount(data["playduration"], data["lastplayed"])
album.increment_playcount(data["playduration"], data["lastplayed"], data["playcount"])
for artisthash in track.tracks[0].artisthashes:
artist = ArtistStore.artistmap.get(artisthash)
if artist:
artist.increment_playcount(data["playduration"], data["lastplayed"])
artist.increment_playcount(data["playduration"], data["lastplayed"], data["playcount"])
def map_favorites():
+2 -2
View File
@@ -28,10 +28,10 @@ class AlbumMapEntry:
def basetitle(self):
return self.album.base_title
def increment_playcount(self, duration: int, timestamp: int):
def increment_playcount(self, duration: int, timestamp: int, playcount: int = 1):
self.album.lastplayed = timestamp
self.album.playduration += duration
self.album.playcount += 1
self.album.playcount += playcount
def toggle_favorite_user(self, userid: int | None = None):
if userid is None:
+2 -2
View File
@@ -18,10 +18,10 @@ class ArtistMapEntry:
self.albumhashes: set[str] = albumhashes
self.trackhashes: set[str] = trackhashes
def increment_playcount(self, duration: int, timestamp: int):
def increment_playcount(self, duration: int, timestamp: int, playcount: int = 1):
self.artist.lastplayed = timestamp
self.artist.playduration += duration
self.artist.playcount += 1
self.artist.playcount += playcount
def toggle_favorite_user(self, userid: int | None = None):
if userid is None:
+2 -2
View File
@@ -31,12 +31,12 @@ class TrackGroup:
"""
self.tracks.remove(track)
def increment_playcount(self, duration: int, timestamp: int):
def increment_playcount(self, duration: int, timestamp: int, playcount: int = 1):
"""
Increments the playcount of all tracks in the group.
"""
for track in self.tracks:
track.playcount += 1
track.playcount += playcount
track.lastplayed = timestamp
track.playduration += duration