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
2024-01-17 00:19:45 +01:00
<!-- alert for windows install -- >
< widgets -alert v-if ="isWindowsInstall" type="warning" class="my-8 text-base" > Not supported for the Windows install yet < / widgets -alert >
2022-10-02 18:53:53 +02:00
<!-- Merge to m4b -- >
2024-01-17 00:19:45 +01:00
< div v-if ="showM4bDownload && !isWindowsInstall" 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 } }
2022-10-02 18:53:53 +02:00
< span class = "material-icons text-lg ml-2" > launch < / span >
< / u i - b t n >
< / div >
< / div >
< / div >
<!-- Embed Metadata -- >
2024-01-17 00:19:45 +01:00
< div v-if ="mediaTracks.length && !isWindowsInstall" 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 } }
2022-10-02 18:53:53 +02:00
< span class = "material-icons text-lg ml-2" > launch < / span >
< / u i - b t n >
2023-04-02 23:13:18 +02:00
< ui -btn v-if ="!isMetadataEmbedQueued && !isEmbedTaskRunning" class="w-full mt-4" small @click.stop="quickEmbed" > Quick Embed < / 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" >
< p class = "text-lg" > Queued for metadata embed ( { { queuedEmbedLIds . length } } in queue ) < / p >
< / w i d g e t s - a l e r t >
<!-- processing alert -- >
< widgets -alert v-if ="isEmbedTaskRunning" type="warning" class="mt-4" >
< p class = "text-lg" > Currently embedding metadata < / p >
< / w i d g e t s - a l e r t >
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
2024-01-17 00:19:45 +01:00
} ,
isWindowsInstall ( ) {
return this . Source == 'windows'
} ,
Source ( ) {
return this . $store . state . Source
2022-10-02 18:53:53 +02:00
}
} ,
2023-04-02 23:13:18 +02:00
methods : {
quickEmbed ( ) {
const payload = {
message : 'Warning! Quick embed will not backup your audio files. Make sure that you have a backup of your audio files. <br><br>Would you like to continue?' ,
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
}
< / script >