PodcastファイルにアクセスするRhythmboxプラグインは表示されません
質問
Rhythmboxプラグインを作成して、現在Rhythmboxに知られているすべてのポッドキャストファイル(ダウンロードしているかどうかにかかわらず)を反復し、それらと一緒に何かをすることです。
RhythmboxのPythonシェルでいくつかの調査とテストの後、私はすべてのオブジェクトのリストを取得することに成功しました。ただし、プラグインにコード化すると、エラーが発生します。
(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
以下を試しました:
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...
そして、それは正しく機能します。まあ、最も美しいソリューションではありませんが、私のニーズには問題ありません。
他のヒント
まず、Rhythmboxを再インストールしてみてください。
これが出力するものを見る、それは私のマシンで正常に動作します、あなたのマシンにこの出力が何を投稿するかを投稿してください
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)
所属していません StackOverflow