Bug 211777

Summary: [PATCH] rating is a float in amarok and an integer in dbus
Product: [Applications] amarok Reporter: kakashizilla
Component: Collections/LocalAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: karaluh, kfunk, maximilian.kossick, mitchell, psychonaut
Priority: NOR    
Version: 2.3-GIT   
Target Milestone: 2.4.0   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description kakashizilla 2009-10-25 14:38:58 UTC
Version:           2.2.0 (using KDE 4.3.1)
Compiler:          gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC)  
OS:                Linux
Installed from:    Fedora RPMs

Amarok 2 uses a float to code the rating,
but the dbus method GetMetadata() gives an integer.
So, we loose the information about half-stars when we use dbus to get the rating.
Why not use the same notation as in amarok 1.4, i.e. 0 <= rating <= 10 ?
Comment 1 Mikko C. 2009-10-27 13:55:50 UTC
true, I can confirm this. Not sure how to CC for this.
Comment 2 Daniel Dewald 2009-12-08 14:33:44 UTC
I had a short look into this. internally Amarok is using the 0 <= rating <= 10 version of storing the rating. But trough dbus it tries to export the rating trough a float value which obviously dbus doesn't like and converts it to an int. et voilĂ  you got a rounded value. There a two possibilities as far as I see it. Output the 0 <= rating <= 10 version or output the rating in a way that dbus likes.
Comment 3 Myriam Schweingruber 2009-12-17 17:51:27 UTC
Rating is in the collection, I subscribe both Jeff and Max, let the developers decide :)
Comment 4 Kevin Funk 2010-02-18 18:21:57 UTC
It's an easy fix. Not sure if it breaks other stuff, though.
Please check, I am not committing this. 

diff --git a/src/meta/MetaUtility.cpp b/src/meta/MetaUtility.cpp
index 5d1bcf2..e6e2d67 100644
--- a/src/meta/MetaUtility.cpp
+++ b/src/meta/MetaUtility.cpp
@@ -127,7 +127,7 @@ Meta::Field::mprisMapFromTrack( const Meta::TrackPtr track )
             map["genre"] = track->genre()->name();

         map["comment"] = track->comment();
-        map["rating"] = track->rating()/2;  //out of 5, not 10.
+        map["rating"] = track->rating() / 2.0;  // out of 5, not 10. Return float (bug 211777).

         if( track->year() )
             map["year"] = track->year()->name();
Comment 5 Sven Krohlas 2010-03-24 15:54:40 UTC
So, is there anybody who wants to test that fix?
Comment 6 Myriam Schweingruber 2011-05-15 22:49:56 UTC
*** Bug 257609 has been marked as a duplicate of this bug. ***
Comment 7 Kevin Funk 2011-06-05 12:17:56 UTC
Actually a WONTFIX, MPRIS standard tells us to use integer values.

See: http://xmms2.org/wiki/MPRIS_Metadata#.22rating.22

"rating"

(uint32) A "taste" rate value, out of 5. 0-5 or 1-5? 


Hint:
You might want to use MPRIS v2.0 which uses the [0.0-1.0] range.
Comment 8 karaluh 2011-06-06 14:36:25 UTC
(In reply to comment #7)
> Actually a WONTFIX, MPRIS standard tells us to use integer values.
> 
> See: http://xmms2.org/wiki/MPRIS_Metadata#.22rating.22
> 
> "rating"
> 
> (uint32) A "taste" rate value, out of 5. 0-5 or 1-5? 

WONTFIX what?

> Hint:
> You might want to use MPRIS v2.0 which uses the [0.0-1.0] range.

Hint for who?
Comment 9 Kevin Funk 2011-06-06 16:13:38 UTC
WONTFIX: GetMetadata() won't return a float. We're following the MPRISv1 standard here

HINT: For anyone using dbus to get ratings, please use the MPRISv2 interface.