Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
Arquivo: mpc.py Projeto: dyuri/rcfiles
    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
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
def get_client():
    client = MPDClient()
    client.connect(app.config['MPD_ADDRESS'], app.config['MPD_PORT'])
    return client
Exemplo n.º 5
0
 def __init__(self, fp):
     self.__fp = fp
     self.__client = MPDClient()
     self.__lock = threading.Lock()
     self.__idle_client = MPDClient()
Exemplo n.º 6
0
 def getOpenClient():
     client = MPDClient()
     client.connect('localhost', 6600)
     return client
Exemplo n.º 7
0
 def __init__(self):
     self.client = MPDClient()
     self.port = 6600
     self._connect()
Exemplo n.º 8
0
#!/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}")