summaryrefslogtreecommitdiff
path: root/plugins/mpd_client.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-08-15 13:13:17 +0200
committermathieui <mathieui@mathieui.net>2018-08-15 13:13:17 +0200
commit6e13b8b73572f9c0ac9b5c683b98a475afbeab38 (patch)
tree7dae86588339a8cf144b2d98c9280f28646341a9 /plugins/mpd_client.py
parentd1b624753bb5371cf287cc9d86bb685593a99315 (diff)
downloadpoezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.tar.gz
poezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.tar.bz2
poezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.tar.xz
poezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.zip
yapf -rip on plugins
Diffstat (limited to 'plugins/mpd_client.py')
-rw-r--r--plugins/mpd_client.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/mpd_client.py b/plugins/mpd_client.py
index 6115c0da..c5cd88b8 100644
--- a/plugins/mpd_client.py
+++ b/plugins/mpd_client.py
@@ -54,34 +54,44 @@ from os.path import basename as base
from poezio import tabs
import mpd
+
class Plugin(BasePlugin):
def init(self):
for _class in (tabs.ConversationTab, tabs.MucTab, tabs.PrivateTab):
- self.api.add_tab_command(_class, 'mpd', self.command_mpd,
- usage='[full]',
- help='Sends a message showing the current song of an MPD instance. If full is provided, the message is more verbose.',
- short='Send the MPD status',
- completion=self.completion_mpd)
+ self.api.add_tab_command(
+ _class,
+ 'mpd',
+ self.command_mpd,
+ usage='[full]',
+ help=
+ 'Sends a message showing the current song of an MPD instance. If full is provided, the message is more verbose.',
+ short='Send the MPD status',
+ completion=self.completion_mpd)
def command_mpd(self, args):
args = shell_split(args)
c = mpd.MPDClient()
- c.connect(host=self.config.get('host', 'localhost'), port=self.config.get('port', '6600'))
+ c.connect(
+ host=self.config.get('host', 'localhost'),
+ port=self.config.get('port', '6600'))
password = self.config.get('password', '')
if password:
c.password(password)
current = c.currentsong()
artist = current.get('artist', 'Unknown artist')
album = current.get('album', 'Unknown album')
- title = current.get('title', base(current.get('file', 'Unknown title')))
+ title = current.get('title', base(
+ current.get('file', 'Unknown title')))
s = '%s - %s (%s)' % (artist, title, album)
if 'full' in args:
if 'elapsed' in current and 'time' in current:
current_time = float(c.status()['elapsed'])
percents = int(current_time / float(current['time']) * 10)
- s += ' \x192}[\x191}' + '-'*(percents-1) + '\x193}+' + '\x191}' + '-' * (10-percents-1) + '\x192}]\x19o'
- if not self.api.send_message('%s' % (s,)):
+ s += ' \x192}[\x191}' + '-' * (
+ percents - 1) + '\x193}+' + '\x191}' + '-' * (
+ 10 - percents - 1) + '\x192}]\x19o'
+ if not self.api.send_message('%s' % (s, )):
self.api.information('Cannot send result (%s)' % s, 'Error')
def completion_mpd(self, the_input):