mirror of
https://github.com/beetbox/beets.git
synced 2026-02-26 09:11:32 +01:00
path formats can now be specified by album type
This commit is contained in:
parent
2360c5744a
commit
096816cba7
2 changed files with 44 additions and 24 deletions
|
|
@ -38,29 +38,29 @@ ITEM_FIELDS = [
|
|||
('path', 'blob', False, False),
|
||||
('album_id', 'int', False, False),
|
||||
|
||||
('title', 'text', True, True),
|
||||
('artist', 'text', True, True),
|
||||
('album', 'text', True, True),
|
||||
('albumartist', 'text', True, True),
|
||||
('genre', 'text', True, True),
|
||||
('composer', 'text', True, True),
|
||||
('grouping', 'text', True, True),
|
||||
('year', 'int', True, True),
|
||||
('month', 'int', True, True),
|
||||
('day', 'int', True, True),
|
||||
('track', 'int', True, True),
|
||||
('tracktotal', 'int', True, True),
|
||||
('disc', 'int', True, True),
|
||||
('disctotal', 'int', True, True),
|
||||
('lyrics', 'text', True, True),
|
||||
('comments', 'text', True, True),
|
||||
('bpm', 'int', True, True),
|
||||
('comp', 'bool', True, True),
|
||||
('mb_trackid', 'text', True, True),
|
||||
('mb_albumid', 'text', True, True),
|
||||
('mb_artistid', 'text', True, True),
|
||||
('mb_albumartistid', 'text', True, True),
|
||||
('albumtype', 'text', True, True),
|
||||
('title', 'text', True, True),
|
||||
('artist', 'text', True, True),
|
||||
('album', 'text', True, True),
|
||||
('albumartist', 'text', True, True),
|
||||
('genre', 'text', True, True),
|
||||
('composer', 'text', True, True),
|
||||
('grouping', 'text', True, True),
|
||||
('year', 'int', True, True),
|
||||
('month', 'int', True, True),
|
||||
('day', 'int', True, True),
|
||||
('track', 'int', True, True),
|
||||
('tracktotal', 'int', True, True),
|
||||
('disc', 'int', True, True),
|
||||
('disctotal', 'int', True, True),
|
||||
('lyrics', 'text', True, True),
|
||||
('comments', 'text', True, True),
|
||||
('bpm', 'int', True, True),
|
||||
('comp', 'bool', True, True),
|
||||
('mb_trackid', 'text', True, True),
|
||||
('mb_albumid', 'text', True, True),
|
||||
('mb_artistid', 'text', True, True),
|
||||
('mb_albumartistid', 'text', True, True),
|
||||
('albumtype', 'text', True, True),
|
||||
|
||||
('length', 'real', False, True),
|
||||
('bitrate', 'int', False, True),
|
||||
|
|
@ -878,7 +878,9 @@ class Library(BaseLibrary):
|
|||
pathmod = pathmod or os.path
|
||||
|
||||
# Use a path format based on the album type, if available.
|
||||
if item.comp and 'comp' in self.path_formats:
|
||||
if 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']
|
||||
else:
|
||||
path_format = self.path_formats['default']
|
||||
|
|
|
|||
|
|
@ -288,6 +288,24 @@ class DestinationTest(unittest.TestCase):
|
|||
'comp': 'three'}
|
||||
self.assertEqual(self.lib.destination(self.i), np('one/three'))
|
||||
|
||||
def test_albumtype_path(self):
|
||||
self.i.comp = True
|
||||
self.i.albumtype = 'sometype'
|
||||
self.lib.directory = 'one'
|
||||
self.lib.path_formats = {'default': 'two',
|
||||
'comp': 'three',
|
||||
'sometype': 'four'}
|
||||
self.assertEqual(self.lib.destination(self.i), np('one/four'))
|
||||
|
||||
def test_albumtype_path_fallback_to_comp(self):
|
||||
self.i.comp = True
|
||||
self.i.albumtype = 'sometype'
|
||||
self.lib.directory = 'one'
|
||||
self.lib.path_formats = {'default': 'two',
|
||||
'comp': 'three',
|
||||
'anothertype': 'four'}
|
||||
self.assertEqual(self.lib.destination(self.i), np('one/three'))
|
||||
|
||||
def test_syspath_windows_format(self):
|
||||
path = ntpath.join('a', 'b', 'c')
|
||||
outpath = beets.library._syspath(path, ntpath)
|
||||
|
|
|
|||
Loading…
Reference in a new issue