mirror of
https://github.com/beetbox/beets.git
synced 2026-01-06 07:53:40 +01:00
Add strip_path to mpdstats
This commit is contained in:
parent
04ea754d00
commit
414b682123
2 changed files with 12 additions and 1 deletions
|
|
@ -53,6 +53,9 @@ class MPDClientWrapper(object):
|
|||
self.music_directory = (
|
||||
mpd_config['music_directory'].as_str())
|
||||
|
||||
self.strip_path = (
|
||||
mpd_config['strip_path'].as_str())
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
# On Python 2, use_unicode will enable the utf-8 mode for
|
||||
# python-mpd2
|
||||
|
|
@ -118,12 +121,16 @@ class MPDClientWrapper(object):
|
|||
"""Return the path to the currently playing song, along with its
|
||||
songid. Prefixes paths with the music_directory, to get the absolute
|
||||
path.
|
||||
In some cases, we need to remove the local path from MPD server,
|
||||
we replace 'strip_path' with ''.
|
||||
`strip_path` defaults to ''.
|
||||
"""
|
||||
result = None
|
||||
entry = self.get('currentsong')
|
||||
if 'file' in entry:
|
||||
if not is_url(entry['file']):
|
||||
result = os.path.join(self.music_directory, entry['file'])
|
||||
file = entry['file'].replace(self.strip_path, '')
|
||||
result = os.path.join(self.music_directory, file)
|
||||
else:
|
||||
result = entry['file']
|
||||
return result, entry.get('id')
|
||||
|
|
@ -334,6 +341,7 @@ class MPDStatsPlugin(plugins.BeetsPlugin):
|
|||
super(MPDStatsPlugin, self).__init__()
|
||||
mpd_config.add({
|
||||
'music_directory': config['directory'].as_filename(),
|
||||
'strip_path': u'',
|
||||
'rating': True,
|
||||
'rating_mix': 0.75,
|
||||
'host': os.environ.get('MPD_HOST', u'localhost'),
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ configuration file. The available options are:
|
|||
- **music_directory**: If your MPD library is at a different location from the
|
||||
beets library (e.g., because one is mounted on a NFS share), specify the path
|
||||
here.
|
||||
- **strip_path**: If your MPD library contains local path, specify the part to remove
|
||||
here. Combining this with **music_directory** you can mangle MPD path to match the
|
||||
**beets library** one.
|
||||
Default: The beets library directory.
|
||||
- **rating**: Enable rating updates.
|
||||
Default: ``yes``.
|
||||
|
|
|
|||
Loading…
Reference in a new issue