Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:53:06+00:00 2026-06-14T12:53:06+00:00

I am trying to create a Python plugin which will set the rating of

  • 0

I am trying to create a Python plugin which will set the rating of the currently playing song in Rhythmbox 2.96. It appears that Rhythmbox 2.96 doesn’t let you use the API (Python modules) to set the rating of a song anymore; player related actions have been dropped in favor of MPRIS.

I then tried looking at using dbus with MPRIS but MPRIS doesn’t have a spec for setting the rating of a song either. After a lot of digging, I found this sample in the Rhythmbox codebase and adapted it into a test script.

It works, but the SetEntryProperties method is causing Rhythmbox to freeze for about 30 seconds. Here is the Python script.


Instructions:

  1. Copy the code into a file called rate.py

  2. Start rhythmbox from a terminal using

    rhythmbox -D rate
    
  3. In Rhythmbox, enable the Python Console from the plugins

  4. Start the Python Console and run

       execfile('/path/to/rate.py')
    
  5. You will see the print output in the terminal and Rhythmbox freezes for about 20-30 seconds.


# rhythmbox -D rate
# Rhythmbox: Edit > Plugins > Python Console enabled
# Play a song
# Open Rhythmbox Python Console
# execfile('/path/to/rate.py')

import sys
import rb
from gi.repository import Gtk, Gdk

def rateThread(rating):
        try:
            currentSongURI = shell.props.shell_player.get_playing_entry().get_playback_uri()
            print "Setting rating for " + currentSongURI

            from gi.repository import GLib, Gio
            bus_type = Gio.BusType.SESSION
            flags = 0
            iface_info = None

            print "Get Proxy"
            proxy = Gio.DBusProxy.new_for_bus_sync(bus_type, flags, iface_info,
                                                   "org.gnome.Rhythmbox3",
                                                   "/org/gnome/Rhythmbox3/RhythmDB",
                                                   "org.gnome.Rhythmbox3.RhythmDB", None)

            print "Got proxy"
            rating = float(rating)
            vrating = GLib.Variant("d", rating)
            print "SetEntryProperties"
            proxy.SetEntryProperties("(sa{sv})", currentSongURI, {"rating": vrating})
            print "Done"
        except:
            print sys.exc_info()

        return False

def rate():
        if shell.props.shell_player.get_playing_entry():
            Gdk.threads_add_idle(100, rateThread, 3)

rate()

The exception that gets printed is:

 Desktop/test2.py:41: (<class 'gi._glib.GError'>, GError('Timeout was
 reached',),  <traceback object at 0x913e554>)

My knowledge of Python/dbus is limited, so I don’t understand why that error is occurring. I’d appreciate any help with it.

Also, if you know of a better way of setting the rating of a song in Rhythmbox through code, it would be welcome too!

I am using Ubuntu 12.04, if it makes a difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:53:07+00:00Added an answer on June 14, 2026 at 12:53 pm

    Setting the Rating within a plugin

    Rhythmbox 2.9x does provide an API to set the Rating – there is no need to call via dbus unless you are using an external program such as the Rhythmbox Tray Icon.

    Ratings are held as double type values in its internal database. Using a RhythmDBEntry you can obtain the Rating with

    rating = entry.get_double(RB.RhythmDBPropType.RATING)
    

    To set the rating you’ll need the RhythmDB entry_set function:

    db=self.shell.props.db
    db.entry_set(entry, RB.RhythmDBPropType.RATING, rating)
    

    Example code for getting and setting ratings can be found in the CoverArt Browser plugin (coverart_album.py)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create metaclass in Python (2.7) that will set arguments passed to
I'm currently trying to create a Python script that will autogenerate space-delimited arithmetic expressions
I'm trying to create a python script that will allow me to load up
I am trying to create a python script which I will later run as
I'm trying to create a python server that will serve calls from outer source
I am trying to create a Python script which will take an address as
Before I start, I am trying to create a python zip script which will
I'm trying to create a Python script that would : Look into the folder
I am trying to create a raw socket in Python that listens for UDP
I am trying to create a python script that opens a single page at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.