def playlistinfo(self, sortkey='pos'):
"""Shows playlist information sorted by key
"""
new_buf = wc.buffer_search("", "mpc: playlist")
if len(new_buf) == 0:
new_buf = wc.buffer_new('mpc: playlist', "", "", "", "")
pl = self._mpdc.playlistinfo()
try:
# Numerical sort
spl = sorted(pl,
cmp=lambda x,y: cmp(int(x), int(y)),
key=itemgetter(sortkey))
except ValueError:
# Alpha sort
lcmp = lambda x,y: cmp(x.lower(), y.lower())
spl = sorted(pl,
cmp=lambda x,y: cmp(x.lower(), y.lower()),
key=itemgetter(sortkey))
t = Template(wc.config_get_plugin("playinfo"))
for line in spl:
wc.prnt(new_buf, t.safe_substitute(line))
return pl
评论列表
文章目录