mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	remove brading
This commit is contained in:
		
							parent
							
								
									fd84cd0d7f
								
							
						
					
					
						commit
						a2dc76e190
					
				| @ -144,18 +144,20 @@ | ||||
|         <div v-if="!chapterData" class="flex flex-col items-center justify-center p-20"> | ||||
|           <div class="relative"> | ||||
|             <div class="flex items-end space-x-2"> | ||||
|               <ui-text-input-with-label v-model.trim="asinInput" label="ASIN" /> | ||||
|               <ui-dropdown v-model="regionInput" :label="$strings.LabelRegion" small :items="audibleRegions" class="w-32" /> | ||||
|               <ui-btn small color="bg-primary" @click="findChapters">{{ $strings.ButtonSearch }}</ui-btn> | ||||
|               <ui-text-input-with-label v-model.trim="asinInput" label="ASIN" class="flex-3"/> | ||||
|               <ui-dropdown v-model="regionInput" :label="$strings.LabelRegion" small :items="audibleRegions" class="w-32 flex-2" /> | ||||
|               <ui-btn color="bg-primary flex-1" @click="findChapters">{{ $strings.ButtonSearch }}</ui-btn> | ||||
|             </div> | ||||
|             <div class="mt-2"> | ||||
|               <ui-checkbox v-model="removeBranding" label="Remove Audible branding from chapters" small checkbox-bg="bg" label-class="pl-2 text-base text-sm" @click="toggleRemoveBranding" /> | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="absolute left-0 mt-1.5 text-error text-s h-5"> | ||||
|               <p v-if="asinError">{{ asinError }}</p> | ||||
|               <p v-if="asinError">{{ $strings.MessageAsinCheck }}</p> | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="invisible h-5 mt-1 text-xs"></div> | ||||
|             <div class="invisible mt-1 text-xs"></div> | ||||
|           </div> | ||||
| 
 | ||||
|         </div> | ||||
|         <div v-else class="w-full p-4"> | ||||
|           <div class="flex justify-between mb-4"> | ||||
| @ -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, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user