All pastes #742131 Raw Edit

Mine

public python v1 · immutable
·published 2007-10-19 07:47 UTC
rendered paste body
import xmmsclientimport xmmsclient.glib as xgimport xmmsclient.collections as xcimport itertoolsimport osimport gobjectloop = gobject.MainLoop()xmms = xmmsclient.XMMS("pygnt-test")xmms.connect(os.getenv("XMMS_PATH"))conn = xg.GLibConnector(xmms)def got_list_of_songs_in_pl(result):    list = result.value()    pos = itertools.count(1)    for song in list:        def got_song_details(result):            info = result.value()            def safe(ar, at):                try:                    return str(ar[at])                except:                    return ""            position = str(pos.next()) # XXX: This does NOT work            title = safe(info, 'title')            artist = safe(info, 'artist')            album = safe(info, 'album')            time = safe(info, 'time')   # XXX: What should I really use?            print position, " | ", title, " | ", artist, " | ", album, " | ", time        # song is the medialib id        xmms.medialib_get_info(song, got_song_details)xmms.playlist_list_entries(None, got_list_of_songs_in_pl)loop.run()