Torrent file name sanitizing (#390)

Hi, I've added file names sanitization when saving the torrent file, as
previously the import was failing on torrents with special characters in
names. This fixes #367
This commit is contained in:
Sergey Khruschak
2026-02-03 18:09:36 +02:00
committed by GitHub
parent d5994a9037
commit 24fcba6bee
3 changed files with 14 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import bencoder
import libtorrent
import patoolib
import requests
from pathvalidate import sanitize_filename
from requests.exceptions import InvalidSchema
from media_manager.config import MediaManagerConfig
@@ -132,7 +133,7 @@ def get_torrent_hash(torrent: IndexerQueryResult) -> str:
:return: The hash of the torrent.
"""
torrent_filepath = (
MediaManagerConfig().misc.torrent_directory / f"{torrent.title}.torrent"
MediaManagerConfig().misc.torrent_directory / f"{sanitize_filename(torrent.title)}.torrent"
)
if torrent_filepath.exists():
log.warning(f"Torrent file already exists at: {torrent_filepath}")