diff --git a/client/src/components/Settings.vue b/client/src/components/Settings.vue index 5593f1fa..f0e12512 100644 --- a/client/src/components/Settings.vue +++ b/client/src/components/Settings.vue @@ -196,6 +196,17 @@ + + +
+ + +
+ @@ -502,6 +513,15 @@ function onSubgenreInput(e: string | null, i: number) { $1t.settings.value.quickTag.genres[i].subgenres = e.split(","); } +/// Enable custom subgenre tag +function enableCustomSubgenreTag(enable: boolean) { + if (enable) { + $1t.settings.value.quickTag.subgenreTag = new FrameName('TCON', 'GENRE', '©gen'); + } else { + $1t.settings.value.quickTag.subgenreTag = undefined; + } +} + function browseQuickTag() { $1t.browse('qt', $1t.settings.value.path); diff --git a/client/src/scripts/quicktag.ts b/client/src/scripts/quicktag.ts index a7fdf30b..9a470763 100644 --- a/client/src/scripts/quicktag.ts +++ b/client/src/scripts/quicktag.ts @@ -303,6 +303,12 @@ class QTTrack implements QuickTagFile { this.custom = this.loadCustom(); // Stupid copy this.originalGenres = JSON.parse(JSON.stringify(this.genres)); + // Add subgenres + if (settings.subgenreTag) { + let subgenres = (this.tags[this.removeAbstractions(settings.subgenreTag.byFormat(this.format))] ?? []); + this.originalGenres.push(...subgenres.filter(g => !this.genres.includes(g))); + this.genres.push(...subgenres.filter(g => !this.genres.includes(g))); + } } @@ -472,10 +478,28 @@ class QTTrack implements QuickTagFile { } // Genre change if (this.genres.join('') != this.originalGenres.join('')) { - changes.push({ - type: 'genre', - value: this.genres - }) + // Subgenre custom tag + if (this.settings.subgenreTag) { + + let subgenres = this.genres.filter((genre) => this.settings.genres.find((g) => g.subgenres.includes(genre))); + let genres = this.genres.filter((g) => !subgenres.includes(g)); + + changes.push({ + type: 'raw', + tag: this.settings.subgenreTag.byFormat(this.format), + value: subgenres + }); + changes.push({ + type: 'genre', + value: genres + }); + + } else { + changes.push({ + type: 'genre', + value: this.genres + }); + } } // Note change diff --git a/client/src/scripts/settings.ts b/client/src/scripts/settings.ts index 853f5094..72abaf08 100644 --- a/client/src/scripts/settings.ts +++ b/client/src/scripts/settings.ts @@ -168,6 +168,9 @@ class QuickTagSettings { } ] + // Custom subgenre tag + subgenreTag?: FrameName; + // Manually load from JSON to restore classes static fromJson(data: any): QuickTagSettings { let qt: QuickTagSettings = Object.assign(new QuickTagSettings(), data); @@ -190,7 +193,8 @@ class QuickTagSettings { return v; }); return c; - }) + }); + qt.subgenreTag = qt.subgenreTag ? FrameName.fromJson(data.subgenreTag) : undefined; return qt; } }