diff --git a/src/modals/insert-template.ts b/src/modals/insert-template.ts index 6bc868f..2d2951f 100644 --- a/src/modals/insert-template.ts +++ b/src/modals/insert-template.ts @@ -27,12 +27,14 @@ export class InsertTemplateModal extends Modal { try { const data = await getVideoData(this.videoUrl, this.plugin.settings); - if (!this.app.vault.getAbstractFileByPath(this.plugin.settings.folder)) { - if (this.plugin.settings.createPaths && !isFolderExists(this.plugin.settings.folder, this.app)) { + if (this.plugin.settings.createPaths && !isFolderExists(this.plugin.settings.folder, this.app)) { + try { await this.app.vault.createFolder(this.plugin.settings.folder); - } else { - throw new Error(`Folder '${this.plugin.settings.folder}' does not exist`); + } catch (err) { + console.warn('Folder already exists'); } + } else { + throw new Error(`Folder '${this.plugin.settings.folder}' does not exist`); } // Create a new file with the title of the video diff --git a/src/utils/parser.ts b/src/utils/parser.ts index aa28e8e..4a9567b 100644 --- a/src/utils/parser.ts +++ b/src/utils/parser.ts @@ -51,7 +51,7 @@ export function parseISODuration(data: string): string { } export function sanitizeFilename(text: string): string { - return text.replace(/[/:*?"<>|#^[\\\]]/g, ''); + return text.replace(/[/:*?"<>#^[\\\]]/g, ''); } export function filterStringData(text: string): string {