summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/indexer/title_parse.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/indexer/title_parse.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py b/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
index 6676e9b..5203247 100644
--- a/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
+++ b/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
@@ -187,6 +187,20 @@ def parse_track_filename(filename: str) -> ParsedTrack:
return ParsedTrack(title=title, track_no=track_no, naive_title=naive_title(filename))
+def strip_track_prefix(text: str) -> str:
+ """
+ Some taggers copy the bare filename into the `title` tag verbatim,
+ track-number prefix included (found live: a whole CD-single's worth of
+ `title` tags reading "01 - Venus As A Boy" rather than "Venus As A
+ Boy") — since a tag normally wins over the filename-parsed title
+ (enrich_audio.py), that pollution would otherwise beat a cleaner parse.
+ A no-op when there's no such prefix, so a genuinely clean tag is
+ returned unchanged.
+ """
+ m = _TRACK_PREFIX_RE.match(text)
+ return re.sub(r"^[\s-]+", "", text[m.end():]).strip() if m else text
+
+
def parse_episode_filename(filename: str) -> ParsedName:
"""
Parse an episode filename. `display_title` may come back None (e.g.