【问题标题】:How do I get the currently playing song in Rhythmbox using Python如何使用 Python 在 Rhythmbox 中获取当前正在播放的歌曲
【发布时间】:2012-08-10 00:14:33
【问题描述】:

我使用的是 Ubuntu 12.04。我想使用 Python 访问 Rhythymbox。

到目前为止,我是这样进行的:

我浏览过这个网站 https://live.gnome.org/RhythmboxPlugins/WritingGuide ,但它提供了有关如何编写插件的详细信息,我现在对此不感兴趣。我已经阅读了一些教程,告诉我这样做。

import dbus
session_bus = dbus.SessionBus()

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

但我收到以下错误

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

有人可以指出我想要实现的正确方向吗?

【问题讨论】:

  • 访问是什么意思? 具体你想做什么?
  • 我只想获取正在播放的歌曲的名称。
  • 也许你可以看看/usr/lib/rhythmbox/plugins/im-status/im-status.py中的im-status插件,它把歌曲的名字放在pidgin/empathy中

标签: python dbus rhythmbox


【解决方案1】:

lyricsdownloader.py 使用的解决方法是:

import subprocess
import shlex

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

注意:这不适用于 Ubuntu 11.10,它没有带节奏盒客户端。

【讨论】:

  • 如何将标题捕获为 str?当我 print title 我得到 None 并且 var 测试为 NoneType...
  • 这很好,但请注意,可能有几首歌曲名称相同但位于不同的文件夹中(例如,它们在不同年份演唱,但名称相同)。我尝试了删除播放歌曲的方法,但问题是我不知道应该删除哪首歌曲。 (幸好我可以删除另一首歌)
【解决方案2】:

这可能很有用。 https://github.com/aliva/rhythmbox-microblogger

这是 RhythmBox 的推特插件。因此,您可以直接获取当前歌曲,而不是 twitter 和 Gtk。

from gi.repository import RB

RB.RhythmDBPropType.TITLE 将提供可用于获取标题的枚举。

【讨论】:

    【解决方案3】:

    我认为您在Launchpad 中描述的 Rhythmbox DBus 接口中遇到了错误。 Tracker 表示已提交修复,但您的版本可能没有该修复。

    【讨论】:

    • 它仍在发生,在“修复发布”很久之后
    猜你喜欢
    • 2015-05-17
    • 2020-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-10
    • 2010-11-22
    • 2017-07-25
    • 1970-01-01
    相关资源
    最近更新 更多