From e9eac16284153b44eed556dba9753f5789ddf99a Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 12 Dec 2012 15:07:00 +0100 Subject: [PATCH] mpd: Use relative urlencoded paths in tag cache This partly reverts "beac2e8 mpd: Use file:// URIs in tag_cache" by removing the "file://" URI scheme and the music dir base path from the "file:" fields in the tag cache. The advantage is that the tag cache becomes independent of the music dir location and the tag cache loader can be made compatible with both old and new tag caches. --- mopidy/frontends/mpd/translator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mopidy/frontends/mpd/translator.py b/mopidy/frontends/mpd/translator.py index 1d7b52aa..b2113dda 100644 --- a/mopidy/frontends/mpd/translator.py +++ b/mopidy/frontends/mpd/translator.py @@ -169,17 +169,25 @@ def _add_to_tag_cache(result, folders, files): result.append(('end', name)) result.append(('songList begin',)) + for track in files: track_result = dict(track_to_mpd_format(track)) + path = uri_to_path(track_result['file']) try: text_path = path.decode('utf-8') except UnicodeDecodeError: text_path = urllib.pathname2url(path).decode('utf-8') + relative_path = os.path.relpath(path, base_path) + relative_uri = urllib.pathname2url(relative_path) + + track_result['file'] = relative_uri track_result['mtime'] = get_mtime(path) track_result['key'] = os.path.basename(text_path) track_result = order_mpd_track_info(track_result.items()) + result.extend(track_result) + result.append(('songList end',))