代码之家  ›  专栏  ›  技术社区  ›  eumiro

访问播客文件的Rhythbox插件看不到它们

  •  4
  • eumiro  · 技术社区  · 14 年前

    我正在编写一个RhythBox插件,用于迭代所有RhythBox当前已知的播客文件(无论是否下载),并对它们进行一些操作。

    在对节奏盒的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 回复  |  直到 12 年前
        1
  •  1
  •   Zimm3r    14 年前

    首先尝试重新安装Rhythbox。

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

    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
  •  0
  •   eumiro    12 年前

    我尝试了以下方法:

    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...
    

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

    推荐文章