pep8 compliance.
This commit is contained in:
parent
9769d1b7d0
commit
b179d29abf
@ -13,10 +13,13 @@ class MPD(IntervalModule):
|
|||||||
.. rubric:: Available formatters (uses :ref:`formatp`)
|
.. rubric:: Available formatters (uses :ref:`formatp`)
|
||||||
|
|
||||||
* `{title}` — (the title of the current song)
|
* `{title}` — (the title of the current song)
|
||||||
* `{album}` — (the album of the current song, can be an empty string (e.g. for online streams))
|
* `{album}` — (the album of the current song, can be an empty string \
|
||||||
|
(e.g. for online streams))
|
||||||
* `{artist}` — (can be empty, too)
|
* `{artist}` — (can be empty, too)
|
||||||
* `{filename}` — (file name with out extension and path; empty unless title is empty)
|
* `{filename}` — (file name with out extension and path; empty unless \
|
||||||
* `{song_elapsed}` — (Position in the currently playing song, uses :ref:`TimeWrapper`, default is `%m:%S`)
|
title is empty)
|
||||||
|
* `{song_elapsed}` — (Position in the currently playing song, uses \
|
||||||
|
:ref:`TimeWrapper`, default is `%m:%S`)
|
||||||
* `{song_length}` — (Length of the current song, same as song_elapsed)
|
* `{song_length}` — (Length of the current song, same as song_elapsed)
|
||||||
* `{pos}` — (Position of current song in playlist, one-based)
|
* `{pos}` — (Position of current song in playlist, one-based)
|
||||||
* `{len}` — (Songs in playlist)
|
* `{len}` — (Songs in playlist)
|
||||||
@ -31,15 +34,23 @@ class MPD(IntervalModule):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
("host"),
|
("host"),
|
||||||
("port", "MPD port. If set to 0, host will we interpreted as a Unix socket."),
|
("port", "MPD port. If set to 0, host will we interpreted as a Unix \
|
||||||
|
socket."),
|
||||||
("format", "formatp string"),
|
("format", "formatp string"),
|
||||||
("status", "Dictionary mapping pause, play and stop to output"),
|
("status", "Dictionary mapping pause, play and stop to output"),
|
||||||
("color", "The color of the text"),
|
("color", "The color of the text"),
|
||||||
("max_field_len", "Defines max length for in truncate_fields defined fields, if truncated, ellipsis are appended as indicator. It's applied *before* max_len. Value of 0 disables this."),
|
("max_field_len", "Defines max length for in truncate_fields defined \
|
||||||
("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."),
|
fields, if truncated, ellipsis are appended as indicator. It's applied \
|
||||||
("truncate_fields", "fields that will be truncated if exceeding max_field_len or max_len."),
|
*before* max_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."),
|
||||||
("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.)"),
|
("password", "A password for access to MPD. (This is sent in \
|
||||||
|
cleartext to the server.)"),
|
||||||
)
|
)
|
||||||
|
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
@ -74,7 +85,8 @@ class MPD(IntervalModule):
|
|||||||
sock = self.s
|
sock = self.s
|
||||||
sock.recv(8192)
|
sock.recv(8192)
|
||||||
if self.password is not None:
|
if self.password is not None:
|
||||||
sock.send('password "{}"\n'.format(self.password).encode("utf-8"))
|
sock.send('password "{}"\n'.format(self.password).
|
||||||
|
encode("utf-8"))
|
||||||
sock.recv(8192)
|
sock.recv(8192)
|
||||||
sock.send((command + "\n").encode("utf-8"))
|
sock.send((command + "\n").encode("utf-8"))
|
||||||
try:
|
try:
|
||||||
@ -144,8 +156,9 @@ class MPD(IntervalModule):
|
|||||||
|
|
||||||
def switch_playpause(self):
|
def switch_playpause(self):
|
||||||
try:
|
try:
|
||||||
self._mpd_command(self.s, "%s" %
|
self._mpd_command(self.s, "play"
|
||||||
("play" if self._mpd_command(self.s, "status")["state"] in ["pause", "stop"] else "pause"))
|
if self._mpd_command(self.s, "status")["state"]
|
||||||
|
in ["pause", "stop"] else "pause")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user