commit
3800db2175
@ -39,10 +39,12 @@ class MPD(IntervalModule):
|
|||||||
("max_len", "Defines max length for the hole string, if exceeding fields specefied in truncate_fields are truncated equaly. If truncated, ellipsis are appended as indicator. It's applied *after* max_field_len. Value of 0 disables this."),
|
("max_len", "Defines max length for the hole string, if exceeding fields specefied in truncate_fields are truncated equaly. If truncated, ellipsis are appended as indicator. It's applied *after* max_field_len. Value of 0 disables this."),
|
||||||
("truncate_fields", "fields that will be truncated if exceeding max_field_len or max_len."),
|
("truncate_fields", "fields that will be truncated if exceeding max_field_len or max_len."),
|
||||||
("hide_inactive", "Hides status information when MPD is not running"),
|
("hide_inactive", "Hides status information when MPD is not running"),
|
||||||
|
("password", "A password for access to MPD. (This is sent in cleartext to the server.)"),
|
||||||
)
|
)
|
||||||
|
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
port = 6600
|
port = 6600
|
||||||
|
password = None
|
||||||
s = None
|
s = None
|
||||||
format = "{title} {status}"
|
format = "{title} {status}"
|
||||||
status = {
|
status = {
|
||||||
@ -71,6 +73,9 @@ class MPD(IntervalModule):
|
|||||||
self.s.connect(self.host)
|
self.s.connect(self.host)
|
||||||
sock = self.s
|
sock = self.s
|
||||||
sock.recv(8192)
|
sock.recv(8192)
|
||||||
|
if self.password is not None:
|
||||||
|
sock.send('password "{}"\n'.format(self.password).encode("utf-8"))
|
||||||
|
sock.recv(8192)
|
||||||
sock.send((command + "\n").encode("utf-8"))
|
sock.send((command + "\n").encode("utf-8"))
|
||||||
try:
|
try:
|
||||||
reply = sock.recv(16384).decode("utf-8")
|
reply = sock.recv(16384).decode("utf-8")
|
||||||
|
Loading…
Reference in New Issue
Block a user