Skip to content

Commit

Permalink
Try to fix these regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Sep 30, 2024
1 parent f9d7b02 commit c43f9eb
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 4 deletions.
8 changes: 5 additions & 3 deletions beetsplug/bandcamp/album_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from functools import cached_property
from typing import Any, Dict, Match

import regex

from .helpers import PATTERNS, Helpers

JSONDict = Dict[str, Any]
Expand All @@ -17,7 +19,7 @@ class AlbumName:
_series = r"(?i:\b(part|volume|pt|vol)\b\.?)"
SERIES = re.compile(rf"{_series}[ ]?[A-Z\d.-]+\b")
SERIES_FMT = re.compile(rf"^(.+){_series} *0*")
REMIX_IN_TITLE = re.compile(r"[\( :]+(with re|inc|\+).*?mix[^)]*(\)|$)", re.I)
REMIX_IN_TITLE = regex.compile(r"[\( :]+(with re|inc|\+)[^m]*+mix[^)]*(\)|$)", re.I)
CLEAN_EPLP = re.compile(r"(?:[([]|Double ){0,2}(\b[EL]P\b)\S?", re.I)
EPLP_ALBUM = re.compile(r"\b(?!VA|0\d|-)([^\s:]+\b|[&, ])+ [EL]P\b( [\w#][^ ]+$)?")
EPLP_ALBUM_LINE = re.compile(r"\b(?=[A-Z])(((?!Vinyl|VA|-)[^:\s]+ )+)[EL]P$", re.M)
Expand All @@ -32,10 +34,10 @@ class AlbumName:
re.IGNORECASE + re.VERBOSE,
)
COMPILATION_IN_TITLE = re.compile(r"compilation|best of|anniversary", re.I)
CLEAN_CATALOGNUM = re.compile(
CLEAN_CATALOGNUM = regex.compile(
r"""
(^[A-Z]+\d+\ [|-]\ )
| [^[\w)\]]*\[[A-Z]+\d+\]
| [^[\w)\]]*+\[[A-Z]+\d+\]
""",
re.VERBOSE,
)
Expand Down
105 changes: 104 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ beets = ">=1.5"
httpx = ">=0.27.0"
ordered-set = ">=4.0"
packaging = ">=24.0"
regex = ">=2024.9.11"

[tool.poetry.dev-dependencies]
coveralls = { version = ">=4.0.1", python = ">=3.8,<3.13" }
Expand Down

0 comments on commit c43f9eb

Please sign in to comment.