[banshee] AppleDeviceTrackInfo: Fix reading and writing rating values (bgo#577396)



commit aaa117289de872f79f01dbedae47e1b83f2b7f97
Author: Samuel Gyger <samuel gyger at>
Date:   Fri Jun 1 14:34:33 2012 +0200

    AppleDeviceTrackInfo: Fix reading and writing rating values (bgo#577396)
    
    Libgpod stores rating as number_of_stars * 20, so we need to take that
    into account when reading and writing rating values.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 .../AppleDeviceTrackInfo.cs                        |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs
index b8549f7..77b908d 100644
--- a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs
+++ b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceTrackInfo.cs
@@ -41,6 +41,9 @@ namespace Banshee.Dap.AppleDevice
             get; set;
         }
 
+        // libgpod stores rating as stars*ITDB_RATING_STEP which is 20.
+        private const int ITDB_RATING_STEP = 20;
+
         private string mimetype;
         private string description; // Only used for podcasts.
 
@@ -153,8 +156,7 @@ namespace Banshee.Dap.AppleDevice
             AlbumTitleSort = track.SortAlbum;
             AlbumArtistSort = track.SortAlbumArtist;
             TrackTitleSort = track.SortTitle;
-
-            rating = track.Rating > 5 ? 0 : (int) track.Rating;
+            rating = track.Rating > 100 ? 0 : (int) track.Rating / ITDB_RATING_STEP;
 
             if (track.DRMUserID > 0) {
                 PlaybackError = StreamPlaybackError.Drm;
@@ -240,8 +242,7 @@ namespace Banshee.Dap.AppleDevice
             track.SortAlbum = AlbumTitleSort;
             track.SortAlbumArtist = AlbumArtistSort;
             track.SortTitle = TrackTitleSort;
-
-            track.Rating = ((Rating >= 1) && (Rating <= 5)) ? (uint)Rating : 0;
+            track.Rating = ((Rating >= 1) && (Rating <= 5)) ? (uint)Rating * ITDB_RATING_STEP : 0;
 
             if (HasAttribute (TrackMediaAttributes.Podcast)) {
                 track.Description = description;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]