From d3c6b95ada44151394f210f58c385ddd01b3a47e Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 29 Sep 2021 08:12:19 +0200 Subject: [PATCH 1/2] workandmovement: Fixed exception if ordering-key is missing --- plugins/workandmovement/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/workandmovement/__init__.py b/plugins/workandmovement/__init__.py index 6355f40d..c97c6a2c 100644 --- a/plugins/workandmovement/__init__.py +++ b/plugins/workandmovement/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2018-2019 Philipp Wolfer +# Copyright (C) 2018-2019, 2021 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -20,8 +20,8 @@ PLUGIN_NAME = 'Work & Movement' PLUGIN_AUTHOR = 'Philipp Wolfer' PLUGIN_DESCRIPTION = 'Set work and movement based on work relationships' -PLUGIN_VERSION = '1.0.1' -PLUGIN_API_VERSIONS = ['2.1', '2.2'] +PLUGIN_VERSION = '1.0.2' +PLUGIN_API_VERSIONS = ['2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7'] PLUGIN_LICENSE = 'GPL-2.0-or-later' PLUGIN_LICENSE_URL = 'https://www.gnu.org/licenses/gpl-2.0.html' @@ -170,7 +170,7 @@ def parse_work(work_rel): if is_parent_work(rel): if is_movement_like(rel): work.is_movement = True - work.part_number = rel['ordering-key'] + work.part_number = rel.get('ordering-key') if 'work' in rel: work.parent = parse_work(rel['work']) work.parent.is_work = True From 53ff57257cb1c238b7264b925e222d5790c79a28 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 29 Sep 2021 08:25:16 +0200 Subject: [PATCH 2/2] 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