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?
UPDATE: Thank you for your feedback. 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.