mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix: playcount reset to 1 on remap
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ class SendTrackFileQuery(BaseModel):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
container: Literal["mp3", "aac", "flac", "webm", "ogg"] = Field(
|
container: Literal["mp3", "aac", "flac", "webm", "ogg"] = Field(
|
||||||
"flac",
|
"mp3",
|
||||||
description="The container format of the audio file. Options: mp3, aac, flac, webm, ogg",
|
description="The container format of the audio file. Options: mp3, aac, flac, webm, ogg",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -33,16 +33,16 @@ def map_scrobble_data():
|
|||||||
if track is None:
|
if track is None:
|
||||||
continue
|
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)
|
album = AlbumStore.albummap.get(track.tracks[0].albumhash)
|
||||||
if album:
|
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:
|
for artisthash in track.tracks[0].artisthashes:
|
||||||
artist = ArtistStore.artistmap.get(artisthash)
|
artist = ArtistStore.artistmap.get(artisthash)
|
||||||
if artist:
|
if artist:
|
||||||
artist.increment_playcount(data["playduration"], data["lastplayed"])
|
artist.increment_playcount(data["playduration"], data["lastplayed"], data["playcount"])
|
||||||
|
|
||||||
|
|
||||||
def map_favorites():
|
def map_favorites():
|
||||||
|
|||||||
+2
-2
@@ -28,10 +28,10 @@ class AlbumMapEntry:
|
|||||||
def basetitle(self):
|
def basetitle(self):
|
||||||
return self.album.base_title
|
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.lastplayed = timestamp
|
||||||
self.album.playduration += duration
|
self.album.playduration += duration
|
||||||
self.album.playcount += 1
|
self.album.playcount += playcount
|
||||||
|
|
||||||
def toggle_favorite_user(self, userid: int | None = None):
|
def toggle_favorite_user(self, userid: int | None = None):
|
||||||
if userid is None:
|
if userid is None:
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ class ArtistMapEntry:
|
|||||||
self.albumhashes: set[str] = albumhashes
|
self.albumhashes: set[str] = albumhashes
|
||||||
self.trackhashes: set[str] = trackhashes
|
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.lastplayed = timestamp
|
||||||
self.artist.playduration += duration
|
self.artist.playduration += duration
|
||||||
self.artist.playcount += 1
|
self.artist.playcount += playcount
|
||||||
|
|
||||||
def toggle_favorite_user(self, userid: int | None = None):
|
def toggle_favorite_user(self, userid: int | None = None):
|
||||||
if userid is None:
|
if userid is None:
|
||||||
|
|||||||
+2
-2
@@ -31,12 +31,12 @@ class TrackGroup:
|
|||||||
"""
|
"""
|
||||||
self.tracks.remove(track)
|
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.
|
Increments the playcount of all tracks in the group.
|
||||||
"""
|
"""
|
||||||
for track in self.tracks:
|
for track in self.tracks:
|
||||||
track.playcount += 1
|
track.playcount += playcount
|
||||||
track.lastplayed = timestamp
|
track.lastplayed = timestamp
|
||||||
track.playduration += duration
|
track.playduration += duration
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user