Domanda

Sto scrivendo un plugin Rhythmbox per iterare su tutti i file podcast attualmente noti a Rhythmbox (sia scaricato o meno) e di fare qualcosa con loro.

Dopo alcune ricerche e la sperimentazione in Python Shell del Rhythmbox, sono riuscito ad ottenere un elenco di tutti gli oggetti. Tuttavia, quando ho codificato in un plugin, ottengo un errore:

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

e la lista entries è vuota:

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

Tuttavia, i rendimenti print entry_type:. <rhythmdb.EntryType object at 0xa7ea34c (RhythmDBEntryType at 0xa106988)>, quindi l'oggetto db è apparentemente valida

Che cosa sto facendo di sbagliato?

È stato utile?

Soluzione 2

ho provato il seguente:

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

e funziona correttamente. Beh, non è la soluzione più bella, ma è OK per le mie esigenze.

Altri suggerimenti

In primo luogo provare a reinstallare Rhythmbox.

vedere che cosa questo uscite, funziona benissimo sulla mia macchina, dopo ciò che questo uscite sulla vostra macchina

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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top