From bd21650394729013c6f4278f1186305aae12d837 Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Fri, 20 Mar 2026 15:20:04 +0530 Subject: [PATCH] feat: added filename sanitization settings #16 #19 --- .../pages/settings/applicationSettings.tsx | 26 +++++++++++++++++-- src/helpers/use-downloader.ts | 12 +++++++-- src/services/store.ts | 4 +++ src/types/settings.ts | 2 ++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/components/pages/settings/applicationSettings.tsx b/src/components/pages/settings/applicationSettings.tsx index 403b262..4d125ae 100644 --- a/src/components/pages/settings/applicationSettings.tsx +++ b/src/components/pages/settings/applicationSettings.tsx @@ -282,7 +282,7 @@ function AppAppearanceSettings() { ); } -function AppFolderSettings() { +function AppFilesystemSettings() { const { saveSettingsKey } = useSettings(); const isFlatpak = useEnvironmentStore(state => state.isFlatpak); @@ -295,6 +295,8 @@ function AppFolderSettings() { const setPath = useBasePathsStore((state) => state.setPath); const filenameTemplate = useSettingsPageStatesStore(state => state.settings.filename_template); + const windowsFilenames = useSettingsPageStatesStore(state => state.settings.windows_filenames); + const restrictFilenames = useSettingsPageStatesStore(state => state.settings.restrict_filenames); const downloadStates = useDownloadStatesStore(state => state.downloadStates); const ongoingDownloads = downloadStates.filter(state => @@ -448,6 +450,26 @@ function AppFolderSettings() { +
+

Sanitize Filenames

+

Make filenames windows-compatible, allow only ASCII characters and replace spaces with underscore (recommended, disabling it may cause issue with some downloads, also it may cause paused downloads to re-start from begining)

+
+ saveSettingsKey('windows_filenames', checked)} + /> + +
+
+ saveSettingsKey('restrict_filenames', checked)} + /> + +
+
); } @@ -1933,7 +1955,7 @@ export function ApplicationSettings() { const tabsList = [ { key: 'general', label: 'General', icon: Wrench, component: }, { key: 'appearance', label: 'Appearance', icon: WandSparkles, component: }, - { key: 'folders', label: 'Folders', icon: Folder, component: }, + { key: 'filesystem', label: 'Filesystem', icon: Folder, component: }, { key: 'formats', label: 'Formats', icon: FileVideo, component: }, { key: 'embedding', label: 'Embedding', icon: FilePen, component: }, { key: 'network', label: 'Network', icon: Wifi, component: }, diff --git a/src/helpers/use-downloader.ts b/src/helpers/use-downloader.ts index 670e916..fca60ee 100644 --- a/src/helpers/use-downloader.ts +++ b/src/helpers/use-downloader.ts @@ -72,6 +72,8 @@ export default function useDownloader() { use_potoken: USE_POTOKEN, disable_innertube: DISABLE_INNERTUBE, pot_server_port: POT_SERVER_PORT, + windows_filenames: WINDOWS_FILENAMES, + restrict_filenames: RESTRICT_FILENAMES } = useSettingsPageStatesStore(state => state.settings); const isRunningPotServer = useSettingsPageStatesStore(state => state.isRunningPotServer); @@ -332,8 +334,6 @@ export default function useDownloader() { `temp:${tempDownloadDirPath}`, '--paths', `home:${downloadDirPath}`, - '--windows-filenames', - '--restrict-filenames', '--exec', 'after_move:echo Finalpath: {}', '--no-mtime', @@ -351,6 +351,14 @@ export default function useDownloader() { args.push('--output', `${FILENAME_TEMPLATE}[${downloadId}].%(ext)s`); } + if (WINDOWS_FILENAMES) { + args.push('--windows-filenames'); + } + + if (RESTRICT_FILENAMES) { + args.push('--restrict-filenames'); + } + if ((!USE_CUSTOM_COMMANDS && !resumeState?.custom_command) && USE_DELAY) { if (!DELAY_PLAYLIST_ONLY) { if (DELAY_MODE === 'auto') { diff --git a/src/services/store.ts b/src/services/store.ts index 277a87c..74170ca 100644 --- a/src/services/store.ts +++ b/src/services/store.ts @@ -221,6 +221,8 @@ export const useSettingsPageStatesStore = create((set) use_potoken: false, disable_innertube: false, pot_server_port: 4416, + windows_filenames: true, + restrict_filenames: true, // extension settings websocket_port: 53511 }, @@ -306,6 +308,8 @@ export const useSettingsPageStatesStore = create((set) use_potoken: false, disable_innertube: false, pot_server_port: 4416, + windows_filenames: true, + restrict_filenames: true, // extension settings websocket_port: 53511 }, diff --git a/src/types/settings.ts b/src/types/settings.ts index ce4d009..900fc2c 100644 --- a/src/types/settings.ts +++ b/src/types/settings.ts @@ -64,6 +64,8 @@ export interface Settings { use_potoken: boolean; disable_innertube: boolean; pot_server_port: number; + windows_filenames: boolean; + restrict_filenames: boolean; // extension settings websocket_port: number; }