rhythmbox pythonプラグインからrhythmboxデータベースのすべてのアーティストをリストアップしようとしています。私が見つけた唯一の解決策は、UIにすべてのアーティストとすべての曲を選択させ、すべての曲をループし、その曲のアーティスト名をセットに追加することです。rhythmboxプラグインにすべてのアーティストを掲載するには
この問題は、データベース内のすべてのアーティストのリストが必要なので、選択したアーティストを変更したくないということです(痛みを伴うほど非効率的です)。先ほど選択したアーティストを保存していましたが、完了したら元の状態に戻すことができましたが、UIが新しい情報と詳細情報で更新するまでに時間がかかるという問題があります。データベース)を使用すると、時間がかかります。
コードが gitのクローン[email protected]でフェッチすることができます。
import rb
import rhythmdb
import gtk
class DblisterPlugin (rb.Plugin):
def __init__(self):
rb.Plugin.__init__(self)
def activate(self, shell):
self.shell = shell
print '##### dblister #####'
# choose all artists, this will choose all albums and songs as well
# get the lock for rhythmbox ui
gtk.gdk.threads_enter()
for p in self.shell.props.library_source.get_property_views():
if p.props.prop == rhythmdb.PROP_ARTIST:
p.set_selection([""])
break
gtk.gdk.threads_leave()
##################### Print all artists in database ######################
# loop through all songs currently selected (i.e. all songs since we did p.set_selection([""]) above
# for each song, try to add the artist name to the 'artists' set
artists = set() # unique keys, no duplicates
for row in self.shell.props.selected_source.props.query_model:
entry = row[0]
artist = self.shell.props.db.entry_get(entry, rhythmdb.PROP_ARTIST)
artists.add(artist)
print '--- artists ---'
for artist in artists:
print artist
##################### Print all songs in database ######################
print '--- songs ---'
# loop through all songs currently selected (i.e. all songs since we did p.set_selection([""]) above
# for each song, print artist name and title
for row in self.shell.props.selected_source.props.query_model:
entry = row[0]
artist = self.shell.props.db.entry_get(entry, rhythmdb.PROP_ARTIST)
song = self.shell.props.db.entry_get(entry, rhythmdb.PROP_TITLE)
print artist + ' - ' + song
def deactivate(self, shell):
del self.shell
print 'Bye world'
私ので、私はこれをしたい理由は次のとおりです。sameltvom/dblister.git
ここでは、コードですリズムボックスへのtelnetインターフェースを開発中、https://github.com/sameltvom/rhythmcurse。
入力してください!
敬具、 サミュエル