Rhythmbox plugin to access podcast files doesn't see them

700 views Asked by At

I am writing a Rhythmbox plugin to iterate over all podcast files currently known to Rhythmbox (whether downloaded or not) and to do something with them.

After some research and testing in the Rhythmbox's Python Shell, I succeeded to get a list of all objects. However, when I coded it into a plugin, I get an error:

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

and the entries list is empty:

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

However, the print entry_type returns: <rhythmdb.EntryType object at 0xa7ea34c (RhythmDBEntryType at 0xa106988)>, so the db object is apparently valid.

What am I doing wrong?

2

There are 2 answers

0
eumiro On BEST ANSWER

I tried the following:

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

and it works correctly. Well, not the most beautiful solution, but it is OK for my needs.

0
Zimm3r On

First try to reinstall rhythmbox.

See what this outputs, it runs fine on my machine, post what this outputs on your machine

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)