Merge pull request #4274 from advplyr/audiobook_tools_update

Audiobook tools update
This commit is contained in:
advplyr 2025-05-08 17:31:46 -05:00 committed by GitHub
commit df45347690
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 21 deletions

View File

@ -74,19 +74,12 @@ export default {
mediaTracks() { mediaTracks() {
return this.media.tracks || [] return this.media.tracks || []
}, },
isSingleM4b() {
return this.mediaTracks.length === 1 && this.mediaTracks[0].metadata.ext.toLowerCase() === '.m4b'
},
chapters() { chapters() {
return this.media.chapters || [] return this.media.chapters || []
}, },
showM4bDownload() { showM4bDownload() {
if (!this.mediaTracks.length) return false if (!this.mediaTracks.length) return false
return !this.isSingleM4b return true
},
showMp3Split() {
if (!this.mediaTracks.length) return false
return this.isSingleM4b && this.chapters.length
}, },
queuedEmbedLIds() { queuedEmbedLIds() {
return this.$store.state.tasks.queuedEmbedLIds || [] return this.$store.state.tasks.queuedEmbedLIds || []

View File

@ -2,7 +2,14 @@
<div id="page-wrapper" class="bg-bg page p-8 overflow-auto relative" :class="streamLibraryItem ? 'streaming' : ''"> <div id="page-wrapper" class="bg-bg page p-8 overflow-auto relative" :class="streamLibraryItem ? 'streaming' : ''">
<div class="flex items-center justify-center mb-6"> <div class="flex items-center justify-center mb-6">
<div class="w-full max-w-2xl"> <div class="w-full max-w-2xl">
<p class="text-2xl mb-2">{{ $strings.HeaderAudiobookTools }}</p> <div class="flex items-center mb-4">
<nuxt-link :to="`/item/${libraryItem.id}`" class="hover:underline">
<h1 class="text-lg lg:text-xl">{{ mediaMetadata.title }}</h1>
</nuxt-link>
<button class="w-7 h-7 flex items-center justify-center mx-4 hover:scale-110 duration-100 transform text-gray-200 hover:text-white" @click="editItem">
<span class="material-symbols text-base">edit</span>
</button>
</div>
</div> </div>
<div class="w-full max-w-2xl"> <div class="w-full max-w-2xl">
<div class="flex justify-end"> <div class="flex justify-end">
@ -13,7 +20,7 @@
<div class="flex justify-center mb-2"> <div class="flex justify-center mb-2">
<div class="w-full max-w-2xl"> <div class="w-full max-w-2xl">
<p class="text-xl">{{ $strings.HeaderMetadataToEmbed }}</p> <p class="text-lg">{{ $strings.HeaderMetadataToEmbed }}</p>
</div> </div>
<div class="w-full max-w-2xl"></div> <div class="w-full max-w-2xl"></div>
</div> </div>
@ -266,9 +273,6 @@ export default {
audioFiles() { audioFiles() {
return (this.media.audioFiles || []).filter((af) => !af.exclude) return (this.media.audioFiles || []).filter((af) => !af.exclude)
}, },
isSingleM4b() {
return this.audioFiles.length === 1 && this.audioFiles[0].metadata.ext.toLowerCase() === '.m4b'
},
streamLibraryItem() { streamLibraryItem() {
return this.$store.state.streamLibraryItem return this.$store.state.streamLibraryItem
}, },
@ -276,14 +280,10 @@ export default {
return this.media.chapters || [] return this.media.chapters || []
}, },
availableTools() { availableTools() {
if (this.isSingleM4b) { return [
return [{ value: 'embed', text: this.$strings.LabelToolsEmbedMetadata }] { value: 'embed', text: this.$strings.LabelToolsEmbedMetadata },
} else { { value: 'm4b', text: this.$strings.LabelToolsM4bEncoder }
return [ ]
{ value: 'embed', text: this.$strings.LabelToolsEmbedMetadata },
{ value: 'm4b', text: this.$strings.LabelToolsM4bEncoder }
]
}
}, },
taskFailed() { taskFailed() {
return this.isTaskFinished && this.task.isFailed return this.isTaskFinished && this.task.isFailed
@ -431,10 +431,24 @@ export default {
}, },
taskUpdated(task) { taskUpdated(task) {
this.processing = !task.isFinished this.processing = !task.isFinished
},
editItem() {
this.$store.commit('showEditModal', this.libraryItem)
},
libraryItemUpdated(libraryItem) {
if (libraryItem.id === this.libraryItem.id) {
this.libraryItem = libraryItem
this.fetchMetadataEmbedObject()
}
} }
}, },
mounted() { mounted() {
this.init() this.init()
this.$eventBus.$on(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
},
beforeDestroy() {
this.$eventBus.$off(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
} }
} }
</script> </script>