Skip to content

Commit d1bbc14

Browse files
committed
Improve emoji detection to prioritize specific content types over generic terms
1 parent 74f7ac8 commit d1bbc14

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cogs/jellyfin_core.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,19 +456,19 @@ def get_library_stats(self) -> Dict[str, Dict[str, Any]]:
456456
if key == "default":
457457
continue
458458
if key in library_name_lower:
459-
matches.append((key, value, len(key)))
459+
matches.append((key, value, len(key), key in GENERIC_TERMS))
460460

461461
# Second pass: find the best non-generic match
462-
for key, value, length in matches:
463-
if key not in GENERIC_TERMS and length > best_match_length:
462+
for key, value, length, is_generic in matches:
463+
if not is_generic and length > best_match_length:
464464
best_match_length = length
465465
best_match_key = key
466466
emoji = value
467467

468468
# If no non-generic match was found, use the best match overall
469469
if best_match_key is None and matches:
470-
best_match_length = max(length for _, _, length in matches)
471-
for key, value, length in matches:
470+
best_match_length = max(length for _, _, length, _ in matches)
471+
for key, value, length, _ in matches:
472472
if length == best_match_length:
473473
emoji = value
474474
break
@@ -759,19 +759,19 @@ async def update_libraries(self, interaction: discord.Interaction):
759759
if key == "default":
760760
continue
761761
if key in library_name_lower:
762-
matches.append((key, value, len(key)))
762+
matches.append((key, value, len(key), key in GENERIC_TERMS))
763763

764764
# Second pass: find the best non-generic match
765-
for key, value, length in matches:
766-
if key not in GENERIC_TERMS and length > best_match_length:
765+
for key, value, length, is_generic in matches:
766+
if not is_generic and length > best_match_length:
767767
best_match_length = length
768768
best_match_key = key
769769
emoji = value
770770

771771
# If no non-generic match was found, use the best match overall
772772
if best_match_key is None and matches:
773-
best_match_length = max(length for _, _, length in matches)
774-
for key, value, length in matches:
773+
best_match_length = max(length for _, _, length, _ in matches)
774+
for key, value, length, _ in matches:
775775
if length == best_match_length:
776776
emoji = value
777777
break

0 commit comments

Comments
 (0)