2021-08-18 00:01:11 +02:00
|
|
|
<template>
|
2022-08-04 01:27:38 +02:00
|
|
|
<div id="match-wrapper" class="w-full h-full overflow-hidden px-2 md:px-4 py-4 md:py-6 relative">
|
2021-08-21 16:15:44 +02:00
|
|
|
<form @submit.prevent="submitSearch">
|
2022-08-04 01:27:38 +02:00
|
|
|
<div class="flex flex-wrap md:flex-nowrap items-center justify-start -mx-1">
|
|
|
|
<div class="w-36 px-1">
|
2021-10-28 21:41:42 +02:00
|
|
|
<ui-dropdown v-model="provider" :items="providers" label="Provider" small />
|
|
|
|
</div>
|
2022-08-04 01:27:38 +02:00
|
|
|
<div class="flex-grow md:w-72 px-1">
|
2022-03-07 00:26:35 +01:00
|
|
|
<ui-text-input-with-label v-model="searchTitle" :label="searchTitleLabel" placeholder="Search" />
|
2021-08-21 16:15:44 +02:00
|
|
|
</div>
|
2022-08-04 01:27:38 +02:00
|
|
|
<div v-show="provider != 'itunes'" class="w-60 md:w-72 px-1">
|
2021-10-28 21:41:42 +02:00
|
|
|
<ui-text-input-with-label v-model="searchAuthor" label="Author" />
|
2021-08-21 16:15:44 +02:00
|
|
|
</div>
|
|
|
|
<ui-btn class="mt-5 ml-1" type="submit">Search</ui-btn>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
2021-08-21 16:15:44 +02:00
|
|
|
</form>
|
2021-08-18 00:01:11 +02:00
|
|
|
<div v-show="processing" class="flex h-full items-center justify-center">
|
|
|
|
<p>Loading...</p>
|
|
|
|
</div>
|
2021-08-21 23:23:35 +02:00
|
|
|
<div v-show="!processing && !searchResults.length && hasSearched" class="flex h-full items-center justify-center">
|
2021-08-18 13:50:24 +02:00
|
|
|
<p>No Results</p>
|
|
|
|
</div>
|
2022-08-04 01:27:38 +02:00
|
|
|
<div v-show="!processing" class="w-full max-h-full overflow-y-auto overflow-x-hidden matchListWrapper mt-4">
|
2021-08-18 00:01:11 +02:00
|
|
|
<template v-for="(res, index) in searchResults">
|
2022-04-14 01:13:39 +02:00
|
|
|
<cards-book-match-card :key="index" :book="res" :is-podcast="isPodcast" :book-cover-aspect-ratio="bookCoverAspectRatio" @select="selectMatch" />
|
2021-08-18 00:01:11 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig" class="absolute top-0 left-0 w-full bg-bg h-full px-2 py-6 md:p-8 max-h-full overflow-y-auto overflow-x-hidden">
|
2022-08-16 01:00:11 +02:00
|
|
|
<div class="flex mb-4">
|
2022-10-01 23:51:22 +02:00
|
|
|
<div class="w-8 h-8 rounded-full hover:bg-white hover:bg-opacity-10 flex items-center justify-center cursor-pointer" @click="clearSelectedMatch">
|
2021-10-28 21:41:42 +02:00
|
|
|
<span class="material-icons text-3xl">arrow_back</span>
|
|
|
|
</div>
|
|
|
|
<p class="text-xl pl-3">Update Book Details</p>
|
|
|
|
</div>
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectAll" checkbox-bg="bg" @input="selectAllToggled" />
|
2021-10-28 21:41:42 +02:00
|
|
|
<form @submit.prevent="submitMatchUpdate">
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.cover" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.cover" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-08-16 00:44:58 +02:00
|
|
|
<ui-text-input-with-label v-model="selectedMatch.cover" :disabled="!selectedMatchUsage.cover" readonly label="Cover" class="flex-grow mx-4" />
|
|
|
|
<div class="min-w-12 max-w-12 md:min-w-16 md:max-w-16">
|
|
|
|
<a :href="selectedMatch.cover" target="_blank" class="w-full bg-primary">
|
|
|
|
<img :src="selectedMatch.cover" class="h-full w-full object-contain" />
|
|
|
|
</a>
|
|
|
|
</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.title" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.title" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.title" :disabled="!selectedMatchUsage.title" label="Title" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.title" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.title || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.subtitle" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.subtitle" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.subtitle" :disabled="!selectedMatchUsage.subtitle" label="Subtitle" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.subtitle" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.subtitle || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.author" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.author" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.author" :disabled="!selectedMatchUsage.author" label="Author" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.authorName" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.authorName || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.narrator" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.narrator" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.narrator" :disabled="!selectedMatchUsage.narrator" label="Narrator" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.narratorName" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.narratorName || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2021-11-21 19:59:32 +01:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.description" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.description" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-09-27 23:49:14 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-textarea-with-label v-model="selectedMatch.description" :rows="3" :disabled="!selectedMatchUsage.description" label="Description" />
|
|
|
|
<p v-if="mediaMetadata.description" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.description.substr(0, 100) + (mediaMetadata.description.length > 100 ? '...' : '') }}</p>
|
|
|
|
</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.publisher" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.publisher" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.publisher" :disabled="!selectedMatchUsage.publisher" label="Publisher" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.publisher" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.publisher || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.publishedYear" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.publishedYear" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.publishedYear" :disabled="!selectedMatchUsage.publishedYear" label="Published Year" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.publishedYear" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.publishedYear || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2021-10-28 21:41:42 +02:00
|
|
|
</div>
|
2022-01-10 01:37:16 +01:00
|
|
|
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.series" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.series" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
2022-05-28 22:54:04 +02:00
|
|
|
<widgets-series-input-widget v-model="selectedMatch.series" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.seriesName" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.seriesName || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2021-11-21 19:59:32 +01:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.genres && selectedMatchOrig.genres.length" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.genres" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-05-23 04:56:51 +02:00
|
|
|
<div class="flex-grow ml-4">
|
2022-10-01 23:51:22 +02:00
|
|
|
<!-- <ui-text-input-with-label v-model="selectedMatch.genres" :disabled="!selectedMatchUsage.genres" label="Genres" /> -->
|
|
|
|
<ui-multi-select v-model="selectedMatch.genres" :items="selectedMatch.genres" label="Genres" />
|
2022-09-27 23:49:14 +02:00
|
|
|
<p v-if="mediaMetadata.genres" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.genres.join(', ') }}</p>
|
2022-05-23 04:56:51 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.tags" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.tags" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-05-23 04:56:51 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.tags" :disabled="!selectedMatchUsage.tags" label="Tags" />
|
2022-09-27 23:49:14 +02:00
|
|
|
<p v-if="media.tags" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ media.tags.join(', ') }}</p>
|
2022-05-23 04:56:51 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.language" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.language" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-05-23 04:56:51 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.language" :disabled="!selectedMatchUsage.language" label="Language" />
|
|
|
|
<p v-if="mediaMetadata.language" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.language || '' }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.isbn" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.isbn" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.isbn" :disabled="!selectedMatchUsage.isbn" label="ISBN" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.isbn" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.isbn || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2022-01-10 01:37:16 +01:00
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.asin" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.asin" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-01 00:10:02 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.asin" :disabled="!selectedMatchUsage.asin" label="ASIN" />
|
2022-04-03 00:37:44 +02:00
|
|
|
<p v-if="mediaMetadata.asin" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.asin || '' }}</p>
|
2022-04-01 00:10:02 +02:00
|
|
|
</div>
|
2022-01-10 01:37:16 +01:00
|
|
|
</div>
|
2022-04-14 01:13:39 +02:00
|
|
|
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.itunesId" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.itunesId" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-14 01:13:39 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.itunesId" type="number" :disabled="!selectedMatchUsage.itunesId" label="iTunes ID" />
|
|
|
|
<p v-if="mediaMetadata.itunesId" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.itunesId || '' }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.feedUrl" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.feedUrl" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-14 01:13:39 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.feedUrl" :disabled="!selectedMatchUsage.feedUrl" label="RSS Feed URL" />
|
|
|
|
<p v-if="mediaMetadata.feedUrl" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.feedUrl || '' }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.itunesPageUrl" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.itunesPageUrl" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-14 01:13:39 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.itunesPageUrl" :disabled="!selectedMatchUsage.itunesPageUrl" label="iTunes Page URL" />
|
|
|
|
<p v-if="mediaMetadata.itunesPageUrl" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.itunesPageUrl || '' }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-01 23:51:22 +02:00
|
|
|
<div v-if="selectedMatchOrig.releaseDate" class="flex items-center py-2">
|
2022-08-16 01:00:11 +02:00
|
|
|
<ui-checkbox v-model="selectedMatchUsage.releaseDate" checkbox-bg="bg" @input="checkboxToggled" />
|
2022-04-14 01:13:39 +02:00
|
|
|
<div class="flex-grow ml-4">
|
|
|
|
<ui-text-input-with-label v-model="selectedMatch.releaseDate" :disabled="!selectedMatchUsage.releaseDate" label="Release Date" />
|
|
|
|
<p v-if="mediaMetadata.releaseDate" class="text-xs ml-1 text-white text-opacity-60">Currently: {{ mediaMetadata.releaseDate || '' }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-10-28 21:41:42 +02:00
|
|
|
<div class="flex items-center justify-end py-2">
|
|
|
|
<ui-btn color="success" type="submit">Update</ui-btn>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2021-08-18 13:50:24 +02:00
|
|
|
processing: Boolean,
|
2022-03-11 01:45:02 +01:00
|
|
|
libraryItem: {
|
2021-08-18 00:01:11 +02:00
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-03-11 01:45:02 +01:00
|
|
|
libraryItemId: null,
|
2021-08-21 16:15:44 +02:00
|
|
|
searchTitle: null,
|
|
|
|
searchAuthor: null,
|
2021-08-18 00:01:11 +02:00
|
|
|
lastSearch: null,
|
2021-10-28 21:41:42 +02:00
|
|
|
provider: 'google',
|
2021-08-21 23:23:35 +02:00
|
|
|
searchResults: [],
|
2021-10-28 21:41:42 +02:00
|
|
|
hasSearched: false,
|
|
|
|
selectedMatch: null,
|
2022-10-01 23:51:22 +02:00
|
|
|
selectedMatchOrig: null,
|
2021-10-28 21:41:42 +02:00
|
|
|
selectedMatchUsage: {
|
|
|
|
title: true,
|
|
|
|
subtitle: true,
|
|
|
|
cover: true,
|
|
|
|
author: true,
|
2021-11-21 19:59:32 +01:00
|
|
|
narrator: true,
|
2021-10-28 21:41:42 +02:00
|
|
|
description: true,
|
|
|
|
publisher: true,
|
2022-03-14 01:34:31 +01:00
|
|
|
publishedYear: true,
|
2021-11-21 19:59:32 +01:00
|
|
|
series: true,
|
2022-05-28 22:54:04 +02:00
|
|
|
genres: true,
|
|
|
|
tags: true,
|
|
|
|
language: true,
|
2022-05-23 04:56:51 +02:00
|
|
|
explicit: true,
|
2022-01-10 01:37:16 +01:00
|
|
|
asin: true,
|
2022-04-14 01:13:39 +02:00
|
|
|
isbn: true,
|
|
|
|
// Podcast specific
|
|
|
|
itunesPageUrl: true,
|
|
|
|
itunesId: true,
|
|
|
|
feedUrl: true,
|
|
|
|
releaseDate: true
|
2022-08-16 01:00:11 +02:00
|
|
|
},
|
|
|
|
selectAll: true
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2022-03-11 01:45:02 +01:00
|
|
|
libraryItem: {
|
2021-08-18 00:01:11 +02:00
|
|
|
immediate: true,
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-08-18 13:50:24 +02:00
|
|
|
computed: {
|
|
|
|
isProcessing: {
|
|
|
|
get() {
|
|
|
|
return this.processing
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('update:processing', val)
|
|
|
|
}
|
2021-12-03 02:40:42 +01:00
|
|
|
},
|
2022-05-23 04:56:51 +02:00
|
|
|
seriesItems: {
|
|
|
|
get() {
|
|
|
|
return this.selectedMatch.series.map((se) => {
|
|
|
|
return {
|
2022-05-28 22:54:04 +02:00
|
|
|
id: `new-${Math.floor(Math.random() * 10000)}`,
|
2022-10-02 00:01:22 +02:00
|
|
|
displayName: se.sequence ? `${se.series} #${se.sequence}` : se.series,
|
2022-05-28 22:54:04 +02:00
|
|
|
name: se.series,
|
2022-10-02 00:01:22 +02:00
|
|
|
sequence: se.sequence || ''
|
2022-05-23 04:56:51 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.selectedMatch.series = val
|
|
|
|
}
|
|
|
|
},
|
2021-12-03 02:40:42 +01:00
|
|
|
bookCoverAspectRatio() {
|
2022-08-13 20:56:37 +02:00
|
|
|
return this.$store.getters['libraries/getBookCoverAspectRatio']
|
2022-01-09 00:03:33 +01:00
|
|
|
},
|
|
|
|
providers() {
|
2022-04-14 01:13:39 +02:00
|
|
|
if (this.isPodcast) return this.$store.state.scanners.podcastProviders
|
2022-01-09 00:03:33 +01:00
|
|
|
return this.$store.state.scanners.providers
|
2022-03-07 00:26:35 +01:00
|
|
|
},
|
|
|
|
searchTitleLabel() {
|
|
|
|
if (this.provider == 'audible') return 'Search Title or ASIN'
|
|
|
|
else if (this.provider == 'itunes') return 'Search Term'
|
|
|
|
return 'Search Title'
|
2022-04-01 00:10:02 +02:00
|
|
|
},
|
|
|
|
media() {
|
|
|
|
return this.libraryItem ? this.libraryItem.media || {} : {}
|
|
|
|
},
|
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
2022-04-14 01:13:39 +02:00
|
|
|
},
|
|
|
|
mediaType() {
|
|
|
|
return this.libraryItem ? this.libraryItem.mediaType : null
|
|
|
|
},
|
|
|
|
isPodcast() {
|
|
|
|
return this.mediaType == 'podcast'
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
methods: {
|
2022-08-16 01:00:11 +02:00
|
|
|
selectAllToggled(val) {
|
|
|
|
for (const key in this.selectedMatchUsage) {
|
|
|
|
this.selectedMatchUsage[key] = val
|
|
|
|
}
|
|
|
|
},
|
|
|
|
checkboxToggled() {
|
|
|
|
this.selectAll = Object.values(this.selectedMatchUsage).findIndex((v) => v == false) < 0
|
|
|
|
},
|
2021-12-08 01:42:56 +01:00
|
|
|
persistProvider() {
|
|
|
|
try {
|
|
|
|
localStorage.setItem('book-provider', this.provider)
|
|
|
|
} catch (error) {
|
|
|
|
console.error('PersistProvider', error)
|
|
|
|
}
|
|
|
|
},
|
2021-08-21 16:15:44 +02:00
|
|
|
getSearchQuery() {
|
2022-04-14 01:13:39 +02:00
|
|
|
if (this.isPodcast) return `term=${this.searchTitle}`
|
2021-08-26 02:15:00 +02:00
|
|
|
var searchQuery = `provider=${this.provider}&fallbackTitleOnly=1&title=${this.searchTitle}`
|
2021-08-21 16:15:44 +02:00
|
|
|
if (this.searchAuthor) searchQuery += `&author=${this.searchAuthor}`
|
|
|
|
return searchQuery
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
submitSearch() {
|
2021-08-21 16:15:44 +02:00
|
|
|
if (!this.searchTitle) {
|
|
|
|
this.$toast.warning('Search title is required')
|
|
|
|
return
|
|
|
|
}
|
2021-12-08 01:42:56 +01:00
|
|
|
this.persistProvider()
|
2021-08-18 00:01:11 +02:00
|
|
|
this.runSearch()
|
|
|
|
},
|
|
|
|
async runSearch() {
|
2021-08-21 16:15:44 +02:00
|
|
|
var searchQuery = this.getSearchQuery()
|
|
|
|
if (this.lastSearch === searchQuery) return
|
2021-08-18 00:01:11 +02:00
|
|
|
this.searchResults = []
|
2021-08-21 01:29:10 +02:00
|
|
|
this.isProcessing = true
|
2021-08-21 16:15:44 +02:00
|
|
|
this.lastSearch = searchQuery
|
2022-04-14 01:13:39 +02:00
|
|
|
var searchEntity = this.isPodcast ? 'podcast' : 'books'
|
2022-08-04 00:53:19 +02:00
|
|
|
var results = await this.$axios.$get(`/api/search/${searchEntity}?${searchQuery}`, { timeout: 10000 }).catch((error) => {
|
2021-08-18 13:50:24 +02:00
|
|
|
console.error('Failed', error)
|
|
|
|
return []
|
|
|
|
})
|
2022-04-14 01:13:39 +02:00
|
|
|
// console.log('Got search results', results)
|
|
|
|
results = (results || []).filter((res) => {
|
2021-08-18 13:50:24 +02:00
|
|
|
return !!res.title
|
|
|
|
})
|
2022-04-14 01:13:39 +02:00
|
|
|
|
|
|
|
if (this.isPodcast) {
|
|
|
|
// Map to match PodcastMetadata keys
|
|
|
|
results = results.map((res) => {
|
|
|
|
res.itunesPageUrl = res.pageUrl || null
|
|
|
|
res.itunesId = res.id || null
|
|
|
|
res.author = res.artistName || null
|
|
|
|
return res
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
this.searchResults = results || []
|
2021-08-21 01:29:10 +02:00
|
|
|
this.isProcessing = false
|
2021-08-21 23:23:35 +02:00
|
|
|
this.hasSearched = true
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
init() {
|
2022-10-01 23:51:22 +02:00
|
|
|
this.clearSelectedMatch()
|
2021-10-28 21:41:42 +02:00
|
|
|
this.selectedMatchUsage = {
|
|
|
|
title: true,
|
|
|
|
subtitle: true,
|
|
|
|
cover: true,
|
|
|
|
author: true,
|
2021-11-21 19:59:32 +01:00
|
|
|
narrator: true,
|
2021-10-28 21:41:42 +02:00
|
|
|
description: true,
|
|
|
|
publisher: true,
|
2022-03-14 01:34:31 +01:00
|
|
|
publishedYear: true,
|
2021-11-21 19:59:32 +01:00
|
|
|
series: true,
|
2022-05-28 22:54:04 +02:00
|
|
|
genres: true,
|
|
|
|
tags: true,
|
|
|
|
language: true,
|
2022-05-23 04:56:51 +02:00
|
|
|
explicit: true,
|
2022-01-10 01:37:16 +01:00
|
|
|
asin: true,
|
2022-04-14 01:13:39 +02:00
|
|
|
isbn: true,
|
|
|
|
// Podcast specific
|
|
|
|
itunesPageUrl: true,
|
|
|
|
itunesId: true,
|
|
|
|
feedUrl: true,
|
|
|
|
releaseDate: true
|
2021-10-28 21:41:42 +02:00
|
|
|
}
|
|
|
|
|
2022-03-11 01:45:02 +01:00
|
|
|
if (this.libraryItem.id !== this.libraryItemId) {
|
2021-08-21 23:23:35 +02:00
|
|
|
this.searchResults = []
|
|
|
|
this.hasSearched = false
|
2022-03-11 01:45:02 +01:00
|
|
|
this.libraryItemId = this.libraryItem.id
|
2021-08-21 23:23:35 +02:00
|
|
|
}
|
|
|
|
|
2022-03-11 01:45:02 +01:00
|
|
|
if (!this.libraryItem.media || !this.libraryItem.media.metadata.title) {
|
2021-08-21 16:15:44 +02:00
|
|
|
this.searchTitle = null
|
2021-08-21 23:23:35 +02:00
|
|
|
this.searchAuthor = null
|
2021-08-18 00:01:11 +02:00
|
|
|
return
|
|
|
|
}
|
2022-03-11 01:45:02 +01:00
|
|
|
this.searchTitle = this.libraryItem.media.metadata.title
|
|
|
|
this.searchAuthor = this.libraryItem.media.metadata.authorName || ''
|
2022-04-14 01:13:39 +02:00
|
|
|
if (this.isPodcast) this.provider = 'itunes'
|
|
|
|
else this.provider = localStorage.getItem('book-provider') || 'google'
|
2022-08-04 00:53:19 +02:00
|
|
|
|
|
|
|
if (this.searchTitle) {
|
|
|
|
this.submitSearch()
|
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
2021-10-28 21:41:42 +02:00
|
|
|
selectMatch(match) {
|
2022-06-10 00:56:16 +02:00
|
|
|
if (match) {
|
|
|
|
if (match.series) {
|
|
|
|
if (!match.series.length) {
|
|
|
|
delete match.series
|
|
|
|
} else {
|
|
|
|
match.series = match.series.map((se) => {
|
|
|
|
return {
|
|
|
|
id: `new-${Math.floor(Math.random() * 10000)}`,
|
2022-10-02 00:01:22 +02:00
|
|
|
displayName: se.sequence ? `${se.series} #${se.sequence}` : se.series,
|
2022-06-10 00:56:16 +02:00
|
|
|
name: se.series,
|
2022-10-02 00:01:22 +02:00
|
|
|
sequence: se.sequence || ''
|
2022-06-10 00:56:16 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-10-01 23:51:22 +02:00
|
|
|
if (match.genres && !Array.isArray(match.genres)) {
|
|
|
|
// match.genres = match.genres.join(',')
|
|
|
|
match.genres = match.genres.split(',').map((g) => g.trim())
|
2022-06-04 02:21:31 +02:00
|
|
|
}
|
2022-05-28 22:54:04 +02:00
|
|
|
}
|
|
|
|
|
2022-06-10 00:56:16 +02:00
|
|
|
console.log('Select Match', match)
|
2021-10-28 21:41:42 +02:00
|
|
|
this.selectedMatch = match
|
2022-10-01 23:51:22 +02:00
|
|
|
this.selectedMatchOrig = JSON.parse(JSON.stringify(match))
|
2021-10-28 21:41:42 +02:00
|
|
|
},
|
|
|
|
buildMatchUpdatePayload() {
|
|
|
|
var updatePayload = {}
|
2022-05-23 04:56:51 +02:00
|
|
|
updatePayload.metadata = {}
|
2022-03-14 14:12:28 +01:00
|
|
|
|
2021-10-28 21:41:42 +02:00
|
|
|
for (const key in this.selectedMatchUsage) {
|
|
|
|
if (this.selectedMatchUsage[key] && this.selectedMatch[key]) {
|
2022-03-14 14:12:28 +01:00
|
|
|
if (key === 'series') {
|
2022-05-28 22:54:04 +02:00
|
|
|
if (!Array.isArray(this.selectedMatch[key])) {
|
2022-10-02 00:01:22 +02:00
|
|
|
console.error('Invalid series in selectedMatch', this.selectedMatch[key])
|
2022-05-28 22:54:04 +02:00
|
|
|
} else {
|
2022-10-02 00:01:22 +02:00
|
|
|
var seriesPayload = []
|
2022-05-28 22:54:04 +02:00
|
|
|
this.selectedMatch[key].forEach((seriesItem) =>
|
|
|
|
seriesPayload.push({
|
|
|
|
id: seriesItem.id,
|
|
|
|
name: seriesItem.name,
|
|
|
|
sequence: seriesItem.sequence
|
|
|
|
})
|
|
|
|
)
|
2022-10-02 00:01:22 +02:00
|
|
|
updatePayload.metadata.series = seriesPayload
|
2022-05-28 22:54:04 +02:00
|
|
|
}
|
2022-04-14 01:13:39 +02:00
|
|
|
} else if (key === 'author' && !this.isPodcast) {
|
2022-06-10 00:56:16 +02:00
|
|
|
var authors = this.selectedMatch[key]
|
|
|
|
if (!Array.isArray(authors)) {
|
|
|
|
authors = authors.split(',').map((au) => au.trim())
|
2022-06-04 02:21:31 +02:00
|
|
|
}
|
2022-05-23 04:56:51 +02:00
|
|
|
var authorPayload = []
|
2022-06-10 00:56:16 +02:00
|
|
|
authors.forEach((authorName) =>
|
2022-05-28 22:54:04 +02:00
|
|
|
authorPayload.push({
|
|
|
|
id: `new-${Math.floor(Math.random() * 10000)}`,
|
|
|
|
name: authorName
|
|
|
|
})
|
|
|
|
)
|
2022-05-23 04:56:51 +02:00
|
|
|
updatePayload.metadata.authors = authorPayload
|
2022-03-14 14:12:28 +01:00
|
|
|
} else if (key === 'narrator') {
|
2022-06-16 05:23:56 +02:00
|
|
|
updatePayload.metadata.narrators = this.selectedMatch[key].split(',').map((v) => v.trim())
|
2022-05-23 04:56:51 +02:00
|
|
|
} else if (key === 'genres') {
|
2022-10-01 23:51:22 +02:00
|
|
|
// updatePayload.metadata.genres = this.selectedMatch[key].split(',').map((v) => v.trim())
|
|
|
|
updatePayload.metadata.genres = [...this.selectedMatch[key]]
|
2022-05-23 04:56:51 +02:00
|
|
|
} else if (key === 'tags') {
|
2022-06-10 00:56:16 +02:00
|
|
|
updatePayload.tags = this.selectedMatch[key].split(',').map((v) => v.trim())
|
2022-04-14 01:13:39 +02:00
|
|
|
} else if (key === 'itunesId') {
|
2022-05-23 04:56:51 +02:00
|
|
|
updatePayload.metadata.itunesId = Number(this.selectedMatch[key])
|
|
|
|
} else {
|
|
|
|
updatePayload.metadata[key] = this.selectedMatch[key]
|
2022-03-14 14:12:28 +01:00
|
|
|
}
|
2021-10-28 21:41:42 +02:00
|
|
|
}
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
2022-05-28 22:54:04 +02:00
|
|
|
|
2021-10-28 21:41:42 +02:00
|
|
|
return updatePayload
|
|
|
|
},
|
|
|
|
async submitMatchUpdate() {
|
|
|
|
var updatePayload = this.buildMatchUpdatePayload()
|
|
|
|
if (!Object.keys(updatePayload).length) {
|
|
|
|
return
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
2022-06-10 00:56:16 +02:00
|
|
|
|
|
|
|
console.log('Match payload', updatePayload)
|
2021-10-28 21:41:42 +02:00
|
|
|
this.isProcessing = true
|
|
|
|
|
2022-05-30 16:52:42 +02:00
|
|
|
if (updatePayload.metadata.cover) {
|
2021-10-28 21:41:42 +02:00
|
|
|
var coverPayload = {
|
2022-05-23 04:56:51 +02:00
|
|
|
url: updatePayload.metadata.cover
|
2021-10-28 21:41:42 +02:00
|
|
|
}
|
2022-03-14 01:34:31 +01:00
|
|
|
var success = await this.$axios.$post(`/api/items/${this.libraryItemId}/cover`, coverPayload).catch((error) => {
|
2021-10-28 21:41:42 +02:00
|
|
|
console.error('Failed to update', error)
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
if (success) {
|
2022-03-14 14:12:28 +01:00
|
|
|
this.$toast.success('Item Cover Updated')
|
2021-10-28 21:41:42 +02:00
|
|
|
} else {
|
2022-03-14 14:12:28 +01:00
|
|
|
this.$toast.error('Item Cover Failed to Update')
|
2021-10-28 21:41:42 +02:00
|
|
|
}
|
|
|
|
console.log('Updated cover')
|
2022-05-23 04:56:51 +02:00
|
|
|
delete updatePayload.metadata.cover
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
2021-10-28 21:41:42 +02:00
|
|
|
|
|
|
|
if (Object.keys(updatePayload).length) {
|
2022-05-23 04:56:51 +02:00
|
|
|
var mediaUpdatePayload = updatePayload
|
2022-03-14 14:12:28 +01:00
|
|
|
var updateResult = await this.$axios.$patch(`/api/items/${this.libraryItemId}/media`, mediaUpdatePayload).catch((error) => {
|
2021-10-28 21:41:42 +02:00
|
|
|
console.error('Failed to update', error)
|
|
|
|
return false
|
|
|
|
})
|
2022-03-14 14:12:28 +01:00
|
|
|
if (updateResult) {
|
|
|
|
if (updateResult.updated) {
|
|
|
|
this.$toast.success('Item details updated')
|
|
|
|
} else {
|
|
|
|
this.$toast.info('No detail updates were necessary')
|
|
|
|
}
|
2022-10-01 23:51:22 +02:00
|
|
|
this.clearSelectedMatch()
|
2021-10-28 21:41:42 +02:00
|
|
|
this.$emit('selectTab', 'details')
|
|
|
|
} else {
|
2022-03-14 14:12:28 +01:00
|
|
|
this.$toast.error('Item Details Failed to Update')
|
2021-10-28 21:41:42 +02:00
|
|
|
}
|
|
|
|
} else {
|
2022-10-01 23:51:22 +02:00
|
|
|
this.clearSelectedMatch()
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
|
|
|
this.isProcessing = false
|
2022-10-01 23:51:22 +02:00
|
|
|
},
|
|
|
|
clearSelectedMatch() {
|
|
|
|
this.selectedMatch = null
|
|
|
|
this.selectedMatchOrig = null
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
}
|
2021-08-21 16:15:44 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.matchListWrapper {
|
2022-08-04 01:27:38 +02:00
|
|
|
height: calc(100% - 124px);
|
|
|
|
}
|
|
|
|
@media (min-width: 768px) {
|
|
|
|
.matchListWrapper {
|
|
|
|
height: calc(100% - 80px);
|
|
|
|
}
|
2021-08-21 16:15:44 +02:00
|
|
|
}
|
2022-04-03 00:37:44 +02:00
|
|
|
</style>
|