feat: add a key for extra uniqueness

This commit is contained in:
Benexl
2025-11-18 14:20:07 +03:00
parent 6e287d320d
commit 8440ffb5e5
3 changed files with 10 additions and 11 deletions

View File

@@ -26,8 +26,10 @@ SCALE_UP = "{SCALE_UP}" == "True"
# fzf passes the title with quotes, so we need to trim them
TITLE = sys.argv[1]
KEY = "{KEY}"
KEY = KEY + "-" if KEY else KEY
hash = f"{PREFIX}-{sha256(TITLE.encode('utf-8')).hexdigest()}"
hash = f"{PREFIX}-{sha256((KEY + TITLE).encode('utf-8')).hexdigest()}"
def fzf_image_preview(file_path: str):

View File

@@ -299,7 +299,8 @@ def get_anime_preview(
# Color codes
"HEADER_COLOR": ",".join(HEADER_COLOR),
"SEPARATOR_COLOR": ",".join(SEPARATOR_COLOR),
"PREFIX": "search-results",
"PREFIX": "search-result",
"KEY": "",
"SCALE_UP": str(config.general.preview_scale_up),
}
@@ -348,9 +349,6 @@ def get_episode_preview(
logger.error(f"Failed to start episode background caching: {e}")
# Continue with script generation even if caching fails
# Prepare values to inject into the template
path_sep = "\\" if PLATFORM == "win32" else "/"
# Format the template with the dynamic values
replacements = {
"PREVIEW_MODE": config.general.preview,
@@ -360,7 +358,8 @@ def get_episode_preview(
# Color codes
"HEADER_COLOR": ",".join(HEADER_COLOR),
"SEPARATOR_COLOR": ",".join(SEPARATOR_COLOR),
"PREFIX": f"episode-{media_item.title.english}",
"PREFIX": "episode",
"KEY": f"{media_item.title.english}",
"SCALE_UP": str(config.general.preview_scale_up),
}

View File

@@ -238,7 +238,7 @@ class PreviewCacheWorker(ManagedBackgroundWorker):
"""Generate a cache hash for the given text."""
from hashlib import sha256
return f"search-results-{sha256(text.encode('utf-8')).hexdigest()}"
return f"search-result-{sha256(text.encode('utf-8')).hexdigest()}"
def _on_task_completed(self, task: WorkerTask, future) -> None:
"""Handle task completion with enhanced logging."""
@@ -307,9 +307,7 @@ class EpisodeCacheWorker(ManagedBackgroundWorker):
streaming_episodes = media_item.streaming_episodes
for episode_str in episodes:
hash_id = self._get_cache_hash(
f"{media_item.title.english}_Episode_{episode_str}"
)
hash_id = self._get_cache_hash(f"{media_item.title.english}-{episode_str}")
# Find episode data
episode_data = streaming_episodes.get(episode_str)
@@ -404,7 +402,7 @@ class EpisodeCacheWorker(ManagedBackgroundWorker):
"""Generate a cache hash for the given text."""
from hashlib import sha256
return sha256(text.encode("utf-8")).hexdigest()
return "episode-" + sha256(text.encode("utf-8")).hexdigest()
def _on_task_completed(self, task: WorkerTask, future) -> None:
"""Handle task completion with enhanced logging."""