From a2dc76e1902c8664dcfb836a1a13ef5aed38d5ea Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:21:37 +0200 Subject: [PATCH 1/5] remove brading --- client/pages/audiobook/_id/chapters.vue | 51 +++++++++++++++++++++---- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index 55f74b5c..659e4e58 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -144,18 +144,20 @@
- - - {{ $strings.ButtonSearch }} + + + {{ $strings.ButtonSearch }} +
+
+
-

{{ asinError }}

{{ $strings.MessageAsinCheck }}

- - +
+
@@ -261,6 +263,7 @@ export default { showFindChaptersModal: false, chapterData: null, asinError: null, + removeBranding: false, showSecondInputs: false, audibleRegions: ['US', 'CA', 'UK', 'AU', 'FR', 'DE', 'JP', 'IT', 'IN', 'ES'], hasChanges: false @@ -322,6 +325,9 @@ export default { this.checkChapters() }, + toggleRemoveBranding() { + this.removeBranding = !this.removeBranding; + }, shiftChapterTimes() { if (!this.shiftAmount || isNaN(this.shiftAmount) || this.newChapters.length <= 1) { return @@ -568,7 +574,7 @@ export default { this.asinError = this.$getString(data.stringKey) } else { console.log('Chapter data', data) - this.chapterData = data + this.chapterData = this.removeBranding ? this.removeBrandingFromData(data) : data } }) .catch((error) => { @@ -578,6 +584,37 @@ export default { this.showFindChaptersModal = false }) }, + removeBrandingFromData(data) { + if (!data) return data + try { + const introDuration = data.brandIntroDurationMs + const outroDuration = data.brandOutroDurationMs + + for (let i = 0; i < data.chapters.length; i++) { + const chapter = data.chapters[i] + if (chapter.startOffsetMs < introDuration) { + // This should never happen, as the intro is not longer than the first chapter + // If this happens set to the next second + // Will be 0 for the first chapter anayways + chapter.startOffsetMs = i * 1000 + chapter.startOffsetSec = i + } else { + chapter.startOffsetMs -= introDuration + chapter.startOffsetSec = Math.floor(chapter.startOffsetMs / 1000) + } + } + + const lastChapter = data.chapters[data.chapters.length - 1] + // If there is an outro that's in the outro duration, remove it + if (lastChapter && lastChapter.lengthMs <= outroDuration) { + data.chapters.pop() + } + + } catch { + return data + } + return data + }, resetChapters() { const payload = { message: this.$strings.MessageResetChaptersConfirm, From 38957d4f323cceaad92d1751fe2116f426e763f7 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:34:12 +0200 Subject: [PATCH 2/5] fix shift times not works when editing --- client/pages/audiobook/_id/chapters.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index 659e4e58..94602e8d 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -341,8 +341,8 @@ export default { return } - if (this.newChapters[0].end + amount <= 0) { - this.$toast.error('Invalid shift amount. First chapter would have zero or negative length.') + if (this.newChapters[1].start + amount <= 0) { + this.$toast.error('Invalid shift amount. The first chapter would have zero or negative length and would be overwritten by the second chapter. Increase the start duration of second chapter. ') return } From 65aec6a0993f39481b958e02a81d5382f3d76184 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:44:28 +0200 Subject: [PATCH 3/5] Adds locale --- client/pages/audiobook/_id/chapters.vue | 6 +++--- client/strings/en-us.json | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index 94602e8d..3c6fe476 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -149,7 +149,7 @@ {{ $strings.ButtonSearch }}
- +

{{ asinError }}

@@ -337,12 +337,12 @@ export default { const lastChapter = this.newChapters[this.newChapters.length - 1] if (lastChapter.start + amount > this.mediaDurationRounded) { - this.$toast.error('Invalid shift amount. Last chapter start time would extend beyond the duration of this audiobook.') + this.$toast.error($strings.ToastInvalidShiftAmountLast) return } if (this.newChapters[1].start + amount <= 0) { - this.$toast.error('Invalid shift amount. The first chapter would have zero or negative length and would be overwritten by the second chapter. Increase the start duration of second chapter. ') + this.$toast.error($strings.ToastInvalidShiftAmountStart) return } diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 2bf70b53..101ee161 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -530,6 +530,7 @@ "LabelReleaseDate": "Release Date", "LabelRemoveAllMetadataAbs": "Remove all metadata.abs files", "LabelRemoveAllMetadataJson": "Remove all metadata.json files", + "LabelRemoveAudibleBranding": "Remove Audible intro and outro from chapters", "LabelRemoveCover": "Remove cover", "LabelRemoveMetadataFile": "Remove metadata files in library item folders", "LabelRemoveMetadataFileHelp": "Remove all metadata.json and metadata.abs files in your {0} folders.", @@ -998,6 +999,8 @@ "ToastFailedToUpdate": "Failed to update", "ToastInvalidImageUrl": "Invalid image URL", "ToastInvalidMaxEpisodesToDownload": "Invalid max episodes to download", + "ToastInvalidShiftAmountLast": "Invalid shift amount. The last chapter start time would extend beyond the duration of this audiobook.", + "ToastInvalidShiftAmountStart": "Invalid shift amount. The first chapter would have zero or negative length and would be overwritten by the second chapter. Increase the start duration of second chapter.", "ToastInvalidUrl": "Invalid URL", "ToastItemCoverUpdateSuccess": "Item cover updated", "ToastItemDeletedFailed": "Failed to delete item", From a1074e69ac2addcfbb4ab3696587326fb2f20285 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:51:56 +0200 Subject: [PATCH 4/5] Fixed crash --- client/pages/audiobook/_id/chapters.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index 3c6fe476..085b1584 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -337,12 +337,12 @@ export default { const lastChapter = this.newChapters[this.newChapters.length - 1] if (lastChapter.start + amount > this.mediaDurationRounded) { - this.$toast.error($strings.ToastInvalidShiftAmountLast) + this.$toast.error(this.$strings.ToastInvalidShiftAmountLast) return } if (this.newChapters[1].start + amount <= 0) { - this.$toast.error($strings.ToastInvalidShiftAmountStart) + this.$toast.error(this.$strings.ToastInvalidShiftAmountStart) return } From 0df5a7816df88d66088c497565037eb254c4a95f Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 10 May 2025 16:42:34 -0500 Subject: [PATCH 5/5] Update chapter toast strings, update spacing, autoformat --- client/pages/audiobook/_id/chapters.vue | 17 ++++++++--------- client/strings/en-us.json | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index 05a86e0b..a8840744 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -144,11 +144,11 @@
- - - {{ $strings.ButtonSearch }} + + + {{ $strings.ButtonSearch }}
-
+
@@ -157,7 +157,6 @@
-
@@ -326,7 +325,7 @@ export default { this.checkChapters() }, toggleRemoveBranding() { - this.removeBranding = !this.removeBranding; + this.removeBranding = !this.removeBranding }, shiftChapterTimes() { if (!this.shiftAmount || isNaN(this.shiftAmount) || this.newChapters.length <= 1) { @@ -337,12 +336,12 @@ export default { const lastChapter = this.newChapters[this.newChapters.length - 1] if (lastChapter.start + amount > this.mediaDurationRounded) { - this.$toast.error(this.$strings.ToastInvalidShiftAmountLast) + this.$toast.error(this.$strings.ToastChaptersInvalidShiftAmountLast) return } if (this.newChapters[1].start + amount <= 0) { - this.$toast.error(this.$strings.ToastInvalidShiftAmountStart) + this.$toast.error(this.$strings.ToastChaptersInvalidShiftAmountStart) return } @@ -610,10 +609,10 @@ export default { data.chapters.pop() } + return data } catch { return data } - return data }, resetChapters() { const payload = { diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 8ef7f24c..4c07609e 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -973,6 +973,8 @@ "ToastCachePurgeFailed": "Failed to purge cache", "ToastCachePurgeSuccess": "Cache purged successfully", "ToastChaptersHaveErrors": "Chapters have errors", + "ToastChaptersInvalidShiftAmountLast": "Invalid shift amount. The last chapter start time would extend beyond the duration of this audiobook.", + "ToastChaptersInvalidShiftAmountStart": "Invalid shift amount. The first chapter would have zero or negative length and would be overwritten by the second chapter. Increase the start duration of second chapter.", "ToastChaptersMustHaveTitles": "Chapters must have titles", "ToastChaptersRemoved": "Chapters removed", "ToastChaptersUpdated": "Chapters updated", @@ -1000,8 +1002,6 @@ "ToastFailedToUpdate": "Failed to update", "ToastInvalidImageUrl": "Invalid image URL", "ToastInvalidMaxEpisodesToDownload": "Invalid max episodes to download", - "ToastInvalidShiftAmountLast": "Invalid shift amount. The last chapter start time would extend beyond the duration of this audiobook.", - "ToastInvalidShiftAmountStart": "Invalid shift amount. The first chapter would have zero or negative length and would be overwritten by the second chapter. Increase the start duration of second chapter.", "ToastInvalidUrl": "Invalid URL", "ToastItemCoverUpdateSuccess": "Item cover updated", "ToastItemDeletedFailed": "Failed to delete item",