1
1
mirror of https://github.com/neosubhamoy/neodlp.git synced 2026-03-22 10:15:50 +05:30

feat: added filename sanitization settings #16 #19

This commit is contained in:
2026-03-20 15:20:04 +05:30
Verified
parent 944560dc4f
commit bd21650394
4 changed files with 40 additions and 4 deletions

View File

@@ -282,7 +282,7 @@ function AppAppearanceSettings() {
); );
} }
function AppFolderSettings() { function AppFilesystemSettings() {
const { saveSettingsKey } = useSettings(); const { saveSettingsKey } = useSettings();
const isFlatpak = useEnvironmentStore(state => state.isFlatpak); const isFlatpak = useEnvironmentStore(state => state.isFlatpak);
@@ -295,6 +295,8 @@ function AppFolderSettings() {
const setPath = useBasePathsStore((state) => state.setPath); const setPath = useBasePathsStore((state) => state.setPath);
const filenameTemplate = useSettingsPageStatesStore(state => state.settings.filename_template); 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 downloadStates = useDownloadStatesStore(state => state.downloadStates);
const ongoingDownloads = downloadStates.filter(state => const ongoingDownloads = downloadStates.filter(state =>
@@ -448,6 +450,26 @@ function AppFolderSettings() {
</form> </form>
</Form> </Form>
</div> </div>
<div className="sanitize-filenames">
<h3 className="font-semibold">Sanitize Filenames</h3>
<p className="text-xs text-muted-foreground mb-3">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)</p>
<div className="flex items-center space-x-2 mb-3">
<Switch
id="windows-filenames"
checked={windowsFilenames}
onCheckedChange={(checked) => saveSettingsKey('windows_filenames', checked)}
/>
<Label htmlFor="windows-filenames">Windows Compatibility</Label>
</div>
<div className="flex items-center space-x-2">
<Switch
id="restrict-filenames"
checked={restrictFilenames}
onCheckedChange={(checked) => saveSettingsKey('restrict_filenames', checked)}
/>
<Label htmlFor="restrict-filenames">Force ASCII Only</Label>
</div>
</div>
</> </>
); );
} }
@@ -1933,7 +1955,7 @@ export function ApplicationSettings() {
const tabsList = [ const tabsList = [
{ key: 'general', label: 'General', icon: Wrench, component: <AppGeneralSettings /> }, { key: 'general', label: 'General', icon: Wrench, component: <AppGeneralSettings /> },
{ key: 'appearance', label: 'Appearance', icon: WandSparkles, component: <AppAppearanceSettings /> }, { key: 'appearance', label: 'Appearance', icon: WandSparkles, component: <AppAppearanceSettings /> },
{ key: 'folders', label: 'Folders', icon: Folder, component: <AppFolderSettings /> }, { key: 'filesystem', label: 'Filesystem', icon: Folder, component: <AppFilesystemSettings /> },
{ key: 'formats', label: 'Formats', icon: FileVideo, component: <AppFormatSettings /> }, { key: 'formats', label: 'Formats', icon: FileVideo, component: <AppFormatSettings /> },
{ key: 'embedding', label: 'Embedding', icon: FilePen, component: <AppEmbeddingSettings /> }, { key: 'embedding', label: 'Embedding', icon: FilePen, component: <AppEmbeddingSettings /> },
{ key: 'network', label: 'Network', icon: Wifi, component: <AppNetworkSettings /> }, { key: 'network', label: 'Network', icon: Wifi, component: <AppNetworkSettings /> },

View File

@@ -72,6 +72,8 @@ export default function useDownloader() {
use_potoken: USE_POTOKEN, use_potoken: USE_POTOKEN,
disable_innertube: DISABLE_INNERTUBE, disable_innertube: DISABLE_INNERTUBE,
pot_server_port: POT_SERVER_PORT, pot_server_port: POT_SERVER_PORT,
windows_filenames: WINDOWS_FILENAMES,
restrict_filenames: RESTRICT_FILENAMES
} = useSettingsPageStatesStore(state => state.settings); } = useSettingsPageStatesStore(state => state.settings);
const isRunningPotServer = useSettingsPageStatesStore(state => state.isRunningPotServer); const isRunningPotServer = useSettingsPageStatesStore(state => state.isRunningPotServer);
@@ -332,8 +334,6 @@ export default function useDownloader() {
`temp:${tempDownloadDirPath}`, `temp:${tempDownloadDirPath}`,
'--paths', '--paths',
`home:${downloadDirPath}`, `home:${downloadDirPath}`,
'--windows-filenames',
'--restrict-filenames',
'--exec', '--exec',
'after_move:echo Finalpath: {}', 'after_move:echo Finalpath: {}',
'--no-mtime', '--no-mtime',
@@ -351,6 +351,14 @@ export default function useDownloader() {
args.push('--output', `${FILENAME_TEMPLATE}[${downloadId}].%(ext)s`); 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 ((!USE_CUSTOM_COMMANDS && !resumeState?.custom_command) && USE_DELAY) {
if (!DELAY_PLAYLIST_ONLY) { if (!DELAY_PLAYLIST_ONLY) {
if (DELAY_MODE === 'auto') { if (DELAY_MODE === 'auto') {

View File

@@ -221,6 +221,8 @@ export const useSettingsPageStatesStore = create<SettingsPageStatesStore>((set)
use_potoken: false, use_potoken: false,
disable_innertube: false, disable_innertube: false,
pot_server_port: 4416, pot_server_port: 4416,
windows_filenames: true,
restrict_filenames: true,
// extension settings // extension settings
websocket_port: 53511 websocket_port: 53511
}, },
@@ -306,6 +308,8 @@ export const useSettingsPageStatesStore = create<SettingsPageStatesStore>((set)
use_potoken: false, use_potoken: false,
disable_innertube: false, disable_innertube: false,
pot_server_port: 4416, pot_server_port: 4416,
windows_filenames: true,
restrict_filenames: true,
// extension settings // extension settings
websocket_port: 53511 websocket_port: 53511
}, },

View File

@@ -64,6 +64,8 @@ export interface Settings {
use_potoken: boolean; use_potoken: boolean;
disable_innertube: boolean; disable_innertube: boolean;
pot_server_port: number; pot_server_port: number;
windows_filenames: boolean;
restrict_filenames: boolean;
// extension settings // extension settings
websocket_port: number; websocket_port: number;
} }