本文整理汇总了Python中mpd.MPDClient.listallinfo方法的典型用法代码示例。如果您正苦于以下问题:Python MPDClient.listallinfo方法的具体用法?Python MPDClient.listallinfo怎么用?Python MPDClient.listallinfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpd.MPDClient
的用法示例。
在下文中一共展示了MPDClient.listallinfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listallinfo [as 别名]
def init():
global CLIENT, PLAYLIST, LIBRARY
## MPD object instance
CLIENT = MPDClient()
if mpdConnect(CLIENT, CON_ID):
logging.info('Connected to MPD server')
CLIENT.setvol(95)
PLAYLIST = CLIENT.playlistinfo()
LIBRARY = CLIENT.listallinfo()
repeat(True) # Repeat all tracks
else:
logging.critical('Failed to connect to MPD server')
logging.critical("Sleeping 1 second and retrying")
time.sleep(1)
init()
示例2: MPDClient
# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listallinfo [as 别名]
cursor.execute( "SELECT ROWID, title FROM albums" )
for album in cursor:
db_albums[album[1]] = album[0]
cursor.execute( "SELECT artists.name, albums.title FROM artists, albums, contributions WHERE contributions.artist = artists.ROWID AND contributions.album = albums.ROWID" )
for contribution in cursor:
db_catalog.add( contribution )
# Next get the current database from MPD.
player = MPDClient()
player.connect( 'guanaco', 6600 )
songs = player.listallinfo()
for song in songs:
artist = 'unknown'
album = 'unknown'
if 'artist' in song:
if type( song['artist'] ) is list:
artist = ' - '.join( song['artist'] )
else:
artist = song['artist']
if 'album' in song:
if type( song['album'] ) is list:
album = ' - '.join( song['album'] )
else:
album = song['album']
if artist not in db_artists:
示例3: MPDClient
# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listallinfo [as 别名]
args = parser.parse_args()
skip_tagged = args.skip_tagged
client = MPDClient()
client.timeout = 10
client.idletimeout = None
client.connect(MPD_HOST, MPD_PORT)
libdir = get_mpd_library_dir(MPD_CONF)
total_files_updated = 0
total_files_skipped = 0
total_image_size = 0
for song in client.listallinfo(''):
if not 'file' in song:
continue
file_rel = song['file']
if skip_tagged:
# Awful, I know. But the sticker_find() function did not do much.
try:
client.sticker_get('song', file_rel, 'image-nchunks')
# Track has art, skip it.
total_files_skipped += 1
continue
except:
# Track has no art.
pass
示例4: MPDClient
# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listallinfo [as 别名]
from mpd import MPDClient
client = MPDClient() # create client object
client.timeout = 10 # network timeout in seconds (floats allowed), default: None
client.idletimeout = None # timeout for fetching the result of the idle command is handled seperately, default: None
client.connect("localhost", 6600) # connect to localhost:6600
print(client.mpd_version) # print the MPD version
print(client.listallinfo()) # print result of the command "find any house"
client.close() # send the close command
client.disconnect()
示例5: play
# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listallinfo [as 别名]
@route('/do/<command>/')
def play(command):
status = request.mpd.status().get( 'state', '')
if command == 'play':
request.mpd.pause() if status == 'play' else request.mpd.play()
elif command == 'next':
request.mpd.next()
elif command == 'prev':
request.mpd.previous()
elif command == 'stop':
request.mpd.stop()
return redirect('/')
@route('/static/<filename:path>')
def send_static(filename):
return static_file(filename, root=os.path.join(BASE_DIR, 'static'))
if __name__ == '__main__':
Song.initialize()
c = MPDClient()
c.connect("localhost", 6600)
for s in c.listallinfo():
try:
song = Song(**s)
except Exception as e:
print(e, s)
else:
song.save()
run(host='localhost', port=8080, reloader=True, debug=True)