singleton path format

This commit is contained in:
Adrian Sampson 2011-04-09 14:50:48 -07:00
parent 633e878ee8
commit b28ef722a5
4 changed files with 32 additions and 1 deletions

2
NEWS
View file

@ -1,5 +1,7 @@
1.0b8
-----
* Better support for singleton (non-album) tracks. The "singleton" path
format can be used to customize where these tracks are stored.
* The "distance" number, which quantifies how different an album's
current and proposed metadata are, is now displayed as "similarity"
instead. This should be less noisy and confusing; you'll now see

View file

@ -900,7 +900,13 @@ class Library(BaseLibrary):
pathmod = pathmod or os.path
# Use a path format based on the album type, if available.
if item.albumtype and item.albumtype in self.path_formats:
if not item.album_id:
# Singleton track. Never use the "album" formats.
if 'singleton' in self.path_formats:
path_format = self.path_formats['singleton']
else:
path_format = self.path_formats['default']
elif item.albumtype and item.albumtype in self.path_formats:
path_format = self.path_formats[item.albumtype]
elif item.comp and 'comp' in self.path_formats:
path_format = self.path_formats['comp']

View file

@ -38,6 +38,7 @@ DEFAULT_DIRECTORY = '~/Music'
DEFAULT_PATH_FORMATS = {
'default': '$albumartist/$album/$track $title',
'comp': 'Compilations/$album/$track $title',
'singleton': 'Non-Album/$artist/$title',
}
DEFAULT_ART_FILENAME = 'cover'

View file

@ -248,13 +248,33 @@ class DestinationTest(unittest.TestCase):
def test_default_path_for_non_compilations(self):
self.i.comp = False
self.lib.add_album([self.i])
self.lib.directory = 'one'
self.lib.path_formats = {'default': 'two',
'comp': 'three'}
self.assertEqual(self.lib.destination(self.i), np('one/two'))
def test_singleton_path(self):
i = item()
self.lib.directory = 'one'
self.lib.path_formats = {'default': 'two',
'comp': 'three',
'singleton': 'four'}
self.assertEqual(self.lib.destination(i), np('one/four'))
def test_singleton_track_falls_back_to_default(self):
i = item()
i.comp = True
i.albumtype = 'atype'
self.lib.directory = 'one'
self.lib.path_formats = {'default': 'two',
'comp': 'three',
'atype': 'four'}
self.assertEqual(self.lib.destination(i), np('one/two'))
def test_comp_path(self):
self.i.comp = True
self.lib.add_album([self.i])
self.lib.directory = 'one'
self.lib.path_formats = {'default': 'two',
'comp': 'three'}
@ -262,6 +282,7 @@ class DestinationTest(unittest.TestCase):
def test_albumtype_path(self):
self.i.comp = True
self.lib.add_album([self.i])
self.i.albumtype = 'sometype'
self.lib.directory = 'one'
self.lib.path_formats = {'default': 'two',
@ -271,6 +292,7 @@ class DestinationTest(unittest.TestCase):
def test_albumtype_path_fallback_to_comp(self):
self.i.comp = True
self.lib.add_album([self.i])
self.i.albumtype = 'sometype'
self.lib.directory = 'one'
self.lib.path_formats = {'default': 'two',