How to get current song in Rhythmbox using Python

Im using Ubuntu 12.04. I want to access Rhythymbox using Python.

Here is how I have continued so far:

I went through this site https://live.gnome.org/RhythmboxPlugins/WritingGuide , but it gives detailed information on how to write plugins that I'm not interested in right now. Ive done a few guides that tell me about this.

import dbus session_bus = dbus.SessionBus() proxy_obj = session_bus.get_object( 'org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Player') 

But I get the following error:

 DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Rhythmbox was not provided by any .service files. 

Can someone point me in the right direction of what I would like to achieve?

+4
source share
3 answers

Workaround used by lyricsdownloader.py :

 import subprocess import shlex proc = subprocess.Popen(shlex.split('rhythmbox-client --no-start --print-playing-format %tt'))) title, err = proc.communicate() 

Note. This does not work with Ubuntu 11.10, which comes without rhythmbox-client.

+3
source

I think you encountered a bug in the Rhythmbox DBus interface described on Launchpad . Tracker says the fix is ​​fixed, but maybe your version does not have this fix.

+1
source

This may be helpful. https://github.com/aliva/rhythmbox-microblogger

This is a Twitter plugin for RhythmBox. So instead of twitter and gtk you can just take the current song.

 from gi.repository import RB 

RB.RhythmDBPropType.TITLE will provide an enumeration that you can use to get the header.

+1
source

All Articles