Merge pull request #1439 from ZyX-I/fix-1437
Fix support for passworded connections in mpd+python-mpd* player seg
This commit is contained in:
commit
f91fb141de
|
@ -167,14 +167,16 @@ Requires cmus-remote command be acessible from $PATH.
|
||||||
|
|
||||||
|
|
||||||
class MpdPlayerSegment(PlayerSegment):
|
class MpdPlayerSegment(PlayerSegment):
|
||||||
def get_player_status(self, pl, host='localhost', port=6600):
|
def get_player_status(self, pl, host='localhost', password=None, port=6600):
|
||||||
try:
|
try:
|
||||||
import mpd
|
import mpd
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
if password:
|
||||||
|
host = password + '@' + host
|
||||||
now_playing = run_cmd(pl, [
|
now_playing = run_cmd(pl, [
|
||||||
'mpc', 'current',
|
'mpc', 'current',
|
||||||
'-f', '%album%\n%artist%\n%title%\n%time%',
|
'-f', '%album%\n%artist%\n%title%\n%time%',
|
||||||
'-h', str(host),
|
'-h', host,
|
||||||
'-p', str(port)
|
'-p', str(port)
|
||||||
], strip=False)
|
], strip=False)
|
||||||
if not now_playing:
|
if not now_playing:
|
||||||
|
@ -189,6 +191,8 @@ class MpdPlayerSegment(PlayerSegment):
|
||||||
else:
|
else:
|
||||||
client = mpd.MPDClient()
|
client = mpd.MPDClient()
|
||||||
client.connect(host, port)
|
client.connect(host, port)
|
||||||
|
if password:
|
||||||
|
client.password(password)
|
||||||
now_playing = client.currentsong()
|
now_playing = client.currentsong()
|
||||||
if not now_playing:
|
if not now_playing:
|
||||||
return
|
return
|
||||||
|
@ -220,6 +224,8 @@ package) or alternatively the ``mpc`` command to be acessible from $PATH.
|
||||||
{0}
|
{0}
|
||||||
:param str host:
|
:param str host:
|
||||||
Host on which mpd runs.
|
Host on which mpd runs.
|
||||||
|
:param str password:
|
||||||
|
Password used for connecting to daemon.
|
||||||
:param int port:
|
:param int port:
|
||||||
Port which should be connected to.
|
Port which should be connected to.
|
||||||
''').format(_common_args.format('mpd')))
|
''').format(_common_args.format('mpd')))
|
||||||
|
|
Loading…
Reference in New Issue