Karan Adhikari commited on
Commit
28d4695
Β·
unverified Β·
1 Parent(s): 09f6d64

Update global_search.py

Browse files
Files changed (1) hide show
  1. Backend/helper/global_search.py +12 -0
Backend/helper/global_search.py CHANGED
@@ -35,6 +35,7 @@ _userbot_session_dead = False
35
  _chat_title_cache: Dict[int, str] = {}
36
 
37
  _TOKEN_RE = re.compile(r"[a-z0-9]+")
 
38
 
39
 
40
  # ── Availability ──────────────────────────────────────────────────────────────
@@ -97,10 +98,21 @@ def _parse_and_validate(
97
  season: Optional[int],
98
  episode: Optional[int],
99
  ) -> Optional[dict]:
 
 
 
 
 
100
  try:
101
  parsed = PTN.parse(filename)
102
  except Exception:
103
  return None
 
 
 
 
 
 
104
  if not _matches_episode(parsed, season, episode):
105
  return None
106
  if _title_score(parsed.get("title", ""), expected_title) < MIN_TITLE_SCORE:
 
35
  _chat_title_cache: Dict[int, str] = {}
36
 
37
  _TOKEN_RE = re.compile(r"[a-z0-9]+")
38
+ _MULTIPART_RE = re.compile(r"(?:part|cd|disc|disk)[s._-]*\d+(?=\.\w+$)", re.IGNORECASE)
39
 
40
 
41
  # ── Availability ──────────────────────────────────────────────────────────────
 
98
  season: Optional[int],
99
  episode: Optional[int],
100
  ) -> Optional[dict]:
101
+ # Skip split files (e.g. Part1, CD2, Disc3)
102
+ if _MULTIPART_RE.search(filename):
103
+ LOGGER.info(f"Skipping {filename}: seems to be a split video file")
104
+ return None
105
+
106
  try:
107
  parsed = PTN.parse(filename)
108
  except Exception:
109
  return None
110
+
111
+ # Skip files marked as combined in PTN excess tags
112
+ if "excess" in parsed and any("combined" in item.lower() for item in parsed["excess"]):
113
+ LOGGER.info(f"Skipping {filename}: contains 'combined'")
114
+ return None
115
+
116
  if not _matches_episode(parsed, season, episode):
117
  return None
118
  if _title_score(parsed.get("title", ""), expected_title) < MIN_TITLE_SCORE: