Skip to content

Commit

Permalink
fix album playtime calculation error
Browse files Browse the repository at this point in the history
  • Loading branch information
th0mk committed Jun 13, 2023
1 parent b3099b1 commit 52522d4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/FMBot.Bot/Services/TimeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ public async Task<TimeSpan> GetPlayTimeForAlbum(List<AlbumTrack> albumTracks, Li
if (playsLeft > 0)
{
var avgTrackLength = albumTracks.Average(a => a.Duration);

if (avgTrackLength == null)
{
var avgArtistTrackLength = (long?)this._cache.Get(CacheKeyForArtist(albumTracks.First().ArtistName));
avgTrackLength = avgArtistTrackLength ?? 210000;
}

totalPlaytime += (playsLeft * (long)avgTrackLength);
}

Expand Down

0 comments on commit 52522d4

Please sign in to comment.