Introduce %c (release disambiguation comment) template variable

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
JoeLametta
2021-05-15 16:37:16 +00:00
parent bff5c91fa3
commit e6ad23f119
5 changed files with 10 additions and 2 deletions

View File

@@ -96,6 +96,7 @@ Template schemes
| - %S: release sort name
| - %B: release barcode
| - %C: release catalog number
| - %c: release disambiguation comment
| - %d: release title (with disambiguation)
| - %D: disc title (without disambiguation)
| - %I: MusicBrainz Disc ID

View File

@@ -56,6 +56,7 @@ disc and track template are:
- %S: release sort name
- %B: release barcode
- %C: release catalog number
- %c: release disambiguation comment
- %d: release title (with disambiguation)
- %D: disc title (without disambiguation)
- %I: MusicBrainz Disc ID

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'%[^ABCDIRSXdrxy]', template)
matches = re.findall(r'%[^ABCDIRSXcdrxy]', template)
elif kind == 'track':
matches = re.findall(r'%[^ABCDIRSXadnrstxy]', template)
matches = re.findall(r'%[^ABCDIRSXacdnrstxy]', template)
if '%' in template and matches:
raise ValueError(kind + ' template string contains invalid '
'variable(s): {}'.format(', '.join(matches)))

View File

@@ -70,6 +70,8 @@ class DiscMetadata:
:vartype title: str or None
:cvar releaseTitle: title of the release (with disambiguation)
:vartype releasetitle: str or None
:cvar releaseDisambCmt: release disambiguation comment
:vartype releaseDisambCmt: str or None
:vartype tracks: list of :any:`TrackMetadata`
:cvar countries: MusicBrainz release countries
:vartype countries: list or None
@@ -87,6 +89,7 @@ class DiscMetadata:
release = None
releaseTitle = None
releaseDisambCmt = None
releaseType = None
mbid = None
@@ -290,6 +293,7 @@ def _getMetadata(release, discid=None, country=None):
discMD.title = release['title']
discMD.releaseTitle = releaseTitle = discMD.title
if 'disambiguation' in release:
discMD.releaseDisambCmt = release['disambiguation']
releaseTitle += " (%s)" % release['disambiguation']
count = len(release['medium-list'])
if count > 1:

View File

@@ -178,6 +178,7 @@ class Program:
* ``%S``: release artist sort name
* ``%B``: release barcode
* ``%C``: release catalog number
* ``%c``: release disambiguation comment
* ``%d``: release title (with disambiguation)
* ``%D``: disc title (without disambiguation)
* ``%I``: MusicBrainz Disc ID
@@ -216,6 +217,7 @@ class Program:
v['D'] = metadata.title
v['B'] = metadata.barcode
v['C'] = metadata.catalogNumber
v['c'] = metadata.releaseDisambCmt
if metadata.releaseType:
v['R'] = metadata.releaseType
v['r'] = metadata.releaseType.lower()