summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-26 17:18:37 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-26 17:18:37 +0200
commit80cb6c4dc5f22336387f2ac74ef2cb85cf2cf7d4 (patch)
tree590e2daf81b2feef674f1bd580b9bf40f83addad /packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
parentca62b4123b854fc9ece258e14c84c895aaa275cd (diff)
parent59289b82dc8af08c605fd247c90a5c5ec92c6db3 (diff)
downloadmeshbay-80cb6c4dc5f22336387f2ac74ef2cb85cf2cf7d4.tar.gz
Merge branch 'feat/video-type-filter'
Videos app grouping and TMDB matching fixes, plus a new toolbar filter: - A season-like ancestor folder (numbered season, or Specials/Bonus/Extras -> season 0) now names the show from its own root folder, unconditionally — never a per-file guessit title, which cannot tell a show's real name from an individual episode's own one-off name when the filename carries no reliable ShowName/SxxExx structure. Fixes a real show's episodes and Specials folder alike showing up as dozens of individual "movies", each matched against TMDB by its own one-off title. - The ancestor walk continues past every consecutive season-like folder, not just the first — a per-season Bonus folder is nested two levels inside the show, and stopping at the first would name the season as the show. - A season spanning more than one folder (a per-book Bonus folder nested inside every numbered season) no longer hands out colliding episode numbers independently in each one. - guessit's own episode number is not trusted when it comes from a bare 3-digit leading number ("100" parses as season=1/episode=0, not episode=100) — read directly via regex instead. - Recognizes "S1"/"S2"-style abbreviated season folders, not just full words ("Season"/"Saison"/"Livre") — a real show organized its later seasons this way and they never got the ancestor-based grouping fix at all. - The TMDB match cache is no longer trusted across a movie<->show reclassification it doesn't know happened. - New: an All/Movies/Series filter in the Videos toolbar, to the left of the search field, defaulting to "All"; wraps correctly on mobile. Verified live against the real libraries these were found on throughout — not synthetic reproduction alone. 430 hub tests + 667 node tests passing.
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.py32
1 files changed, 30 insertions, 2 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 5203247..24b423e 100644
--- a/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
+++ b/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py
@@ -36,13 +36,21 @@ _EDITION_RE = re.compile("|".join(_EDITION_PHRASES), re.IGNORECASE)
# A season-like ancestor folder: the English/French words plus a number or
# Roman numeral. Vocabulary is a plain tuple so a deployment can extend it
-# per locale without touching the regex-building logic.
-SEASON_WORDS = ("season", "saison")
+# per locale without touching the regex-building logic. "livre" ("book") is
+# real, observed vocabulary too — some shows name their seasons that way
+# (Roman numerals: "Livre I".."Livre VI") rather than "saison".
+SEASON_WORDS = ("season", "saison", "livre")
_SEASON_RE = re.compile(
r"(?:" + "|".join(SEASON_WORDS) + r")\s*([0-9]+|[ivxlc]+)\b",
re.IGNORECASE,
)
_SPECIALS_RE = re.compile(r"\b(?:bonus|extras?|specials?)\b", re.IGNORECASE)
+# A bare "S" + number as the *whole* folder name — "S1", "S2", "S02" — a
+# common abbreviated convention distinct from SEASON_WORDS' full words.
+# Anchored to the entire name, not just `\b`-bounded within a longer
+# string, so it only matches a folder actually named just that — never
+# some other word that merely starts with "s" followed by digits.
+_SEASON_ABBREV_RE = re.compile(r"^s(\d{1,2})$", re.IGNORECASE)
_ROMAN_NUMERALS = {
2: "II", 3: "III", 4: "IV", 5: "V", 6: "VI",
@@ -108,6 +116,9 @@ def season_from_folder_name(name: str) -> int | None:
"""
if _SPECIALS_RE.search(name):
return 0
+ m = _SEASON_ABBREV_RE.match(name.strip())
+ if m:
+ return int(m.group(1))
m = _SEASON_RE.search(name)
if not m:
return None
@@ -227,3 +238,20 @@ def parse_episode_filename(filename: str) -> ParsedName:
display_title=title or None, naive_title=nt,
season=season, episode=episode, confidence=confidence,
)
+
+
+# A bare leading episode number, no show name attached (§3.4c) — the same
+# shape as music's _TRACK_PREFIX_RE, capped at 3 digits for the same reason:
+# a leading year ("2010 - Episode.mkv") is 4 digits and must not match.
+# guessit's own `episode` is not a substitute here: given exactly 3 digits it
+# tries to read them as a concatenated SxxE/SEE season+episode pair instead
+# of a plain episode number — confirmed live, "100 Title.mkv" parses as
+# season=1, episode=0, not episode=100 — silently wrong in a way nothing
+# about its output distinguishes from a real 2-digit episode. This reads the
+# whole leading number as one value instead.
+_LEADING_NUMBER_RE = re.compile(r"^(\d{1,3})[\s._-]+(?=\S)")
+
+
+def leading_episode_number(filename: str) -> int | None:
+ m = _LEADING_NUMBER_RE.match(filename)
+ return int(m.group(1)) if m else None