mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-29 10:09:11 +01:00
Merge pull request #1005 from Undergrid/multi_select_quick_match
Multi select quick match
This commit is contained in:
commit
a35b35c062
@ -49,6 +49,9 @@
|
|||||||
<div v-show="numLibraryItemsSelected" class="absolute top-0 left-0 w-full h-full px-4 bg-primary flex items-center">
|
<div v-show="numLibraryItemsSelected" class="absolute top-0 left-0 w-full h-full px-4 bg-primary flex items-center">
|
||||||
<h1 class="text-2xl px-4">{{ numLibraryItemsSelected }} Selected</h1>
|
<h1 class="text-2xl px-4">{{ numLibraryItemsSelected }} Selected</h1>
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
|
<ui-tooltip v-if="userIsAdminOrUp && !isPodcastLibrary" text="Quick Match Selected" direction="bottom">
|
||||||
|
<ui-icon-btn :disabled="processingBatch" icon="auto_awesome" @click="batchAutoMatchClick" class="mx-1.5" />
|
||||||
|
</ui-tooltip>
|
||||||
<ui-tooltip v-if="!isPodcastLibrary" :text="`Mark as ${selectedIsFinished ? 'Not Finished' : 'Finished'}`" direction="bottom">
|
<ui-tooltip v-if="!isPodcastLibrary" :text="`Mark as ${selectedIsFinished ? 'Not Finished' : 'Finished'}`" direction="bottom">
|
||||||
<ui-read-icon-btn :disabled="processingBatch" :is-read="selectedIsFinished" @click="toggleBatchRead" class="mx-1.5" />
|
<ui-read-icon-btn :disabled="processingBatch" :is-read="selectedIsFinished" @click="toggleBatchRead" class="mx-1.5" />
|
||||||
</ui-tooltip>
|
</ui-tooltip>
|
||||||
@ -210,7 +213,10 @@ export default {
|
|||||||
},
|
},
|
||||||
setBookshelfTotalEntities(totalEntities) {
|
setBookshelfTotalEntities(totalEntities) {
|
||||||
this.totalEntities = totalEntities
|
this.totalEntities = totalEntities
|
||||||
}
|
},
|
||||||
|
batchAutoMatchClick() {
|
||||||
|
this.$store.commit('globals/setShowBatchQuickMatchModal', true)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$eventBus.$on('bookshelf-total-entities', this.setBookshelfTotalEntities)
|
this.$eventBus.$on('bookshelf-total-entities', this.setBookshelfTotalEntities)
|
||||||
|
141
client/components/modals/BatchQuickMatchModel.vue
Normal file
141
client/components/modals/BatchQuickMatchModel.vue
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<template>
|
||||||
|
<modals-modal v-model="show" name="batchQuickMatch" :processing="processing" :width="500" :height="'unset'">
|
||||||
|
<template #outer>
|
||||||
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
||||||
|
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div ref="container" class="w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
|
||||||
|
<div v-if="show" class="w-full h-full">
|
||||||
|
<div class="py-4 px-4">
|
||||||
|
<h1 class="text-2xl">Quick Match {{ selectedBookIds.length }} Books</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w-full overflow-y-auto overflow-x-hidden max-h-96">
|
||||||
|
<div class="flex px-8 items-center py-2">
|
||||||
|
<p class="pr-4">Provider</p>
|
||||||
|
<ui-dropdown v-model="options.provider" :items="providers" small />
|
||||||
|
</div>
|
||||||
|
<p class="text-base px-8 py-2">Quick Match will attempt to add missing covers and metadata for the selected books. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.</p>
|
||||||
|
<div class="flex px-8 items-end py-2">
|
||||||
|
<ui-toggle-switch v-model="options.overrideCover"/>
|
||||||
|
<ui-tooltip :text="tooltips.updateCovers">
|
||||||
|
<p class="pl-4">
|
||||||
|
Update Covers
|
||||||
|
<span class="material-icons icon-text text-sm">info_outlined</span>
|
||||||
|
</p>
|
||||||
|
</ui-tooltip>
|
||||||
|
</div>
|
||||||
|
<div class="flex px-8 items-end py-2">
|
||||||
|
<ui-toggle-switch v-model="options.overrideDetails"/>
|
||||||
|
<ui-tooltip :text="tooltips.updateDetails">
|
||||||
|
<p class="pl-4">
|
||||||
|
Update Details
|
||||||
|
<span class="material-icons icon-text text-sm">info_outlined</span>
|
||||||
|
</p>
|
||||||
|
</ui-tooltip>
|
||||||
|
</div>
|
||||||
|
<div class="mt-4 py-4 border-b border-white border-opacity-10 text-white text-opacity-80 border-t border-white border-opacity-5">
|
||||||
|
<div class="flex items-center px-4">
|
||||||
|
<ui-btn type="button" @click="show = false">Cancel</ui-btn>
|
||||||
|
<div class="flex-grow" />
|
||||||
|
<ui-btn color="success" @click="doBatchQuickMatch">Continue</ui-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</modals-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
processing: false,
|
||||||
|
lastUsedLibrary: undefined,
|
||||||
|
options: {
|
||||||
|
provider: undefined,
|
||||||
|
overrideDetails: true,
|
||||||
|
overrideCover: true,
|
||||||
|
overrideDefaults: true
|
||||||
|
},
|
||||||
|
tooltips: {
|
||||||
|
updateCovers: 'Allow overwriting of existing covers for the selected books when a match is located.',
|
||||||
|
updateDetails: 'Allow overwriting of existing details for the selected books when a match is located.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
show: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
show: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.globals.showBatchQuickMatchModal
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.commit('globals/setShowBatchQuickMatchModal', val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title() {
|
||||||
|
return `${this.selectedBookIds.length} Items Selected`
|
||||||
|
},
|
||||||
|
showBatchQuickMatchModal() {
|
||||||
|
return this.$store.state.globals.showBatchQuickMatchModal
|
||||||
|
},
|
||||||
|
selectedBookIds() {
|
||||||
|
return this.$store.state.selectedLibraryItems || []
|
||||||
|
},
|
||||||
|
currentLibraryId() {
|
||||||
|
return this.$store.state.libraries.currentLibraryId
|
||||||
|
},
|
||||||
|
providers() {
|
||||||
|
if (this.isPodcast) return this.$store.state.scanners.podcastProviders
|
||||||
|
return this.$store.state.scanners.providers
|
||||||
|
},
|
||||||
|
libraryProvider() {
|
||||||
|
return this.$store.getters['libraries/getLibraryProvider'](this.currentLibraryId) || 'google'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init() {
|
||||||
|
// If we don't have a set provider (first open of dialog) or we've switched library, set
|
||||||
|
// the selected provider to the current library default provider
|
||||||
|
if (!this.options.provider || (this.options.lastUsedLibrary != this.currentLibraryId)) {
|
||||||
|
this.options.lastUsedLibrary = this.currentLibraryId
|
||||||
|
this.options.provider = this.libraryProvider
|
||||||
|
}
|
||||||
|
},
|
||||||
|
doBatchQuickMatch() {
|
||||||
|
if (!this.selectedBookIds.length) return
|
||||||
|
if (this.processing) return
|
||||||
|
|
||||||
|
this.processing = true
|
||||||
|
this.$store.commit('setProcessingBatch', true)
|
||||||
|
this.$axios
|
||||||
|
.$post(`/api/items/batch/quickmatch`, {
|
||||||
|
options: this.options,
|
||||||
|
libraryItemIds: this.selectedBookIds
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$toast.info('Batch quick match of ' + this.selectedBookIds.length + ' books started!')
|
||||||
|
}).catch((error) => {
|
||||||
|
this.$toast.error('Batch quick match failed')
|
||||||
|
console.error('Failed to batch quick match', error)
|
||||||
|
}).finally(() => {
|
||||||
|
this.processing = false
|
||||||
|
this.$store.commit('setProcessingBatch', false)
|
||||||
|
this.show = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -15,6 +15,7 @@
|
|||||||
<modals-podcast-edit-episode />
|
<modals-podcast-edit-episode />
|
||||||
<modals-podcast-view-episode />
|
<modals-podcast-view-episode />
|
||||||
<modals-authors-edit-modal />
|
<modals-authors-edit-modal />
|
||||||
|
<modals-batch-quick-match-model />
|
||||||
<prompt-confirm />
|
<prompt-confirm />
|
||||||
<readers-reader />
|
<readers-reader />
|
||||||
</div>
|
</div>
|
||||||
@ -358,6 +359,18 @@ export default {
|
|||||||
// Force refresh
|
// Force refresh
|
||||||
location.reload()
|
location.reload()
|
||||||
},
|
},
|
||||||
|
batchQuickMatchComplete(result) {
|
||||||
|
var success = result.success || false
|
||||||
|
var toast = 'Batch quick match complete!\n' + result.updates + ' Updated'
|
||||||
|
if (result.unmatched && (result.unmatched > 0)) {
|
||||||
|
toast += '\n' + result.unmatched + ' with no matches'
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
this.$toast.success(toast)
|
||||||
|
} else {
|
||||||
|
this.$toast.info(toast)
|
||||||
|
}
|
||||||
|
},
|
||||||
initializeSocket() {
|
initializeSocket() {
|
||||||
this.socket = this.$nuxtSocket({
|
this.socket = this.$nuxtSocket({
|
||||||
name: process.env.NODE_ENV === 'development' ? 'dev' : 'prod',
|
name: process.env.NODE_ENV === 'development' ? 'dev' : 'prod',
|
||||||
@ -429,6 +442,8 @@ export default {
|
|||||||
this.socket.on('rss_feed_closed', this.rssFeedClosed)
|
this.socket.on('rss_feed_closed', this.rssFeedClosed)
|
||||||
|
|
||||||
this.socket.on('backup_applied', this.backupApplied)
|
this.socket.on('backup_applied', this.backupApplied)
|
||||||
|
|
||||||
|
this.socket.on('batch_quickmatch_complete', this.batchQuickMatchComplete)
|
||||||
},
|
},
|
||||||
showUpdateToast(versionData) {
|
showUpdateToast(versionData) {
|
||||||
var ignoreVersion = localStorage.getItem('ignoreVersion')
|
var ignoreVersion = localStorage.getItem('ignoreVersion')
|
||||||
|
@ -14,6 +14,7 @@ export const state = () => ({
|
|||||||
selectedAuthor: null,
|
selectedAuthor: null,
|
||||||
isCasting: false, // Actively casting
|
isCasting: false, // Actively casting
|
||||||
isChromecastInitialized: false, // Script loaded
|
isChromecastInitialized: false, // Script loaded
|
||||||
|
showBatchQuickMatchModal: false,
|
||||||
dateFormats: [
|
dateFormats: [
|
||||||
{
|
{
|
||||||
text: 'MM/DD/YYYY',
|
text: 'MM/DD/YYYY',
|
||||||
@ -108,5 +109,8 @@ export const mutations = {
|
|||||||
},
|
},
|
||||||
setCasting(state, val) {
|
setCasting(state, val) {
|
||||||
state.isCasting = val
|
state.isCasting = val
|
||||||
|
},
|
||||||
|
setShowBatchQuickMatchModal(state, val) {
|
||||||
|
state.showBatchQuickMatchModal = val
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -305,6 +305,42 @@ class LibraryItemController {
|
|||||||
res.json(libraryItems)
|
res.json(libraryItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// POST: api/items/batch/quickmatch
|
||||||
|
async batchQuickMatch(req, res) {
|
||||||
|
if (!req.user.isAdminOrUp) {
|
||||||
|
Logger.warn('User other than admin attempted to batch quick match library items', req.user)
|
||||||
|
return res.sendStatus(403)
|
||||||
|
}
|
||||||
|
|
||||||
|
var itemsUpdated = 0
|
||||||
|
var itemsUnmatched = 0
|
||||||
|
|
||||||
|
var matchData = req.body
|
||||||
|
var options = matchData.options || {}
|
||||||
|
var items = matchData.libraryItemIds
|
||||||
|
if (!items || !items.length) {
|
||||||
|
return res.sendStatus(500)
|
||||||
|
}
|
||||||
|
res.sendStatus(200)
|
||||||
|
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
var libraryItem = this.db.libraryItems.find(_li => _li.id === items[i])
|
||||||
|
var matchResult = await this.scanner.quickMatchLibraryItem(libraryItem, options)
|
||||||
|
if (matchResult.updated) {
|
||||||
|
itemsUpdated++
|
||||||
|
} else if (matchResult.warning) {
|
||||||
|
itemsUnmatched++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = {
|
||||||
|
success: itemsUpdated > 0,
|
||||||
|
updates: itemsUpdated,
|
||||||
|
unmatched: itemsUnmatched
|
||||||
|
}
|
||||||
|
this.clientEmitter(req.user.id, 'batch_quickmatch_complete', result)
|
||||||
|
}
|
||||||
|
|
||||||
// DELETE: api/items/all
|
// DELETE: api/items/all
|
||||||
async deleteAll(req, res) {
|
async deleteAll(req, res) {
|
||||||
if (!req.user.isAdminOrUp) {
|
if (!req.user.isAdminOrUp) {
|
||||||
|
@ -103,6 +103,7 @@ class ApiRouter {
|
|||||||
this.router.post('/items/batch/delete', LibraryItemController.batchDelete.bind(this))
|
this.router.post('/items/batch/delete', LibraryItemController.batchDelete.bind(this))
|
||||||
this.router.post('/items/batch/update', LibraryItemController.batchUpdate.bind(this))
|
this.router.post('/items/batch/update', LibraryItemController.batchUpdate.bind(this))
|
||||||
this.router.post('/items/batch/get', LibraryItemController.batchGet.bind(this))
|
this.router.post('/items/batch/get', LibraryItemController.batchGet.bind(this))
|
||||||
|
this.router.post('/items/batch/quickmatch', LibraryItemController.batchQuickMatch.bind(this))
|
||||||
|
|
||||||
//
|
//
|
||||||
// User Routes
|
// User Routes
|
||||||
|
@ -675,9 +675,11 @@ class Scanner {
|
|||||||
var provider = options.provider || 'google'
|
var provider = options.provider || 'google'
|
||||||
var searchTitle = options.title || libraryItem.media.metadata.title
|
var searchTitle = options.title || libraryItem.media.metadata.title
|
||||||
var searchAuthor = options.author || libraryItem.media.metadata.authorName
|
var searchAuthor = options.author || libraryItem.media.metadata.authorName
|
||||||
|
var overrideDefaults = options.overrideDefaults || false
|
||||||
|
|
||||||
// Set to override existing metadata if scannerPreferMatchedMetadata setting is true
|
// Set to override existing metadata if scannerPreferMatchedMetadata setting is true and
|
||||||
if (this.db.serverSettings.scannerPreferMatchedMetadata) {
|
// the overrideDefaults option is not set or set to false.
|
||||||
|
if ((overrideDefaults == false) && (this.db.serverSettings.scannerPreferMatchedMetadata)) {
|
||||||
options.overrideCover = true
|
options.overrideCover = true
|
||||||
options.overrideDetails = true
|
options.overrideDetails = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user