Karan Adhikari commited on
Commit
c26ef46
·
unverified ·
1 Parent(s): 25b0f7e

Update metadata.py

Browse files
Files changed (1) hide show
  1. Backend/helper/metadata.py +11 -3
Backend/helper/metadata.py CHANGED
@@ -520,6 +520,7 @@ async def fetch_tv_metadata(title, season, episode, encoded_string, year=None, q
520
  imdb_tv = None
521
  imdb_ep = None
522
  use_tmdb = False
 
523
 
524
  # ------------------------------------------------------------------
525
  # 1. Handle explicit default ID
@@ -528,6 +529,7 @@ async def fetch_tv_metadata(title, season, episode, encoded_string, year=None, q
528
  default_id = str(default_id)
529
  if default_id.startswith("tt"):
530
  imdb_id = default_id
 
531
  elif default_id.isdigit():
532
  tmdb_id = int(default_id)
533
  use_tmdb = True
@@ -567,9 +569,11 @@ async def fetch_tv_metadata(title, season, episode, encoded_string, year=None, q
567
 
568
  # ------------------------------------------------------------------
569
  # 4. Validate IMDb result against query title (guard against Cinemeta
570
- # returning a stale wrong hit despite the fuzzy pre-filter)
 
 
571
  # ------------------------------------------------------------------
572
- if imdb_tv and not use_tmdb:
573
  matched_title = imdb_tv.get("title", "")
574
  sim = _title_similarity(title, matched_title)
575
  if sim < _CINEMETA_THRESHOLD:
@@ -690,6 +694,7 @@ async def fetch_movie_metadata(title, encoded_string, year=None, quality=None, d
690
  tmdb_id = None
691
  imdb_details = None
692
  use_tmdb = False
 
693
 
694
  # ------------------------------------------------------------------
695
  # 1. Explicit default ID
@@ -698,6 +703,7 @@ async def fetch_movie_metadata(title, encoded_string, year=None, quality=None, d
698
  default_id = str(default_id).strip()
699
  if default_id.startswith("tt"):
700
  imdb_id = default_id
 
701
  elif default_id.isdigit():
702
  tmdb_id = int(default_id)
703
  use_tmdb = True
@@ -728,8 +734,10 @@ async def fetch_movie_metadata(title, encoded_string, year=None, quality=None, d
728
 
729
  # ------------------------------------------------------------------
730
  # 4. Validate IMDb result title against query
 
 
731
  # ------------------------------------------------------------------
732
- if imdb_details and not use_tmdb:
733
  matched_title = imdb_details.get("title", "")
734
  sim = _title_similarity(title, matched_title)
735
  if sim < _CINEMETA_THRESHOLD:
 
520
  imdb_tv = None
521
  imdb_ep = None
522
  use_tmdb = False
523
+ explicit_imdb_id = False
524
 
525
  # ------------------------------------------------------------------
526
  # 1. Handle explicit default ID
 
529
  default_id = str(default_id)
530
  if default_id.startswith("tt"):
531
  imdb_id = default_id
532
+ explicit_imdb_id = True
533
  elif default_id.isdigit():
534
  tmdb_id = int(default_id)
535
  use_tmdb = True
 
569
 
570
  # ------------------------------------------------------------------
571
  # 4. Validate IMDb result against query title (guard against Cinemeta
572
+ # returning a stale wrong hit despite the fuzzy pre-filter).
573
+ # Skipped when the IMDb ID was supplied explicitly, since the user
574
+ # deliberately chose that exact ID.
575
  # ------------------------------------------------------------------
576
+ if imdb_tv and not use_tmdb and not explicit_imdb_id:
577
  matched_title = imdb_tv.get("title", "")
578
  sim = _title_similarity(title, matched_title)
579
  if sim < _CINEMETA_THRESHOLD:
 
694
  tmdb_id = None
695
  imdb_details = None
696
  use_tmdb = False
697
+ explicit_imdb_id = False
698
 
699
  # ------------------------------------------------------------------
700
  # 1. Explicit default ID
 
703
  default_id = str(default_id).strip()
704
  if default_id.startswith("tt"):
705
  imdb_id = default_id
706
+ explicit_imdb_id = True
707
  elif default_id.isdigit():
708
  tmdb_id = int(default_id)
709
  use_tmdb = True
 
734
 
735
  # ------------------------------------------------------------------
736
  # 4. Validate IMDb result title against query
737
+ # (skipped when the IMDb ID was supplied explicitly — e.g. manual
738
+ # /set or web "Rescan Metadata" — since the user chose the exact ID)
739
  # ------------------------------------------------------------------
740
+ if imdb_details and not use_tmdb and not explicit_imdb_id:
741
  matched_title = imdb_details.get("title", "")
742
  sim = _title_similarity(title, matched_title)
743
  if sim < _CINEMETA_THRESHOLD: