Introduce %I (MusicBrainz Disc ID) template variable

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
JoeLametta
2021-05-15 14:17:16 +00:00
parent a97820b578
commit bff5c91fa3
4 changed files with 6 additions and 3 deletions

View File

@@ -98,6 +98,7 @@ Template schemes
| - %C: release catalog number
| - %d: release title (with disambiguation)
| - %D: disc title (without disambiguation)
| - %I: MusicBrainz Disc ID
| - %y: release year
| - %r: release type, lowercase
| - %R: release type, normal case

View File

@@ -58,6 +58,7 @@ disc and track template are:
- %C: release catalog number
- %d: release title (with disambiguation)
- %D: disc title (without disambiguation)
- %I: MusicBrainz Disc ID
- %y: release year
- %r: release type, lowercase
- %R: release type, normal case

View File

@@ -277,9 +277,9 @@ def getRelativePath(targetPath, collectionPath):
def validate_template(template, kind):
"""Raise exception if disc/track template includes invalid variables."""
if kind == 'disc':
matches = re.findall(r'%[^ABCDRSXdrxy]', template)
matches = re.findall(r'%[^ABCDIRSXdrxy]', template)
elif kind == 'track':
matches = re.findall(r'%[^ABCDRSXadnrstxy]', template)
matches = re.findall(r'%[^ABCDIRSXadnrstxy]', template)
if '%' in template and matches:
raise ValueError(kind + ' template string contains invalid '
'variable(s): {}'.format(', '.join(matches)))

View File

@@ -180,6 +180,7 @@ class Program:
* ``%C``: release catalog number
* ``%d``: release title (with disambiguation)
* ``%D``: disc title (without disambiguation)
* ``%I``: MusicBrainz Disc ID
* ``%y``: release year
* ``%r``: release type, lowercase
* ``%R``: release type, normal case
@@ -190,7 +191,7 @@ class Program:
assert isinstance(template, str), "%r is not str" % template
v = {}
v['A'] = 'Unknown Artist'
v['d'] = v['D'] = mbdiscid # fallback for title
v['I'] = v['d'] = v['D'] = mbdiscid # fallback for title
v['r'] = 'unknown'
v['R'] = 'Unknown'
v['B'] = '' # barcode