From bff5c91fa3f63abea55fab900e5ca9ba97d38225 Mon Sep 17 00:00:00 2001 From: JoeLametta Date: Sat, 15 May 2021 14:17:16 +0000 Subject: [PATCH] Introduce %I (MusicBrainz Disc ID) template variable Signed-off-by: JoeLametta --- man/whipper-cd-rip.rst | 1 + whipper/command/cd.py | 1 + whipper/common/common.py | 4 ++-- whipper/common/program.py | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/man/whipper-cd-rip.rst b/man/whipper-cd-rip.rst index d85417f..1b7ec56 100644 --- a/man/whipper-cd-rip.rst +++ b/man/whipper-cd-rip.rst @@ -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 diff --git a/whipper/command/cd.py b/whipper/command/cd.py index f8bd3e5..a36386e 100644 --- a/whipper/command/cd.py +++ b/whipper/command/cd.py @@ -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 diff --git a/whipper/common/common.py b/whipper/common/common.py index 5e99609..da41250 100644 --- a/whipper/common/common.py +++ b/whipper/common/common.py @@ -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))) diff --git a/whipper/common/program.py b/whipper/common/program.py index 9d14d57..75b5732 100644 --- a/whipper/common/program.py +++ b/whipper/common/program.py @@ -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