From 23d5c91b0ad2ecd13e1155cf4966b6d3d99f7dd5 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sat, 10 Oct 2026 22:34:50 -0700 Subject: feat: CD ripping support for Linux --- models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'models.py') diff --git a/models.py b/models.py index 01f91c2..5e35c97 100644 --- a/models.py +++ b/models.py @@ -1,5 +1,6 @@ from __future__ import annotations +import re from dataclasses import dataclass from pathlib import Path from types import SimpleNamespace @@ -47,6 +48,18 @@ def flac_name(name: str) -> str: return name if name.lower().endswith(".flac") else name + ".flac" +def track_number(path: Path) -> int | None: + try: + value = FLAC(str(path)).get("TRACKNUMBER", [""])[0] + except Exception: + value = "" + for text in (str(value), path.stem): + match = re.match(r"\s*0*(\d{1,3})\b", text) + if match: + return int(match.group(1)) + return None + + @dataclass class Track: path: Path -- cgit v1.2.3