2022-10-02 18:53:53 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full h-full overflow-hidden overflow-y-auto px-4 py-6">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-xl font-semibold mb-2">{{ $strings.HeaderAudiobookTools }}</p>
|
2022-10-02 18:53:53 +02:00
|
|
|
|
|
|
|
<!-- Merge to m4b -->
|
2024-07-02 18:00:03 +02:00
|
|
|
<div v-if="showM4bDownload" class="w-full border border-black-200 p-4 my-8">
|
2022-10-02 18:53:53 +02:00
|
|
|
<div class="flex flex-wrap items-center">
|
|
|
|
<div>
|
2022-11-16 23:11:06 +01:00
|
|
|
<p class="text-lg">{{ $strings.LabelToolsMakeM4b }}</p>
|
|
|
|
<p class="max-w-sm text-sm pt-2 text-gray-300">{{ $strings.LabelToolsMakeM4bDescription }}</p>
|
2022-10-02 18:53:53 +02:00
|
|
|
</div>
|
|
|
|
<div class="flex-grow" />
|
|
|
|
<div>
|
|
|
|
<ui-btn :to="`/audiobook/${libraryItemId}/manage?tool=m4b`" class="flex items-center"
|
2022-11-08 01:27:17 +01:00
|
|
|
>{{ $strings.ButtonOpenManager }}
|
2024-07-08 18:36:37 +02:00
|
|
|
<span class="material-symbols text-lg ml-2">launch</span>
|
2022-10-02 18:53:53 +02:00
|
|
|
</ui-btn>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Embed Metadata -->
|
2024-07-02 18:00:03 +02:00
|
|
|
<div v-if="mediaTracks.length" class="w-full border border-black-200 p-4 my-8">
|
2022-10-02 18:53:53 +02:00
|
|
|
<div class="flex items-center">
|
|
|
|
<div>
|
2022-11-16 23:11:06 +01:00
|
|
|
<p class="text-lg">{{ $strings.LabelToolsEmbedMetadata }}</p>
|
|
|
|
<p class="max-w-sm text-sm pt-2 text-gray-300">{{ $strings.LabelToolsEmbedMetadataDescription }}</p>
|
2022-10-02 18:53:53 +02:00
|
|
|
</div>
|
|
|
|
<div class="flex-grow" />
|
|
|
|
<div>
|
2022-10-02 21:16:17 +02:00
|
|
|
<ui-btn :to="`/audiobook/${libraryItemId}/manage?tool=embed`" class="flex items-center"
|
2022-11-08 01:27:17 +01:00
|
|
|
>{{ $strings.ButtonOpenManager }}
|
2024-07-08 18:36:37 +02:00
|
|
|
<span class="material-symbols text-lg ml-2">launch</span>
|
2022-10-02 18:53:53 +02:00
|
|
|
</ui-btn>
|
2023-04-02 23:13:18 +02:00
|
|
|
|
2024-10-11 06:21:15 +02:00
|
|
|
<ui-btn v-if="!isMetadataEmbedQueued && !isEmbedTaskRunning" class="w-full mt-4" small @click.stop="quickEmbed">{{ $strings.ButtonQuickEmbed }}</ui-btn>
|
2022-10-02 18:53:53 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-02 23:13:18 +02:00
|
|
|
|
|
|
|
<!-- queued alert -->
|
|
|
|
<widgets-alert v-if="isMetadataEmbedQueued" type="warning" class="mt-4">
|
2024-10-11 06:21:15 +02:00
|
|
|
<p class="text-lg">{{ $getString('MessageQuickEmbedQueue', [queuedEmbedLIds.length]) }}</p>
|
2023-04-02 23:13:18 +02:00
|
|
|
</widgets-alert>
|
|
|
|
|
|
|
|
<!-- processing alert -->
|
|
|
|
<widgets-alert v-if="isEmbedTaskRunning" type="warning" class="mt-4">
|
2024-10-11 06:21:15 +02:00
|
|
|
<p class="text-lg">{{ $strings.MessageQuickEmbedInProgress }}</p>
|
2023-04-02 23:13:18 +02:00
|
|
|
</widgets-alert>
|
2022-10-02 18:53:53 +02:00
|
|
|
</div>
|
|
|
|
|
2022-11-09 00:10:08 +01:00
|
|
|
<p v-if="!mediaTracks.length" class="text-lg text-center my-8">{{ $strings.MessageNoAudioTracks }}</p>
|
2022-10-02 18:53:53 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
processing: Boolean,
|
|
|
|
libraryItem: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
libraryItemId() {
|
2023-04-02 23:13:18 +02:00
|
|
|
return this.libraryItem?.id || null
|
2022-10-02 18:53:53 +02:00
|
|
|
},
|
|
|
|
media() {
|
2023-04-02 23:13:18 +02:00
|
|
|
return this.libraryItem?.media || {}
|
2022-10-02 18:53:53 +02:00
|
|
|
},
|
|
|
|
mediaTracks() {
|
|
|
|
return this.media.tracks || []
|
|
|
|
},
|
|
|
|
isSingleM4b() {
|
|
|
|
return this.mediaTracks.length === 1 && this.mediaTracks[0].metadata.ext.toLowerCase() === '.m4b'
|
|
|
|
},
|
|
|
|
chapters() {
|
|
|
|
return this.media.chapters || []
|
|
|
|
},
|
|
|
|
showM4bDownload() {
|
|
|
|
if (!this.mediaTracks.length) return false
|
|
|
|
return !this.isSingleM4b
|
|
|
|
},
|
|
|
|
showMp3Split() {
|
|
|
|
if (!this.mediaTracks.length) return false
|
|
|
|
return this.isSingleM4b && this.chapters.length
|
2023-04-02 23:13:18 +02:00
|
|
|
},
|
|
|
|
queuedEmbedLIds() {
|
|
|
|
return this.$store.state.tasks.queuedEmbedLIds || []
|
|
|
|
},
|
|
|
|
isMetadataEmbedQueued() {
|
|
|
|
return this.queuedEmbedLIds.some((lid) => lid === this.libraryItemId)
|
|
|
|
},
|
|
|
|
tasks() {
|
|
|
|
return this.$store.getters['tasks/getTasksByLibraryItemId'](this.libraryItemId)
|
|
|
|
},
|
|
|
|
embedTask() {
|
|
|
|
return this.tasks.find((t) => t.action === 'embed-metadata')
|
|
|
|
},
|
|
|
|
encodeTask() {
|
|
|
|
return this.tasks.find((t) => t.action === 'encode-m4b')
|
|
|
|
},
|
|
|
|
isEmbedTaskRunning() {
|
|
|
|
return this.embedTask && !this.embedTask?.isFinished
|
|
|
|
},
|
|
|
|
isEncodeTaskRunning() {
|
|
|
|
return this.encodeTask && !this.encodeTask?.isFinished
|
2022-10-02 18:53:53 +02:00
|
|
|
}
|
|
|
|
},
|
2023-04-02 23:13:18 +02:00
|
|
|
methods: {
|
|
|
|
quickEmbed() {
|
|
|
|
const payload = {
|
2024-10-11 06:21:15 +02:00
|
|
|
message: this.$strings.MessageConfirmQuickEmbed,
|
2023-04-02 23:13:18 +02:00
|
|
|
callback: (confirmed) => {
|
|
|
|
if (confirmed) {
|
|
|
|
this.$axios
|
|
|
|
.$post(`/api/tools/item/${this.libraryItemId}/embed-metadata`)
|
|
|
|
.then(() => {
|
|
|
|
console.log('Audio metadata encode started')
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Audio metadata encode failed', error)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
type: 'yesNo'
|
|
|
|
}
|
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
|
|
|
}
|
|
|
|
}
|
2022-10-02 18:53:53 +02:00
|
|
|
}
|
2024-07-02 18:00:03 +02:00
|
|
|
</script>
|