本文整理汇总了Python中mpd.MPDClient.listall方法的典型用法代码示例。如果您正苦于以下问题:Python MPDClient.listall方法的具体用法?Python MPDClient.listall怎么用?Python MPDClient.listall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpd.MPDClient
的用法示例。
在下文中一共展示了MPDClient.listall方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_spotify_playlists
# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listall [as 别名]
def get_spotify_playlists():
client=MPDClient()
mopidyAddress = '0.0.0.0'
mopidyPort = 6600
client.timeout = 10
client.idletimeout = None
client.connect(mopidyAddress,mopidyPort)
#client.password('IlPits2013')
folders = client.listall('Spotify')
#folders = client.lsinfo('Spotify')
folders = [os.path.basename(f['directory']) for f in folders if 'directory' in f.keys()]
#folders = [f['directory'].split(r'/') for f in folders if 'directory' in f.keys()]
#folders = [f[1] for f in folders if len(f)==2]
client.disconnect()
return folders
示例2: MPDClient
# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listall [as 别名]
s.bind("\0dadmusictv_shuffler")
except socket.error, e:
print "An instance of this shuffler is already running. Aborting."
import sys
sys.exit(0)
import random
from mpd import MPDClient
client = MPDClient()
while 1:
try:
client.connect('localhost',6600)
break
except:
print "Couldn't connect to music; waiting a bit and trying again"
time.sleep(5)
# Read the whole library. Not a problem, because dadmusictv expects you
# to restart the Pi if you've added new songs anyway.
songs = [x["file"] for x in client.listall() if x.has_key("file")]
while 1:
client.idle()
s = client.status()
if s.get("state") == "play" and s.get("nextsong") is None:
# We are at the end of the playlist. Remove all previous songs...
while len(client.playlistinfo()) > 2:
client.delete(0)
# ...and add a random song
client.add(random.choice(songs))