From 360be6b81644c2d334af4f19fee8a5297abbf9bb Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 11 Nov 2018 12:14:58 +0100 Subject: [PATCH] Automatically strip beet root from files This assumes that your mpd and beet roots are the same directory --- mv3u.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mv3u.py b/mv3u.py index 23d15e4..1bbd9a6 100644 --- a/mv3u.py +++ b/mv3u.py @@ -1,7 +1,9 @@ from beets.plugins import BeetsPlugin +from beets import config import os -rename_cache = os.path.expanduser('~/.cache/beets_mv3u_renames') +rename_cache = os.path.expanduser('~/beets_mv3u_renames') +music_root = config['directory'].get() class MV3U(BeetsPlugin): def __init__(self): @@ -38,8 +40,8 @@ class MV3U(BeetsPlugin): def add_rename(self, item): - src = item.path.decode() - dst = item.destination().decode() + src = item.path.decode().replace(music_root, '') + dst = item.destination().decode().replace(music_root, '') with open(rename_cache, 'a') as cache: cache.write(f'{src}\t\t{dst}\n')