【问题标题】:Rhythmbox plugin to access podcast files doesn't see them用于访问播客文件的 Rhythmbox 插件看不到它们
【发布时间】:2010-09-21 15:53:41
【问题描述】:

我正在编写一个 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 对象显然是有效的。

我做错了什么?

【问题讨论】:

  • 你能给出完整的代码,看看它运行在什么上面吗?

标签: python plugins podcast rhythmbox


【解决方案1】:

首先尝试重新安装节奏盒。

看看这个输出什么,它在我的机器上运行良好,把这个输出发布到你的机器上

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)

【讨论】:

    【解决方案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...
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-21
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多