Migrate from Poetry and pyenv to uv

This commit is contained in:
2026-10-12 15:48:26 +02:00
parent c399a6aed3
commit c69f5f9166
93 changed files with 13068 additions and 2401 deletions
+28 -3
View File
@@ -15,6 +15,7 @@ writes it upper-case for a single canonical form.
These helpers build, validate and parse the stem (the filename without its
extension).
"""
import re
# Jellyfin's recognised 3D format tags (case-insensitive on read; Curator
@@ -29,7 +30,8 @@ THREE_D_FORMATS = ("HSBS", "FSBS", "HTAB", "FTAB", "MVC")
_POOL_STEM_RE = re.compile(
r"^(?P<title>.+?) \((?P<year>\d{4})\)(?: \[tmdbid-(?P<id>\d+)\])?"
r"(?:\.3D\.(?P<format3d>hsbs|fsbs|htab|ftab|mvc))?$",
re.IGNORECASE)
re.IGNORECASE,
)
def is_valid_year(year: object) -> bool:
@@ -38,7 +40,10 @@ def is_valid_year(year: object) -> bool:
def canonical_pool_stem(
title: str, year: object, tmdb_id: object = None, format_3d: object = None,
title: str,
year: object,
tmdb_id: object = None,
format_3d: object = None,
) -> str:
"""Build the canonical pool stem ``Title (YYYY)`` (+ `` [tmdbid-N]`` /
``.3D.<FORMAT>`` if given).
@@ -65,7 +70,8 @@ def canonical_pool_stem(
if fmt not in THREE_D_FORMATS:
raise ValueError(
f"3D formát musí být jedno z {', '.join(THREE_D_FORMATS)}, "
f"ne „{format_3d}“.")
f"ne „{format_3d}“."
)
stem += f".3D.{fmt}"
return stem
@@ -116,3 +122,22 @@ def year_from_filename(name: str) -> str | None:
return paren.group(1)
loose = re.findall(r"(?<!\d)(19\d{2}|20\d{2})(?!\d)", name)
return loose[-1] if loose else None
# "3D" + one of THREE_D_FORMATS, anywhere in a raw filename, bordered by a
# non-alphanumeric character (or the string's edge) on each side so it can't
# match inside an unrelated word.
_THREE_D_ANYWHERE_RE = re.compile(
rf"(?<![A-Za-z0-9])3d[\s._-]*({'|'.join(THREE_D_FORMATS)})(?![A-Za-z0-9])",
re.IGNORECASE,
)
def three_d_format_from_filename(name: str) -> str | None:
"""Best-effort 3D format guessed from a raw (release) filename, e.g.
``Avatar.2009.3D.HSBS.BluRay.mkv`` → ``"HSBS"``. Unlike :func:`parse_3d_format`
this doesn't require the rest of the name to be a canonical pool stem — used
to pre-fill a version label while importing. Returns ``None`` if absent.
"""
match = _THREE_D_ANYWHERE_RE.search(name or "")
return match.group(1).upper() if match else None