4

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?

Manoj
  • 961
  • 4
  • 11
  • 37

3 Answers3

3

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.

unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
  • How do can you capture title as a str? when I `print title` I get `None` and the var tests as a NoneType... – Jay Gattuso Feb 09 '13 at 08:07
  • that's fine, but notice there can be a few songs with the same name but in different folders (e.g. they were sung in different years, but they have the same names). I tried with way for deleting playing song, but problem was that I can't figure out which song I should delete. (and regards to luck I could delete another song) – Tebe Mar 08 '13 at 15:51
2

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.

Froyo
  • 17,947
  • 8
  • 45
  • 73
1

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.

Rostyslav Dzinko
  • 39,424
  • 5
  • 49
  • 62