aboutsummaryrefslogtreecommitdiffstats
path: root/models.py
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-10-10 22:34:50 -0700
committerPinapelz <yukais@pinapelz.com>2026-10-10 22:34:50 -0700
commit23d5c91b0ad2ecd13e1155cf4966b6d3d99f7dd5 (patch)
tree3621e557bc17d5e20622a3179f0e23691202c9a5 /models.py
parent5554d8befd332b496c893c6f1d674e29bba79e4e (diff)
feat: CD ripping support for Linux
Diffstat (limited to 'models.py')
-rw-r--r--models.py13
1 files changed, 13 insertions, 0 deletions
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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage