2021-12-04 19:56:29 -06:00
|
|
|
<template>
|
2022-03-23 17:59:14 -05:00
|
|
|
<div ref="card" :id="`book-card-${index}`" :style="{ minWidth: width + 'px', maxWidth: width + 'px', height: height + 'px' }" class="rounded-sm z-10 bg-primary cursor-pointer box-shadow-book" @click="clickCard">
|
2021-12-04 19:56:29 -06:00
|
|
|
<!-- When cover image does not fill -->
|
|
|
|
<div v-show="showCoverBg" class="absolute top-0 left-0 w-full h-full overflow-hidden rounded-sm bg-primary">
|
|
|
|
<div class="absolute cover-bg" ref="coverBg" />
|
|
|
|
</div>
|
|
|
|
|
2022-03-23 17:59:14 -05:00
|
|
|
<!-- Alternative bookshelf title/author/sort -->
|
2022-07-27 18:21:10 -05:00
|
|
|
<div v-if="isAltViewEnabled" class="absolute left-0 z-50 w-full" :style="{ bottom: `-${titleDisplayBottomOffset}rem` }">
|
2022-03-23 17:59:14 -05:00
|
|
|
<p class="truncate" :style="{ fontSize: 0.9 * sizeMultiplier + 'rem' }">
|
|
|
|
{{ displayTitle }}
|
|
|
|
</p>
|
2023-03-03 17:05:23 -06:00
|
|
|
<p class="truncate text-gray-400" :style="{ fontSize: 0.8 * sizeMultiplier + 'rem' }">{{ displayLineTwo || ' ' }}</p>
|
2022-03-23 17:59:14 -05:00
|
|
|
<p v-if="displaySortLine" class="truncate text-gray-400" :style="{ fontSize: 0.8 * sizeMultiplier + 'rem' }">{{ displaySortLine }}</p>
|
2022-07-27 18:21:10 -05:00
|
|
|
</div>
|
2022-03-23 17:59:14 -05:00
|
|
|
|
2023-03-03 17:05:23 -06:00
|
|
|
<div v-if="seriesSequenceList" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-20 text-right" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }" style="background-color: #78350f">
|
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">#{{ seriesSequenceList }}</p>
|
|
|
|
</div>
|
|
|
|
<div v-else-if="booksInSeries" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-20" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }" style="background-color: #cd9d49dd">
|
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">{{ booksInSeries }}</p>
|
|
|
|
</div>
|
2022-03-23 17:59:14 -05:00
|
|
|
|
2021-12-04 19:56:29 -06:00
|
|
|
<div class="w-full h-full absolute top-0 left-0 rounded overflow-hidden z-10">
|
2022-04-03 17:07:26 -05:00
|
|
|
<div v-show="libraryItem && !imageReady" class="absolute top-0 left-0 w-full h-full flex items-center justify-center" :style="{ padding: sizeMultiplier * 0.5 + 'rem' }">
|
2023-02-12 12:16:38 -06:00
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }" class="text-gray-300 text-center">{{ title }}</p>
|
2021-12-04 19:56:29 -06:00
|
|
|
</div>
|
|
|
|
|
2022-04-03 17:07:26 -05:00
|
|
|
<img v-show="libraryItem" ref="cover" :src="bookCoverSrc" class="w-full h-full transition-opacity duration-300" :class="showCoverBg ? 'object-contain' : 'object-fill'" @load="imageLoaded" :style="{ opacity: imageReady ? 1 : 0 }" />
|
2021-12-04 19:56:29 -06:00
|
|
|
|
|
|
|
<!-- Placeholder Cover Title & Author -->
|
|
|
|
<div v-if="!hasCover" class="absolute top-0 left-0 right-0 bottom-0 w-full h-full flex items-center justify-center" :style="{ padding: placeholderCoverPadding + 'rem' }">
|
|
|
|
<div>
|
2023-02-12 12:16:38 -06:00
|
|
|
<p class="text-center" style="color: rgb(247 223 187)" :style="{ fontSize: titleFontSize + 'rem' }">{{ titleCleaned }}</p>
|
2021-12-04 19:56:29 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="!hasCover" class="absolute left-0 right-0 w-full flex items-center justify-center" :style="{ padding: placeholderCoverPadding + 'rem', bottom: authorBottom + 'rem' }">
|
2023-02-12 12:16:38 -06:00
|
|
|
<p class="text-center" style="color: rgb(247 223 187); opacity: 0.75" :style="{ fontSize: authorFontSize + 'rem' }">{{ authorCleaned }}</p>
|
2021-12-04 19:56:29 -06:00
|
|
|
</div>
|
2023-09-10 17:51:53 -05:00
|
|
|
|
|
|
|
<div v-if="showPlayButton" class="absolute -bottom-16 -right-16 rotate-45 w-32 h-32 p-2 bg-gradient-to-r from-transparent to-black to-40% inline-flex justify-start items-center">
|
|
|
|
<div class="hover:text-white text-gray-200 hover:scale-110 transform duration-200 pointer-events-auto -rotate-45" @click.stop.prevent="play">
|
|
|
|
<span class="material-icons" :style="{ fontSize: playIconFontSize + 'rem' }">{{ streamIsPlaying ? 'pause_circle' : 'play_circle_filled' }}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-12-04 19:56:29 -06:00
|
|
|
</div>
|
|
|
|
|
2022-04-24 14:15:37 -05:00
|
|
|
<!-- Play/pause button for podcast episode -->
|
2023-02-25 16:33:06 -06:00
|
|
|
<div v-if="recentEpisode" class="absolute z-10 top-0 left-0 bottom-0 right-0 m-auto flex items-center justify-center w-12 h-12 rounded-full bg-white bg-opacity-70" @click.stop="playEpisode">
|
2022-04-24 14:15:37 -05:00
|
|
|
<span class="material-icons text-6xl text-black text-opacity-80">{{ streamIsPlaying ? 'pause_circle' : 'play_circle_filled' }}</span>
|
|
|
|
</div>
|
|
|
|
|
2022-03-23 17:59:14 -05:00
|
|
|
<!-- No progress shown for collapsed series in library -->
|
2022-04-24 14:15:37 -05:00
|
|
|
<div v-if="!collapsedSeries && (!isPodcast || recentEpisode)" class="absolute bottom-0 left-0 h-1 shadow-sm max-w-full z-10 rounded-b" :class="itemIsFinished ? 'bg-success' : 'bg-yellow-400'" :style="{ width: width * userProgressPercent + 'px' }"></div>
|
2021-12-04 19:56:29 -06:00
|
|
|
|
2023-06-09 17:05:29 -05:00
|
|
|
<!-- Downloaded icon -->
|
2022-08-21 18:03:27 -05:00
|
|
|
<div v-if="showHasLocalDownload" class="absolute right-0 top-0 z-20" :style="{ top: (isPodcast ? 1.75 : 0.375) * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
2022-04-07 18:46:58 -05:00
|
|
|
<span class="material-icons text-2xl text-success">{{ isLocalOnly ? 'task' : 'download_done' }}</span>
|
|
|
|
</div>
|
|
|
|
|
2022-03-23 17:59:14 -05:00
|
|
|
<!-- Error widget -->
|
2022-04-13 20:24:54 -05:00
|
|
|
<div v-if="showError" :style="{ height: 1.5 * sizeMultiplier + 'rem', width: 2.5 * sizeMultiplier + 'rem' }" class="bg-error rounded-r-full shadow-md flex items-center justify-end border-r border-b border-red-300">
|
|
|
|
<span class="material-icons text-red-100 pr-1" :style="{ fontSize: 0.875 * sizeMultiplier + 'rem' }">priority_high</span>
|
|
|
|
</div>
|
2021-12-04 19:56:29 -06:00
|
|
|
|
2023-06-24 14:45:25 -05:00
|
|
|
<!-- rss feed icon -->
|
|
|
|
<div v-if="rssFeed" class="absolute text-success top-0 left-0 z-10" :style="{ padding: 0.375 * sizeMultiplier + 'rem' }">
|
|
|
|
<span class="material-icons" :style="{ fontSize: sizeMultiplier * 1.5 + 'rem' }">rss_feed</span>
|
|
|
|
</div>
|
|
|
|
|
2022-04-24 14:15:37 -05:00
|
|
|
<!-- Series sequence -->
|
2022-04-09 20:29:59 -05:00
|
|
|
<div v-if="seriesSequence && showSequence && !isSelectionMode" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-10" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">#{{ seriesSequence }}</p>
|
|
|
|
</div>
|
|
|
|
|
2022-04-24 14:15:37 -05:00
|
|
|
<!-- Podcast Episode # -->
|
2023-05-19 17:03:54 -05:00
|
|
|
<div v-if="recentEpisodeNumber !== null && !isSelectionMode" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-10" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">
|
|
|
|
Episode<span v-if="recentEpisodeNumber"> #{{ recentEpisodeNumber }}</span>
|
|
|
|
</p>
|
2022-04-24 14:15:37 -05:00
|
|
|
</div>
|
|
|
|
|
2022-04-09 20:29:59 -05:00
|
|
|
<!-- Podcast Num Episodes -->
|
2022-04-24 14:15:37 -05:00
|
|
|
<div v-else-if="numEpisodes && !isSelectionMode" class="absolute rounded-full bg-black bg-opacity-90 box-shadow-md z-10 flex items-center justify-center" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', width: 1.25 * sizeMultiplier + 'rem', height: 1.25 * sizeMultiplier + 'rem' }">
|
2022-04-09 20:29:59 -05:00
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">{{ numEpisodes }}</p>
|
2021-12-04 19:56:29 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-03 17:07:26 -05:00
|
|
|
import { Capacitor } from '@capacitor/core'
|
|
|
|
|
2021-12-04 19:56:29 -06:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
index: Number,
|
|
|
|
width: {
|
|
|
|
type: Number,
|
|
|
|
default: 120
|
|
|
|
},
|
|
|
|
height: {
|
|
|
|
type: Number,
|
|
|
|
default: 192
|
|
|
|
},
|
|
|
|
bookCoverAspectRatio: Number,
|
2022-04-09 20:29:59 -05:00
|
|
|
showSequence: Boolean,
|
2022-07-27 18:21:10 -05:00
|
|
|
isAltViewEnabled: Boolean,
|
2021-12-04 19:56:29 -06:00
|
|
|
bookMount: {
|
2022-03-23 17:59:14 -05:00
|
|
|
// Book can be passed as prop or set with setEntity()
|
2021-12-04 19:56:29 -06:00
|
|
|
type: Object,
|
|
|
|
default: () => null
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
|
|
|
orderBy: String,
|
|
|
|
filterBy: String,
|
|
|
|
sortingIgnorePrefix: Boolean
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isProcessingReadUpdate: false,
|
2022-04-03 17:07:26 -05:00
|
|
|
libraryItem: null,
|
2021-12-04 19:56:29 -06:00
|
|
|
imageReady: false,
|
|
|
|
rescanning: false,
|
|
|
|
selected: false,
|
|
|
|
isSelectionMode: false,
|
2022-04-07 18:46:58 -05:00
|
|
|
showCoverBg: false,
|
|
|
|
localLibraryItem: null
|
2021-12-04 19:56:29 -06:00
|
|
|
}
|
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
watch: {
|
|
|
|
bookMount: {
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) {
|
2022-04-03 17:07:26 -05:00
|
|
|
this.libraryItem = newVal
|
2022-03-23 17:59:14 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-12-04 19:56:29 -06:00
|
|
|
computed: {
|
2022-03-23 17:59:14 -05:00
|
|
|
showExperimentalFeatures() {
|
|
|
|
return this.store.state.showExperimentalFeatures
|
|
|
|
},
|
|
|
|
_libraryItem() {
|
2022-04-03 17:07:26 -05:00
|
|
|
return this.libraryItem || {}
|
|
|
|
},
|
|
|
|
isLocal() {
|
|
|
|
return !!this._libraryItem.isLocal
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-04-07 18:46:58 -05:00
|
|
|
isLocalOnly() {
|
|
|
|
// Local item with no server match
|
|
|
|
return this.isLocal && !this._libraryItem.libraryItemId
|
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
media() {
|
|
|
|
return this._libraryItem.media || {}
|
|
|
|
},
|
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
|
|
|
},
|
2022-04-09 20:29:59 -05:00
|
|
|
mediaType() {
|
|
|
|
return this._libraryItem.mediaType
|
|
|
|
},
|
|
|
|
isPodcast() {
|
|
|
|
return this.mediaType === 'podcast'
|
|
|
|
},
|
2021-12-04 19:56:29 -06:00
|
|
|
placeholderUrl() {
|
|
|
|
return '/book_placeholder.jpg'
|
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
bookCoverSrc() {
|
2022-04-03 17:07:26 -05:00
|
|
|
if (this.isLocal) {
|
2022-04-07 18:46:58 -05:00
|
|
|
if (this.libraryItem.coverContentUrl) return Capacitor.convertFileSrc(this.libraryItem.coverContentUrl)
|
2022-04-03 17:07:26 -05:00
|
|
|
return this.placeholderUrl
|
|
|
|
}
|
2022-03-23 17:59:14 -05:00
|
|
|
return this.store.getters['globals/getLibraryItemCoverSrc'](this._libraryItem, this.placeholderUrl)
|
2021-12-05 18:31:47 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
libraryItemId() {
|
|
|
|
return this._libraryItem.id
|
2021-12-05 18:31:47 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
libraryId() {
|
|
|
|
return this._libraryItem.libraryId
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
hasEbook() {
|
2022-03-28 19:53:53 -05:00
|
|
|
return this.media.ebookFile
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
2022-03-28 19:53:53 -05:00
|
|
|
numTracks() {
|
|
|
|
return this.media.numTracks
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-04-09 20:29:59 -05:00
|
|
|
numEpisodes() {
|
2022-08-21 18:03:27 -05:00
|
|
|
if (this.isLocal && this.isPodcast && this.media.episodes) return this.media.episodes.length
|
2022-04-09 20:29:59 -05:00
|
|
|
return this.media.numEpisodes
|
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
processingBatch() {
|
|
|
|
return this.store.state.processingBatch
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
booksInSeries() {
|
|
|
|
// Only added to audiobook object when collapseSeries is enabled
|
|
|
|
return this._libraryItem.booksInSeries
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
hasCover() {
|
2022-03-23 17:59:14 -05:00
|
|
|
return !!this.media.coverPath
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
squareAspectRatio() {
|
|
|
|
return this.bookCoverAspectRatio === 1
|
|
|
|
},
|
|
|
|
sizeMultiplier() {
|
2022-03-23 17:59:14 -05:00
|
|
|
var baseSize = this.squareAspectRatio ? 192 : 120
|
2021-12-04 19:56:29 -06:00
|
|
|
return this.width / baseSize
|
|
|
|
},
|
|
|
|
title() {
|
2022-03-23 17:59:14 -05:00
|
|
|
return this.mediaMetadata.title || ''
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
playIconFontSize() {
|
|
|
|
return Math.max(2, 3 * this.sizeMultiplier)
|
|
|
|
},
|
|
|
|
authors() {
|
|
|
|
return this.mediaMetadata.authors || []
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
author() {
|
2022-04-09 20:29:59 -05:00
|
|
|
if (this.isPodcast) return this.mediaMetadata.author
|
|
|
|
return this.mediaMetadata.authorName
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
authorLF() {
|
2022-04-09 20:29:59 -05:00
|
|
|
return this.mediaMetadata.authorNameLF
|
|
|
|
},
|
|
|
|
series() {
|
|
|
|
// Only included when filtering by series or collapse series
|
|
|
|
return this.mediaMetadata.series
|
|
|
|
},
|
|
|
|
seriesSequence() {
|
2023-06-19 12:37:44 -05:00
|
|
|
return this.series?.sequence || null
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-04-24 14:15:37 -05:00
|
|
|
recentEpisode() {
|
|
|
|
// Only added to item when getting currently listening podcasts
|
|
|
|
return this._libraryItem.recentEpisode
|
|
|
|
},
|
|
|
|
recentEpisodeNumber() {
|
|
|
|
if (!this.recentEpisode) return null
|
|
|
|
if (this.recentEpisode.episode) {
|
|
|
|
return this.recentEpisode.episode.replace(/^#/, '')
|
|
|
|
}
|
2023-05-19 17:03:54 -05:00
|
|
|
return ''
|
2022-04-24 14:15:37 -05:00
|
|
|
},
|
2022-04-09 20:29:59 -05:00
|
|
|
collapsedSeries() {
|
|
|
|
// Only added to item object when collapseSeries is enabled
|
|
|
|
return this._libraryItem.collapsedSeries
|
|
|
|
},
|
|
|
|
booksInSeries() {
|
|
|
|
// Only added to item object when collapseSeries is enabled
|
2023-06-19 12:37:44 -05:00
|
|
|
return this.collapsedSeries?.numBooks || 0
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
2023-03-03 17:05:23 -06:00
|
|
|
seriesSequenceList() {
|
2023-06-19 12:37:44 -05:00
|
|
|
return this.collapsedSeries?.seriesSequenceList || null
|
2023-03-03 17:05:23 -06:00
|
|
|
},
|
|
|
|
libraryItemIdsInSeries() {
|
|
|
|
// Only added to item object when collapseSeries is enabled
|
2023-06-19 12:37:44 -05:00
|
|
|
return this.collapsedSeries?.libraryItemIds || []
|
2023-03-03 17:05:23 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
displayTitle() {
|
2023-03-02 17:17:49 -06:00
|
|
|
if (this.recentEpisode) return this.recentEpisode.title
|
2023-03-04 14:15:08 -06:00
|
|
|
|
|
|
|
const ignorePrefix = this.orderBy === 'media.metadata.title' && this.sortingIgnorePrefix
|
|
|
|
if (this.collapsedSeries) return ignorePrefix ? this.collapsedSeries.nameIgnorePrefix : this.collapsedSeries.name
|
|
|
|
return ignorePrefix ? this.mediaMetadata.titleIgnorePrefix : this.title
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
2023-03-03 17:05:23 -06:00
|
|
|
displayLineTwo() {
|
|
|
|
if (this.recentEpisode) return this.title
|
|
|
|
if (this.collapsedSeries) return ''
|
|
|
|
if (this.isPodcast) return this.author
|
|
|
|
|
2022-03-23 17:59:14 -05:00
|
|
|
if (this.orderBy === 'media.metadata.authorNameLF') return this.authorLF
|
|
|
|
return this.author
|
|
|
|
},
|
|
|
|
displaySortLine() {
|
2023-03-03 17:05:23 -06:00
|
|
|
if (this.collapsedSeries) return null
|
2022-03-23 17:59:14 -05:00
|
|
|
if (this.orderBy === 'mtimeMs') return 'Modified ' + this.$formatDate(this._libraryItem.mtimeMs)
|
|
|
|
if (this.orderBy === 'birthtimeMs') return 'Born ' + this.$formatDate(this._libraryItem.birthtimeMs)
|
|
|
|
if (this.orderBy === 'addedAt') return 'Added ' + this.$formatDate(this._libraryItem.addedAt)
|
2022-07-30 08:39:50 -05:00
|
|
|
if (this.orderBy === 'media.duration') return 'Duration: ' + this.$elapsedPrettyExtended(this.media.duration, false)
|
2022-03-23 17:59:14 -05:00
|
|
|
if (this.orderBy === 'size') return 'Size: ' + this.$bytesPretty(this._libraryItem.size)
|
2023-03-03 17:05:23 -06:00
|
|
|
if (this.orderBy === 'media.numTracks') return `${this.numEpisodes} Episodes`
|
2022-03-23 17:59:14 -05:00
|
|
|
return null
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-04-24 14:15:37 -05:00
|
|
|
episodeProgress() {
|
|
|
|
// Only used on home page currently listening podcast shelf
|
|
|
|
if (!this.recentEpisode) return null
|
|
|
|
if (this.isLocal) return this.store.getters['globals/getLocalMediaProgressById'](this.libraryItemId, this.recentEpisode.id)
|
|
|
|
return this.store.getters['user/getUserMediaProgress'](this.libraryItemId, this.recentEpisode.id)
|
|
|
|
},
|
2021-12-04 19:56:29 -06:00
|
|
|
userProgress() {
|
2022-08-11 16:49:38 -05:00
|
|
|
if (this.recentEpisode) return this.episodeProgress || null
|
2022-04-09 12:03:37 -05:00
|
|
|
if (this.isLocal) return this.store.getters['globals/getLocalMediaProgressById'](this.libraryItemId)
|
2022-04-08 19:05:32 -05:00
|
|
|
return this.store.getters['user/getUserMediaProgress'](this.libraryItemId)
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2023-03-25 17:40:46 -05:00
|
|
|
useEBookProgress() {
|
|
|
|
if (!this.userProgress || this.userProgress.progress) return false
|
|
|
|
return this.userProgress.ebookProgress > 0
|
|
|
|
},
|
2021-12-04 19:56:29 -06:00
|
|
|
userProgressPercent() {
|
2023-03-25 17:40:46 -05:00
|
|
|
if (this.useEBookProgress) return Math.max(Math.min(1, this.userProgress.ebookProgress), 0)
|
2023-06-24 14:45:25 -05:00
|
|
|
return Math.max(Math.min(1, this.userProgress?.progress || 0), 0) || 0
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
itemIsFinished() {
|
2023-06-24 14:45:25 -05:00
|
|
|
return !!this.userProgress?.isFinished
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
showError() {
|
2022-04-24 14:15:37 -05:00
|
|
|
return this.numMissingParts || this.isMissing || this.isInvalid
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-04-24 14:15:37 -05:00
|
|
|
localLibraryItemId() {
|
|
|
|
if (this.isLocal) return this.libraryItemId
|
2023-06-19 12:37:44 -05:00
|
|
|
return this.localLibraryItem?.id || null
|
|
|
|
},
|
|
|
|
localEpisode() {
|
|
|
|
if (!this.recentEpisode || !this.localLibraryItem) return null
|
|
|
|
// Current recentEpisode is only implemented server side so this will always be the serverEpisodeId
|
|
|
|
return this.localLibraryItem.media.episodes.find((ep) => ep.serverEpisodeId === this.recentEpisode.id)
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
2022-04-24 14:15:37 -05:00
|
|
|
isStreaming() {
|
2023-09-10 17:51:53 -05:00
|
|
|
return this.store.getters['getIsMediaStreaming'](this.libraryItemId, this.recentEpisode?.id)
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
2022-04-24 14:15:37 -05:00
|
|
|
streamIsPlaying() {
|
2023-09-10 17:51:53 -05:00
|
|
|
return this.store.state.playerIsPlaying && this.isStreaming
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
isMissing() {
|
2022-03-23 17:59:14 -05:00
|
|
|
return this._libraryItem.isMissing
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
isInvalid() {
|
2022-03-23 17:59:14 -05:00
|
|
|
return this._libraryItem.isInvalid
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-04-24 14:15:37 -05:00
|
|
|
numMissingParts() {
|
|
|
|
if (this.isPodcast) return 0
|
|
|
|
return this.media.numMissingParts
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
overlayWrapperClasslist() {
|
|
|
|
var classes = []
|
|
|
|
if (this.isSelectionMode) classes.push('bg-opacity-60')
|
|
|
|
else classes.push('bg-opacity-40')
|
|
|
|
if (this.selected) {
|
|
|
|
classes.push('border-2 border-yellow-400')
|
|
|
|
}
|
|
|
|
return classes
|
|
|
|
},
|
2021-12-04 19:56:29 -06:00
|
|
|
store() {
|
|
|
|
return this.$store || this.$nuxt.$store
|
|
|
|
},
|
|
|
|
userCanUpdate() {
|
|
|
|
return this.store.getters['user/getUserCanUpdate']
|
|
|
|
},
|
|
|
|
userCanDelete() {
|
|
|
|
return this.store.getters['user/getUserCanDelete']
|
|
|
|
},
|
|
|
|
userCanDownload() {
|
|
|
|
return this.store.getters['user/getUserCanDownload']
|
|
|
|
},
|
|
|
|
userIsRoot() {
|
|
|
|
return this.store.getters['user/getIsRoot']
|
|
|
|
},
|
|
|
|
titleFontSize() {
|
|
|
|
return 0.75 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
authorFontSize() {
|
|
|
|
return 0.6 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
placeholderCoverPadding() {
|
|
|
|
return 0.8 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
authorBottom() {
|
|
|
|
return 0.75 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
titleCleaned() {
|
|
|
|
if (!this.title) return ''
|
|
|
|
if (this.title.length > 60) {
|
|
|
|
return this.title.slice(0, 57) + '...'
|
|
|
|
}
|
|
|
|
return this.title
|
|
|
|
},
|
|
|
|
authorCleaned() {
|
2022-03-23 17:59:14 -05:00
|
|
|
if (!this.author) return ''
|
|
|
|
if (this.author.length > 30) {
|
|
|
|
return this.author.slice(0, 27) + '...'
|
2021-12-04 19:56:29 -06:00
|
|
|
}
|
2022-03-23 17:59:14 -05:00
|
|
|
return this.author
|
2022-07-27 18:21:10 -05:00
|
|
|
},
|
|
|
|
titleDisplayBottomOffset() {
|
|
|
|
if (!this.isAltViewEnabled) return 0
|
|
|
|
else if (!this.displaySortLine) return 3 * this.sizeMultiplier
|
|
|
|
return 4.25 * this.sizeMultiplier
|
2022-08-21 18:03:27 -05:00
|
|
|
},
|
|
|
|
showHasLocalDownload() {
|
|
|
|
if (this.localLibraryItem || this.isLocal) {
|
|
|
|
if (this.recentEpisode && !this.isLocal) {
|
2023-06-19 12:37:44 -05:00
|
|
|
return !!this.localEpisode
|
2022-08-21 18:03:27 -05:00
|
|
|
} else {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
2023-06-24 14:45:25 -05:00
|
|
|
},
|
|
|
|
rssFeed() {
|
|
|
|
if (this.booksInSeries) return null
|
|
|
|
return this._libraryItem.rssFeed || null
|
2023-09-10 17:51:53 -05:00
|
|
|
},
|
|
|
|
showPlayButton() {
|
|
|
|
return false
|
|
|
|
// return !this.isMissing && !this.isInvalid && !this.isStreaming && (this.numTracks || this.recentEpisode)
|
2021-12-04 19:56:29 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setSelectionMode(val) {
|
|
|
|
this.isSelectionMode = val
|
|
|
|
if (!val) this.selected = false
|
|
|
|
},
|
2022-05-13 16:27:05 -05:00
|
|
|
setEntity(_libraryItem) {
|
|
|
|
var libraryItem = _libraryItem
|
|
|
|
|
|
|
|
// this code block is only necessary when showing a selected series with sequence #
|
|
|
|
// it will update the selected series so we get realtime updates for series sequence changes
|
|
|
|
if (this.series) {
|
|
|
|
// i know.. but the libraryItem passed to this func cannot be modified so we need to create a copy
|
|
|
|
libraryItem = {
|
|
|
|
..._libraryItem,
|
|
|
|
media: {
|
|
|
|
..._libraryItem.media,
|
|
|
|
metadata: {
|
|
|
|
..._libraryItem.media.metadata
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var mediaMetadata = libraryItem.media.metadata
|
|
|
|
if (mediaMetadata.series) {
|
|
|
|
var newSeries = mediaMetadata.series.find((se) => se.id === this.series.id)
|
|
|
|
if (newSeries) {
|
|
|
|
// update selected series
|
|
|
|
libraryItem.media.metadata.series = newSeries
|
|
|
|
this.libraryItem = libraryItem
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-03 17:07:26 -05:00
|
|
|
this.libraryItem = libraryItem
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
2022-04-07 18:46:58 -05:00
|
|
|
setLocalLibraryItem(localLibraryItem) {
|
|
|
|
// Server books may have a local library item
|
|
|
|
this.localLibraryItem = localLibraryItem
|
|
|
|
},
|
2023-09-10 17:51:53 -05:00
|
|
|
async play() {},
|
2023-02-25 16:33:06 -06:00
|
|
|
async playEpisode() {
|
|
|
|
await this.$hapticsImpact()
|
|
|
|
const eventBus = this.$eventBus || this.$nuxt.$eventBus
|
|
|
|
if (this.streamIsPlaying) {
|
|
|
|
eventBus.$emit('pause-item')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-06-19 12:37:44 -05:00
|
|
|
if (this.localEpisode) {
|
|
|
|
// Play episode locally
|
|
|
|
eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.localLibraryItemId,
|
|
|
|
episodeId: this.localEpisode.id,
|
|
|
|
serverLibraryItemId: this.libraryItemId,
|
|
|
|
serverEpisodeId: this.recentEpisode.id
|
|
|
|
})
|
|
|
|
return
|
2023-02-25 16:33:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
eventBus.$emit('play-item', { libraryItemId: this.libraryItemId, episodeId: this.recentEpisode.id })
|
|
|
|
},
|
2022-12-08 00:28:28 -05:00
|
|
|
async clickCard(e) {
|
2021-12-04 19:56:29 -06:00
|
|
|
if (this.isSelectionMode) {
|
|
|
|
e.stopPropagation()
|
|
|
|
e.preventDefault()
|
|
|
|
this.selectBtnClick()
|
|
|
|
} else {
|
2023-02-25 16:33:06 -06:00
|
|
|
const router = this.$router || this.$nuxt.$router
|
2022-03-23 17:59:14 -05:00
|
|
|
if (router) {
|
2023-02-25 16:33:06 -06:00
|
|
|
if (this.recentEpisode) router.push(`/item/${this.libraryItemId}/${this.recentEpisode.id}`)
|
2023-03-03 17:05:23 -06:00
|
|
|
else if (this.collapsedSeries) router.push(`/bookshelf/series/${this.collapsedSeries.id}`)
|
2022-03-23 17:59:14 -05:00
|
|
|
else router.push(`/item/${this.libraryItemId}`)
|
|
|
|
}
|
2021-12-04 19:56:29 -06:00
|
|
|
}
|
|
|
|
},
|
2022-03-23 17:59:14 -05:00
|
|
|
editClick() {
|
2022-04-03 17:07:26 -05:00
|
|
|
this.$emit('edit', this.libraryItem)
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
|
|
|
rescan() {
|
|
|
|
this.rescanning = true
|
|
|
|
this.$axios
|
|
|
|
.$get(`/api/items/${this.libraryItemId}/scan`)
|
|
|
|
.then((data) => {
|
|
|
|
this.rescanning = false
|
|
|
|
var result = data.result
|
|
|
|
if (!result) {
|
|
|
|
this.$toast.error(`Re-Scan Failed for "${this.title}"`)
|
|
|
|
} else if (result === 'UPDATED') {
|
|
|
|
this.$toast.success(`Re-Scan complete item was updated`)
|
|
|
|
} else if (result === 'UPTODATE') {
|
|
|
|
this.$toast.success(`Re-Scan complete item was up to date`)
|
|
|
|
} else if (result === 'REMOVED') {
|
|
|
|
this.$toast.error(`Re-Scan complete item was removed`)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to scan library item', error)
|
|
|
|
this.$toast.error('Failed to scan library item')
|
|
|
|
this.rescanning = false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
showEditModalTracks() {
|
|
|
|
// More menu func
|
2022-04-03 17:07:26 -05:00
|
|
|
this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'tracks' })
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
|
|
|
showEditModalMatch() {
|
|
|
|
// More menu func
|
2022-04-03 17:07:26 -05:00
|
|
|
this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'match' })
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
|
|
|
showEditModalDownload() {
|
|
|
|
// More menu func
|
2022-04-03 17:07:26 -05:00
|
|
|
this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'download' })
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
|
|
|
openCollections() {
|
2022-04-03 17:07:26 -05:00
|
|
|
this.store.commit('setSelectedLibraryItem', this.libraryItem)
|
2022-03-23 17:59:14 -05:00
|
|
|
this.store.commit('globals/setShowUserCollectionsModal', true)
|
|
|
|
},
|
|
|
|
clickReadEBook() {
|
2022-04-03 17:07:26 -05:00
|
|
|
this.store.commit('showEReader', this.libraryItem)
|
2022-03-23 17:59:14 -05:00
|
|
|
},
|
2021-12-04 19:56:29 -06:00
|
|
|
selectBtnClick() {
|
2022-03-23 17:59:14 -05:00
|
|
|
if (this.processingBatch) return
|
2021-12-04 19:56:29 -06:00
|
|
|
this.selected = !this.selected
|
2022-04-03 17:07:26 -05:00
|
|
|
this.$emit('select', this.libraryItem)
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
destroy() {
|
|
|
|
// destroy the vue listeners, etc
|
|
|
|
this.$destroy()
|
|
|
|
|
|
|
|
// remove the element from the DOM
|
|
|
|
if (this.$el && this.$el.parentNode) {
|
|
|
|
this.$el.parentNode.removeChild(this.$el)
|
|
|
|
} else if (this.$el && this.$el.remove) {
|
|
|
|
this.$el.remove()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setCoverBg() {
|
|
|
|
if (this.$refs.coverBg) {
|
|
|
|
this.$refs.coverBg.style.backgroundImage = `url("${this.bookCoverSrc}")`
|
|
|
|
}
|
|
|
|
},
|
|
|
|
imageLoaded() {
|
|
|
|
this.imageReady = true
|
|
|
|
|
|
|
|
if (this.$refs.cover && this.bookCoverSrc !== this.placeholderUrl) {
|
2023-01-08 14:07:48 -06:00
|
|
|
const { naturalWidth, naturalHeight } = this.$refs.cover
|
|
|
|
const aspectRatio = naturalHeight / naturalWidth
|
|
|
|
const arDiff = Math.abs(aspectRatio - this.bookCoverAspectRatio)
|
2021-12-04 19:56:29 -06:00
|
|
|
|
|
|
|
// If image aspect ratio is <= 1.45 or >= 1.75 then use cover bg, otherwise stretch to fit
|
|
|
|
if (arDiff > 0.15) {
|
|
|
|
this.showCoverBg = true
|
|
|
|
this.$nextTick(this.setCoverBg)
|
|
|
|
} else {
|
|
|
|
this.showCoverBg = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.bookMount) {
|
|
|
|
this.setEntity(this.bookMount)
|
2022-04-07 18:46:58 -05:00
|
|
|
|
|
|
|
if (this.bookMount.localLibraryItem) {
|
|
|
|
this.setLocalLibraryItem(this.bookMount.localLibraryItem)
|
|
|
|
}
|
2021-12-04 19:56:29 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|