Rhythmbox: how do I access the 'rating' field of a track via a Python script?
1 answer
You can use the D-Bus Rhythmbox interface. I wrote a small script that can get / set the rating and display a notification acting on the currently playing song.
The script is located here: http://kaizer.se/wiki/code/rhrating.py
Addendum 1: I promise to write prettier Python when it doesn't throw the script!
Appendix 2: Invalid Usage String./rhrating.py [NEWRATING 0..5]
Addendum three: If I filter the script and take out the parts that accurately rank the song at the filesystem location uri
, it is:
import dbus
bus = dbus.Bus()
service_name = "org.gnome.Rhythmbox"
sobj_name = "/org/gnome/Rhythmbox/Shell"
siface_name = "org.gnome.Rhythmbox.Shell"
def set_rating(uri, rating):
searchobj = bus.get_object(service_name, sobj_name)
shell = dbus.Interface(searchobj, siface_name)
shell.setSongProperty(uri, "rating", float(rating))
+3
source to share