Im using Ubuntu 12.04. I want to access Rhythymbox using Python .
This is how I've proceeded so far:
Ive gone through this site https://live.gnome.org/RhythmboxPlugins/WritingGuide , but it gives details on how to write plugins , which Im not interested in right now. Ive gone through a few tutorials which tells me to do this.
import dbus
session_bus = dbus.SessionBus()
proxy_obj = session_bus.get_object(
'org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Player')
But I am getting the following error
DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Rhythmbox was not provided by any .service files.
Could someone please point me in the right direction of what I would like to achieve?
A workaround, used by lyricsdownloader.py, is:
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 shipped without rhythmbox-client.
This might be useful. https://github.com/aliva/rhythmbox-microblogger
It 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 give enum which you can use to get the title.
I think that you've encountered a bug in Rhythmbox DBus interface described on Launchpad. Tracker says that fix is committed, but possibly your version doesn't have that fix.
来源:https://stackoverflow.com/questions/11939856/how-do-i-get-the-currently-playing-song-in-rhythmbox-using-python