mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 19:12:40 +01:00
Fill default config for albumtypes plugin
This commit is contained in:
parent
c5764df989
commit
d40f0c8860
3 changed files with 37 additions and 18 deletions
|
|
@ -31,9 +31,16 @@ class AlbumTypesPlugin(BeetsPlugin):
|
|||
super(AlbumTypesPlugin, self).__init__()
|
||||
self.album_template_fields['atypes'] = self._atypes
|
||||
self.config.add({
|
||||
'types': [],
|
||||
'ignore_va': [],
|
||||
'brackets': '[]'
|
||||
'types': [
|
||||
('ep', 'EP'),
|
||||
('single', 'Single'),
|
||||
('soundtrack', 'OST'),
|
||||
('live', 'Live'),
|
||||
('compilation', 'Anthology'),
|
||||
('remix', 'Remix')
|
||||
],
|
||||
'ignore_va': ['compilation'],
|
||||
'bracket': '[]'
|
||||
})
|
||||
|
||||
def _atypes(self, item: Album):
|
||||
|
|
|
|||
|
|
@ -20,17 +20,12 @@ file. The available options are:
|
|||
- **types**: An ordered list of album type to format mappings. The order of the
|
||||
mappings determines their order in the output. If a mapping is missing or
|
||||
blank, it will not be in the output.
|
||||
Default: ``[]``.
|
||||
- **ignore_va**: A list of types that should not be output for Various Artists
|
||||
albums. Useful for not adding redundant information - various artist albums
|
||||
are often compilations.
|
||||
Default: ``[]``.
|
||||
- **bracket**: Defines the brackets to enclose each album type in the output.
|
||||
Default: ``'[]'``
|
||||
|
||||
Examples
|
||||
--------
|
||||
Example config::
|
||||
The default configuration looks like this::
|
||||
|
||||
albumtypes:
|
||||
types:
|
||||
|
|
@ -41,16 +36,22 @@ Example config::
|
|||
- compilation: 'Anthology'
|
||||
- remix: 'Remix'
|
||||
ignore_va: compilation
|
||||
bracket: '()'
|
||||
bracket: '[]'
|
||||
|
||||
Examples
|
||||
--------
|
||||
With path formats configured like::
|
||||
|
||||
paths:
|
||||
default: $albumartist/($year)$atypes $album/...
|
||||
albumtype:soundtrack Various Artists/$album ($year)$atypes)/...
|
||||
comp: Various Artists/$album ($year)$atypes/...
|
||||
default: $albumartist/[$year]$atypes $album/...
|
||||
albumtype:soundtrack Various Artists/$album [$year]$atypes)/...
|
||||
comp: Various Artists/$album [$year]$atypes/...
|
||||
|
||||
This configuration generates paths that look like this, for example::
|
||||
|
||||
Aphex Twin/(1993)(EP)(Remix) On Remixes
|
||||
Pink Flow/(1995)(Live) p·u·l·s·e
|
||||
Various Artists/20th Century Lullabies (1999)
|
||||
Various Artists/Ocean's Eleven (2001)(OST)
|
||||
The default plugin configuration generates paths that look like this, for example::
|
||||
|
||||
Aphex Twin/[1993][EP][Remix] On Remixes
|
||||
Pink Flow/[1995][Live] p·u·l·s·e
|
||||
Various Artists/20th Century Lullabies [1999]
|
||||
Various Artists/Ocean's Eleven [2001][OST]
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,17 @@ class AlbumTypesPluginTest(unittest.TestCase, TestHelper):
|
|||
result = subject._atypes(album)
|
||||
self.assertEqual('(OST)', result)
|
||||
|
||||
def test_respects_defaults(self):
|
||||
"""Tests if the plugin uses the default values if config not given."""
|
||||
album = self._create_album(
|
||||
album_types=['ep', 'single', 'soundtrack', 'live', 'compilation',
|
||||
'remix'],
|
||||
artist_id=VARIOUS_ARTISTS_ID
|
||||
)
|
||||
subject = AlbumTypesPlugin()
|
||||
result = subject._atypes(album)
|
||||
self.assertEqual('[EP][Single][OST][Live][Remix]', result)
|
||||
|
||||
def _set_config(self, types: [(str, str)], ignore_va: [str], bracket: str):
|
||||
self.config['albumtypes']['types'] = types
|
||||
self.config['albumtypes']['ignore_va'] = ignore_va
|
||||
|
|
|
|||
Loading…
Reference in a new issue