Strip Rifftrax/channel tags and trust unique fuzzy match candidates
This commit is contained in:
+13
-12
@@ -903,21 +903,20 @@ def fuzzy_title_match(media_type, results, query, year):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
query_norm = clean_and_squeeze(query).lower()
|
query_norm = clean_and_squeeze(query).lower()
|
||||||
best = None
|
year_matches = [r for r in results if result_year(media_type, r) == year]
|
||||||
best_ratio = 0.0
|
if not year_matches:
|
||||||
|
return None
|
||||||
|
|
||||||
for r in results:
|
def title_similarity(r):
|
||||||
if result_year(media_type, r) != year:
|
|
||||||
continue
|
|
||||||
title_norm = clean_and_squeeze(result_title(media_type, r) or "").lower()
|
title_norm = clean_and_squeeze(result_title(media_type, r) or "").lower()
|
||||||
if not title_norm:
|
if not title_norm:
|
||||||
continue
|
return 0.0
|
||||||
ratio = difflib.SequenceMatcher(None, query_norm, title_norm).ratio()
|
return difflib.SequenceMatcher(None, query_norm, title_norm).ratio()
|
||||||
if ratio > best_ratio:
|
|
||||||
best_ratio = ratio
|
|
||||||
best = r
|
|
||||||
|
|
||||||
if best is not None and best_ratio >= FUZZY_TITLE_MATCH_THRESHOLD:
|
best = max(year_matches, key=title_similarity)
|
||||||
|
best_ratio = title_similarity(best)
|
||||||
|
threshold = YEAR_MATCH_MIN_SIMILARITY if len(year_matches) == 1 else FUZZY_TITLE_MATCH_THRESHOLD
|
||||||
|
if best_ratio >= threshold:
|
||||||
return best, best_ratio
|
return best, best_ratio
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -991,7 +990,7 @@ JUNK_TOKENS = {
|
|||||||
"bluray", "blueray", "bdrip", "brrip", "bdremux", "remux",
|
"bluray", "blueray", "bdrip", "brrip", "bdremux", "remux",
|
||||||
"webrip", "webdl", "web", "dl", "hdtv", "hdrip", "dvdrip", "dvd",
|
"webrip", "webdl", "web", "dl", "hdtv", "hdrip", "dvdrip", "dvd",
|
||||||
"hevc", "x264", "x265", "h264", "h265", "avc", "xvid", "divx",
|
"hevc", "x264", "x265", "h264", "h265", "avc", "xvid", "divx",
|
||||||
"aac", "ac3", "eac3", "dts", "atmos", "ddp", "dd",
|
"aac", "ac3", "eac3", "dts", "atmos", "ddp", "dd", "rifftrax",
|
||||||
"proper", "repack", "extended", "unrated", "uncut", "explicit", "ultimate", "director", "directors", "cut",
|
"proper", "repack", "extended", "unrated", "uncut", "explicit", "ultimate", "director", "directors", "cut",
|
||||||
"internal", "limited", "theatrical", "multi", "dual", "audio",
|
"internal", "limited", "theatrical", "multi", "dual", "audio",
|
||||||
"hdr", "sdr", "4k", "uhd", "10bit", "8bit", "hi10p", "hi444pp",
|
"hdr", "sdr", "4k", "uhd", "10bit", "8bit", "hi10p", "hi444pp",
|
||||||
@@ -1073,6 +1072,7 @@ RELEASE_GROUP_SUFFIX_PATTERN = re.compile(
|
|||||||
)
|
)
|
||||||
|
|
||||||
AUDIO_CHANNELS_PATTERN = re.compile(r'(?<![0-9])\d\.\d(?![0-9])')
|
AUDIO_CHANNELS_PATTERN = re.compile(r'(?<![0-9])\d\.\d(?![0-9])')
|
||||||
|
AUDIO_CHANNEL_COUNT_PATTERN = re.compile(r'\b\d(?:ch|CH)\b')
|
||||||
AUDIO_CODEC_CHANNELS_PATTERN = re.compile(
|
AUDIO_CODEC_CHANNELS_PATTERN = re.compile(
|
||||||
r'\b(DDP?|EAC3|AC3|TrueHD|Atmos|DTS(?:-HD)?|FLAC|AAC)[.\s]?\d(?:[.\s]\d)?\b',
|
r'\b(DDP?|EAC3|AC3|TrueHD|Atmos|DTS(?:-HD)?|FLAC|AAC)[.\s]?\d(?:[.\s]\d)?\b',
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
@@ -1155,6 +1155,7 @@ def build_query(raw_name, year, keep_hyphens=False):
|
|||||||
raw_name = VIDEO_CODEC_SPACED_PATTERN.sub(r'H\1', raw_name)
|
raw_name = VIDEO_CODEC_SPACED_PATTERN.sub(r'H\1', raw_name)
|
||||||
raw_name = AUDIO_CODEC_CHANNELS_PATTERN.sub(' ', raw_name)
|
raw_name = AUDIO_CODEC_CHANNELS_PATTERN.sub(' ', raw_name)
|
||||||
raw_name = AUDIO_CHANNELS_PATTERN.sub(' ', raw_name)
|
raw_name = AUDIO_CHANNELS_PATTERN.sub(' ', raw_name)
|
||||||
|
raw_name = AUDIO_CHANNEL_COUNT_PATTERN.sub(' ', raw_name)
|
||||||
raw_name = strip_junk_trailing_paren(raw_name)
|
raw_name = strip_junk_trailing_paren(raw_name)
|
||||||
|
|
||||||
match = RELEASE_GROUP_SUFFIX_PATTERN.search(raw_name)
|
match = RELEASE_GROUP_SUFFIX_PATTERN.search(raw_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user