def __init__(self, server="localhost",port=6600): self.mpc = MPDClient() self.server = server self.port = port BarItem.__init__(self, "MPD") self.output['name'] = "NowPlaying" self.update()
def __init__(self, **config): Notifier.__init__(self, **config) self.add_defaults(Client.defaults) self.client = MPDClient() self.client.host = self.host self.client.port = self.port
def populateList(self): self.client = MPDClient() self.client.connect('localhost', 6600) self.playlistinfo = self.client.playlistinfo() self.client.disconnect() self.playlist = [] #backgroundColor = QColor('#383C4A') #foregroundColor = QColor('#C1C1C1') for i in self.playlistinfo: row = '' if 'album' in i: row = row + i['album'] + ' - ' if 'title' in i: if isinstance(i['title'], str): row = row + i['title'] else: row = row + i['title'][0] if 'artist' in i: row = row + ' - ' + i['artist'] self.playlist.append(row) #newRow = QListWidgetItem(row) #newRow.setBackground(backgroundColor) #newRow.setForeground(foregroundColor) #self.lw.addItem(newRow) self.visibleLw.addItems(self.playlist) self.visibleLw.setCurrentRow(0)
def get_client(): client = MPDClient() client.connect(app.config['MPD_ADDRESS'], app.config['MPD_PORT']) return client
def __init__(self, fp): self.__fp = fp self.__client = MPDClient() self.__lock = threading.Lock() self.__idle_client = MPDClient()
def getOpenClient(): client = MPDClient() client.connect('localhost', 6600) return client
def __init__(self): self.client = MPDClient() self.port = 6600 self._connect()
#!/usr/bin/env python2 from musicpd import MPDClient import os fifo_name = os.getenv("XDG_RUNTIME_DIR", "/tmp") + "/powerstatus10k/fifos/mpd" mpd_host = os.getenv("MPD_HOST", "127.0.0.1") mpd_port = os.getenv("MPD_PORT", "6600") client = MPDClient() client.connect(mpd_host, mpd_port) while True: client.send_idle() client.fetch_idle() status = client.status() state = status["state"] if "state" in status else "stop" song = client.currentsong() artist = song["artist"] if "artist" in song else "Unknown Artist" title = song["title"] if "title" in song else "Unknown Title" # Do this here to avoid problems on a deleted FIFO during runtime. if not os.path.exists(fifo_name): os.mkfifo(fifo_name) with open(fifo_name, "w") as fifo: fifo.write(f"{state}:{artist}:{title}")