feat: sanitize " in key

This commit is contained in:
Benexl
2025-11-18 14:48:00 +03:00
parent 64093204ad
commit 08ae8786c3
4 changed files with 9 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ 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}"""
KEY = KEY + "-" if KEY else KEY
hash = f"{PREFIX}-{sha256((KEY + TITLE).encode('utf-8')).hexdigest()}"

View File

@@ -6,6 +6,8 @@ from typing import Dict, List, Optional
import httpx
from viu_media.core.utils import formatter
from ...core.config import AppConfig
from ...core.constants import APP_CACHE_DIR, PLATFORM, SCRIPTS_DIR
from ...core.utils.file import AtomicWriter
@@ -359,7 +361,7 @@ def get_episode_preview(
"HEADER_COLOR": ",".join(HEADER_COLOR),
"SEPARATOR_COLOR": ",".join(SEPARATOR_COLOR),
"PREFIX": "episode",
"KEY": f"{media_item.title.english}",
"KEY": f"{media_item.title.english.replace(formatter.DOUBLE_QUOTE, formatter.SINGLE_QUOTE)}",
"SCALE_UP": str(config.general.preview_scale_up),
}

View File

@@ -307,7 +307,9 @@ 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_str}")
hash_id = self._get_cache_hash(
f"{media_item.title.english.replace(formatter.DOUBLE_QUOTE, formatter.SINGLE_QUOTE)}-{episode_str}"
)
# Find episode data
episode_data = streaming_episodes.get(episode_str)

View File

@@ -5,6 +5,8 @@ from typing import Dict, List, Optional, Union
from ...libs.media_api.types import AiringSchedule
COMMA_REGEX = re.compile(r"([0-9]{3})(?=\d)")
SINGLE_QUOTE = "'"
DOUBLE_QUOTE = '"'
def format_media_duration(total_minutes: Optional[int]) -> str: