Rhythmbox:如何访问“评级”?通过Python脚本跟踪轨道的字段?

发布于 2024-08-05 22:28:10 字数 49 浏览 4 评论 0原文

我希望能够通过 Python 获取/设置与特定曲目相关的评级。我该如何实现这一目标?

I would like the capability to get/set the rating associated with a specific track through a Python. How do I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

身边 2024-08-12 22:28:10

您可以使用 Rhythmbox 的 D-Bus 接口。我编写了一个小脚本,可以获取/设置评级并显示通知,所有这些都作用于当前播放的歌曲。

脚本在这里:http://kaizer.se/wiki/code/rhating.py

附录一:我保证我会写出更漂亮的 Python,但它不是一次性脚本!
附录二:缺少的用法字符串是 ./rhating.py [NEWRATING 0..5]

附录三:如果我过滤脚本并取出在文件系统中准确设置歌曲评级的部分位置uri,是这样的:

import dbus
bus = dbus.Bus()

service_name = "org.gnome.Rhythmbox"
sobj_name = "/org/gnome/Rhythmbox/Shell"
siface_name = "org.gnome.Rhythmbox.Shell"

def set_rating(uri, rating):
    searchobj = bus.get_object(service_name, sobj_name)
    shell = dbus.Interface(searchobj, siface_name)
    shell.setSongProperty(uri, "rating", float(rating))

You can use Rhythmbox' D-Bus interface. I have written a small script that can get/set the rating and displays a notification, all acting on the currently playing song.

The script is here: http://kaizer.se/wiki/code/rhrating.py

Addendum one: I promise I write more beautiful Python when it's not a throwaway script!
Addendum two: The missing Usage string is ./rhrating.py [NEWRATING 0..5]

Addendum three: If I filter the script and take out the parts that exactly set the rating of a song at filesystem location uri, it's this:

import dbus
bus = dbus.Bus()

service_name = "org.gnome.Rhythmbox"
sobj_name = "/org/gnome/Rhythmbox/Shell"
siface_name = "org.gnome.Rhythmbox.Shell"

def set_rating(uri, rating):
    searchobj = bus.get_object(service_name, sobj_name)
    shell = dbus.Interface(searchobj, siface_name)
    shell.setSongProperty(uri, "rating", float(rating))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文