我正在编写Rhythmbox插件,以在Rhythmbox当前已知的所有播客文件(无论是否下载)上迭代并与它们做某事。

经过一些在Rhythmbox的Python Shell中进行的研究和测试之后,我成功获得了所有对象的列表。但是,当我将其编码为插件时,我会发现一个错误:

(rhythmbox:7500): GLib-GObject-WARNING **: invalid cast from `RhythmDBTree' to `RhythmDBEntryType'

entries 列表为空:

def run(self, action, shell):
    db = shell.get_property('db')
    entry_type = db.entry_type_get_by_name('podcast-post')
    print entry_type
    entries = []
    db.entry_foreach_by_type(entry_type, entries.append)
    print entries

然而 print entry_type 返回: <rhythmdb.EntryType object at 0xa7ea34c (RhythmDBEntryType at 0xa106988)>, ,因此DB对象显然是有效的。

我究竟做错了什么?

有帮助吗?

解决方案 2

我尝试了以下内容:

def run(self, action, shell):
    db = shell.get_property('db')
    entry_type = db.entry_type_get_by_name('podcast-post')
    print entry_type
    entries = []
    db.entry_foreach(entries.append)
    print entries
    for entry in entries:
        if entry.get_type() == entry_type:
            # process entry...

它正常工作。好吧,不是最美丽的解决方案,但可以满足我的需求。

其他提示

首先尝试重新安装Rhythmbox。

查看输出的内容,在我的计算机上运行良好,在计算机上发布该输出的内容

from __future__ import print_function

def plugin_create(database):
    print(database)
    db.entry_foreach_by_type(db.entry_type_get_by_name('podcast-post'), print)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top