Merge pull request #504 from somospocos/mpd-module-improvement

Mpd module improvement
This commit is contained in:
tobi-wan-kenobi 2019-12-27 13:32:00 +01:00 committed by GitHub
commit fac363c9e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,13 +7,42 @@ Requires the following executable:
* mpc * mpc
Parameters: Parameters:
* mpd.format: Format string for the song information. Tag values can be put in curly brackets (i.e. {artist}) * mpd.format: Format string for the song information.
Supported tags (see `man mpc` for additional information)
* {name}
* {artist}
* {album}
* {albumartist}
* {comment}
* {composer}
* {date}
* {originaldate}
* {disc}
* {genre}
* {performer}
* {title}
* {track}
* {time}
* {file}
* {id}
* {prio}
* {mtime}
* {mdate}
Additional tags:
* {position} - position of currently playing song
not to be confused with %position% mpc tag
* {duration} - duration of currently playing song
* {file1} - song file name without path prefix
if {file} = '/foo/bar.baz', then {file1} = 'bar.baz'
* {file2} - song file name without path prefix and extension suffix
if {file} = '/foo/bar.baz', then {file2} = 'bar'
* mpd.host: MPD host to connect to. (mpc behaviour by default) * mpd.host: MPD host to connect to. (mpc behaviour by default)
""" """
from collections import defaultdict from collections import defaultdict
import string import string
import os
import bumblebee.util import bumblebee.util
import bumblebee.input import bumblebee.input
@ -132,5 +161,10 @@ class Module(bumblebee.engine.Module):
if line.startswith("tag"): if line.startswith("tag"):
key, value = line.split(" ", 2)[1:] key, value = line.split(" ", 2)[1:]
self._tags.update({key: value}) self._tags.update({key: value})
if key == "file":
self._tags.update({"file1": os.path.basename(value)})
self._tags.update(
{"file2":
os.path.splitext(os.path.basename(value))[0]})
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4