From f0619744ed3198ac796a12c0acc8da874bcb5d48 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sat, 30 Oct 2010 21:26:53 +0200 Subject: [PATCH] Fix tracks to direcotory dir handling --- mopidy/frontends/mpd/translator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mopidy/frontends/mpd/translator.py b/mopidy/frontends/mpd/translator.py index 69be17ed..e234046b 100644 --- a/mopidy/frontends/mpd/translator.py +++ b/mopidy/frontends/mpd/translator.py @@ -125,10 +125,15 @@ def _add_to_tag_cache(result, folders, files): def tracks_to_directory_tree(tracks): directories = ({}, []) for track in tracks: - uri = track.uri path = '' current = directories - for part in split_path(os.path.dirname(uri_to_path(uri))): + + local_folder = os.path.expanduser(settings.LOCAL_MUSIC_FOLDER) + track_path = uri_to_path(track.uri) + track_path = re.sub('^' + re.escape(local_folder), '', track_path) + track_dir = os.path.dirname(track_path) + + for part in split_path(track_dir): path = os.path.join(path, part) if path not in current[0]: current[0][path] = ({}, [])