Improved checking for duplicate performers in queue

This commit is contained in:
Christoph Stahl 2023-10-09 18:35:35 +02:00
parent a38dedee6c
commit 0dd0f32b47

View file

@ -3,6 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from dataclasses import field from dataclasses import field
import re
from typing import Any from typing import Any
from typing import Optional from typing import Optional
from uuid import UUID from uuid import UUID
@ -64,8 +65,8 @@ class Entry:
""" """
Update the attributes with given substitutions. Update the attributes with given substitutions.
:param \*\*kwargs: Keywords taken from the list of attributes. :param \\*\\*kwargs: Keywords taken from the list of attributes.
:type \*\*kwargs: Any :type \\*\\*kwargs: Any
:rtype: None :rtype: None
""" """
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
@ -74,8 +75,19 @@ class Entry:
def normalize(performers: str) -> set[str]: def normalize(performers: str) -> set[str]:
return set( return set(
filter( filter(
lambda x: len(x) > 3, lambda x: len(x) > 0
performers.replace(",", " ").replace(".", " ").split(" "), and x not in ["der", "die", "das", "alle", "und"],
re.sub(
r"[^a-zA-Z0-9\s]",
"",
re.sub(
r"\s",
" ",
performers.lower()
.replace(".", " ")
.replace(",", " "),
),
).split(" "),
) )
) )