From fa050b2f395f74adf27ab92bc5c8107e2a650172 Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Tue, 26 May 2026 21:08:21 +0530 Subject: [PATCH] feat: added option to remove download id from filename #35 --- .../pages/settings/applicationSettings.tsx | 10 ++++++++++ src/helpers/use-downloader.ts | 15 ++++++++++++--- src/services/store.ts | 6 ++++-- src/types/settings.ts | 1 + 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/components/pages/settings/applicationSettings.tsx b/src/components/pages/settings/applicationSettings.tsx index ba77367..b0ea497 100644 --- a/src/components/pages/settings/applicationSettings.tsx +++ b/src/components/pages/settings/applicationSettings.tsx @@ -309,6 +309,7 @@ function AppFilesystemSettings() { 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 uniqueFilenames = useSettingsPageStatesStore(state => state.settings.unique_filenames); const downloadStates = useDownloadStatesStore(state => state.downloadStates); const ongoingDownloads = downloadStates.filter(state => @@ -462,6 +463,15 @@ function AppFilesystemSettings() { +
+

Unique Filenames

+

Make filenames unique by appending download ID, playlist index at the end of the filename (recommended, disabling it may cause issue with some downloads, also it may cause paused downloads to re-start from begining)

+ saveSettingsKey('unique_filenames', checked)} + /> +

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)

diff --git a/src/helpers/use-downloader.ts b/src/helpers/use-downloader.ts index 19c7b20..49d48dc 100644 --- a/src/helpers/use-downloader.ts +++ b/src/helpers/use-downloader.ts @@ -74,7 +74,8 @@ export default function useDownloader() { disable_innertube: DISABLE_INNERTUBE, pot_server_port: POT_SERVER_PORT, windows_filenames: WINDOWS_FILENAMES, - restrict_filenames: RESTRICT_FILENAMES + restrict_filenames: RESTRICT_FILENAMES, + unique_filenames: UNIQUE_FILENAMES, } = useSettingsPageStatesStore(state => state.settings); const isRunningPotServer = useSettingsPageStatesStore(state => state.isRunningPotServer); @@ -349,9 +350,17 @@ export default function useDownloader() { } if (isMultiplePlaylistItems) { - args.push('--output', `%(playlist_title|Unknown)s[${downloadId}]/[%(playlist_index|0)d]_${FILENAME_TEMPLATE}.%(ext)s`); + if (UNIQUE_FILENAMES) { + args.push('--output', `%(playlist_title|Untitled)s[${downloadId}]/[%(playlist_index|0)d]_${FILENAME_TEMPLATE}.%(ext)s`); + } else { + args.push('--output', `%(playlist_title|Untitled)s/${FILENAME_TEMPLATE}.%(ext)s`); + } } else { - args.push('--output', `${FILENAME_TEMPLATE}[${downloadId}].%(ext)s`); + if (UNIQUE_FILENAMES) { + args.push('--output', `${FILENAME_TEMPLATE}[${downloadId}].%(ext)s`); + } else { + args.push('--output', `${FILENAME_TEMPLATE}.%(ext)s`); + } } if (WINDOWS_FILENAMES) { diff --git a/src/services/store.ts b/src/services/store.ts index 5f0f89a..888ae76 100644 --- a/src/services/store.ts +++ b/src/services/store.ts @@ -204,7 +204,7 @@ export const useSettingsPageStatesStore = create((set) force_internet_protocol: 'ipv4', use_custom_commands: false, custom_commands: [], - filename_template: '%(title|Unknown)s_%(resolution|unknown)s', + filename_template: '%(title|Untitled)s_%(resolution|unknown)s', debug_mode: false, log_verbose: true, log_progress: false, @@ -223,6 +223,7 @@ export const useSettingsPageStatesStore = create((set) pot_server_port: 4416, windows_filenames: true, restrict_filenames: true, + unique_filenames: true, quit_on_close: false, // extension settings websocket_port: 53511 @@ -292,7 +293,7 @@ export const useSettingsPageStatesStore = create((set) force_internet_protocol: 'ipv4', use_custom_commands: false, custom_commands: [], - filename_template: '%(title|Unknown)s_%(resolution|unknown)s', + filename_template: '%(title|Untitled)s_%(resolution|unknown)s', debug_mode: false, log_verbose: true, log_progress: false, @@ -311,6 +312,7 @@ export const useSettingsPageStatesStore = create((set) pot_server_port: 4416, windows_filenames: true, restrict_filenames: true, + unique_filenames: true, quit_on_close: false, // extension settings websocket_port: 53511 diff --git a/src/types/settings.ts b/src/types/settings.ts index f050f7b..710360e 100644 --- a/src/types/settings.ts +++ b/src/types/settings.ts @@ -66,6 +66,7 @@ export interface Settings { pot_server_port: number; windows_filenames: boolean; restrict_filenames: boolean; + unique_filenames: boolean; quit_on_close: boolean; // extension settings websocket_port: number;