diff --git a/viu_media/assets/scripts/fzf/preview.py b/viu_media/assets/scripts/fzf/preview.py index 46159cb..eb163e0 100644 --- a/viu_media/assets/scripts/fzf/preview.py +++ b/viu_media/assets/scripts/fzf/preview.py @@ -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): diff --git a/viu_media/cli/utils/preview.py b/viu_media/cli/utils/preview.py index ed256f1..cf97422 100644 --- a/viu_media/cli/utils/preview.py +++ b/viu_media/cli/utils/preview.py @@ -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), } diff --git a/viu_media/cli/utils/preview_workers.py b/viu_media/cli/utils/preview_workers.py index 7f084b3..aac7039 100644 --- a/viu_media/cli/utils/preview_workers.py +++ b/viu_media/cli/utils/preview_workers.py @@ -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."""