From 53ff57257cb1c238b7264b925e222d5790c79a28 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 29 Sep 2021 08:25:16 +0200 Subject: [PATCH] workandmovement: Strip separating chars like comma from start of movement title --- plugins/workandmovement/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/workandmovement/__init__.py b/plugins/workandmovement/__init__.py index c97c6a2c..ecec2fd0 100644 --- a/plugins/workandmovement/__init__.py +++ b/plugins/workandmovement/__init__.py @@ -37,8 +37,9 @@ from picard.metadata import register_track_metadata_processor -_re_work_title = re.compile(r'(?P.*):\s+(?P[IVXLCDM]+)\.\s+(?P.*)') -_re_part_number = re.compile(r'(?P[0-9IVXLCDM]+)\.?\s+') +_re_work_title = re.compile(r'(?P.*):\s+(?P[IVXLCDM]+)\.\s[\s,:;./]*(?P.*)') +_re_part_number = re.compile(r'(?P[0-9IVXLCDM]+)\.?\s[\s,:;./]*') +_re_separators = re.compile(r'^[\s,:;./-]+') class Work: @@ -147,14 +148,15 @@ def normalize_movement_title(work): if work.parent: work_title = work.parent.title if movement_title.startswith(work_title): - movement_title = movement_title[len(work_title):].lstrip(':').strip() + movement_title = movement_title[len(work_title):] + movement_title = _re_separators.sub('', movement_title) match = _re_part_number.match(movement_title) if match: # Only remove the number if it matches the part_number try: number = number_to_int(match.group('number')) if number == work.part_number: - movement_title = _re_part_number.sub("", movement_title) + movement_title = _re_part_number.sub('', movement_title) except ValueError as e: log.warning(e) return movement_title