Skip to content

Commit

Permalink
series filename template
Browse files Browse the repository at this point in the history
seperated movie and series filename templates
  • Loading branch information
Superschnizel committed Nov 30, 2023
1 parent b822041 commit c73cfda
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
5 changes: 4 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ export default class Moviegrabber extends Plugin {
return;
}

let title = await this.FillTemplate(this.settings.FilenameTemplate, itemData);
let titleTemplate = type == 'movie'
? this.settings.FilenameTemplateMovie
: this.settings.FilenameTemplateSeries;
let title = await this.FillTemplate(titleTemplate, itemData);
title = title == '' ? item.Title : title;

let path = `${dir}${title.replace(/[/\\?%*:|"<>]/g, '')}.md`
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "moviegrabber",
"name": "Moviegrabber",
"version": "1.1.12",
"version": "1.1.13",
"minAppVersion": "0.15.0",
"description": "Grab movie data from public APIs and transform it into notes that can be used with dataview and properties",
"author": "Superschnizel",
Expand Down
23 changes: 18 additions & 5 deletions src/MoviegrabberSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export interface MoviegrabberSettings {
SeriesTemplatePath: string;

PlotLength: string;
FilenameTemplate: string;
FilenameTemplateMovie: string;
FilenameTemplateSeries: string;
}

export const DEFAULT_SETTINGS: MoviegrabberSettings = {
Expand All @@ -26,7 +27,8 @@ export const DEFAULT_SETTINGS: MoviegrabberSettings = {
MovieTemplatePath: '',
SeriesTemplatePath: '',
PlotLength: 'short',
FilenameTemplate: '{{Title}}'
FilenameTemplateMovie: '{{Title}}',
FilenameTemplateSeries: '{{Title}}'
}

export const DEFAULT_TEMPLATE: string = "---\n"+
Expand Down Expand Up @@ -168,13 +170,24 @@ export class MoviegrabberSettingTab extends PluginSettingTab {
}));

new Setting(containerEl)
.setName('Filename Template')
.setName('Movie filename template')
.setDesc('Template used for the filename of Movienotes. Used same template tags as other files.')
.addText(text => text
.setPlaceholder('')
.setValue(this.plugin.settings.FilenameTemplate)
.setValue(this.plugin.settings.FilenameTemplateMovie)
.onChange(async (value) => {
this.plugin.settings.FilenameTemplate = value;
this.plugin.settings.FilenameTemplateMovie = value;
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Series filename template')
.setDesc('Template used for the filename of Movienotes. Used same template tags as other files.')
.addText(text => text
.setPlaceholder('')
.setValue(this.plugin.settings.FilenameTemplateSeries)
.onChange(async (value) => {
this.plugin.settings.FilenameTemplateSeries = value;
await this.plugin.saveSettings();
}));
}
Expand Down

0 comments on commit c73cfda

Please sign in to comment.