2022-03-11 01:45:02 +01:00
|
|
|
<template>
|
2022-03-14 01:34:31 +01:00
|
|
|
<div id="page-wrapper" class="bg-bg page overflow-hidden" :class="streamLibraryItem ? 'streaming' : ''">
|
2023-12-31 21:51:01 +01:00
|
|
|
<div id="item-page-wrapper" class="w-full h-full overflow-y-auto px-2 py-6 lg:p-8">
|
2023-04-16 01:09:49 +02:00
|
|
|
<div class="flex flex-col lg:flex-row max-w-6xl mx-auto">
|
|
|
|
<div class="w-full flex justify-center lg:block lg:w-52" style="min-width: 208px">
|
2023-10-24 05:37:51 +02:00
|
|
|
<div class="relative group" style="height: fit-content">
|
2023-10-27 23:51:44 +02:00
|
|
|
<covers-book-cover class="relative group-hover:brightness-75 transition cursor-pointer" expand-on-click :library-item="libraryItem" :width="bookCoverWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" />
|
2022-03-11 01:45:02 +01:00
|
|
|
|
2022-03-22 01:24:38 +01:00
|
|
|
<!-- Item Progress Bar -->
|
2022-08-06 15:00:28 +02:00
|
|
|
<div v-if="!isPodcast" class="absolute bottom-0 left-0 h-1.5 shadow-sm z-10" :class="userIsFinished ? 'bg-success' : 'bg-yellow-400'" :style="{ width: 208 * progressPercent + 'px' }"></div>
|
2022-03-11 01:45:02 +01:00
|
|
|
|
2022-03-22 01:24:38 +01:00
|
|
|
<!-- Item Cover Overlay -->
|
2023-10-27 23:51:44 +02:00
|
|
|
<div class="absolute top-0 left-0 w-full h-full z-10 opacity-0 group-hover:opacity-100 pointer-events-none">
|
2022-07-30 02:06:52 +02:00
|
|
|
<div v-show="showPlayButton && !isStreaming" class="h-full flex items-center justify-center pointer-events-none">
|
2022-08-28 20:12:38 +02:00
|
|
|
<div class="hover:text-white text-gray-200 hover:scale-110 transform duration-200 pointer-events-auto cursor-pointer" @click.stop.prevent="playItem">
|
2022-03-11 01:45:02 +01:00
|
|
|
<span class="material-icons text-4xl">play_circle_filled</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-10-24 05:37:51 +02:00
|
|
|
<span class="absolute bottom-2.5 right-2.5 z-10 material-icons text-lg cursor-pointer text-white text-opacity-75 hover:text-opacity-100 hover:scale-110 transform duration-200 pointer-events-auto" @click="showEditCover">edit</span>
|
2022-03-11 01:45:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-16 01:09:49 +02:00
|
|
|
<div class="flex-grow px-2 py-6 lg:py-0 md:px-10">
|
2022-03-11 01:45:02 +01:00
|
|
|
<div class="flex justify-center">
|
|
|
|
<div class="mb-4">
|
2022-08-07 17:38:13 +02:00
|
|
|
<h1 class="text-2xl md:text-3xl font-semibold">
|
2023-02-25 00:31:16 +01:00
|
|
|
<div class="flex items-center">
|
|
|
|
{{ title }}
|
|
|
|
<widgets-explicit-indicator :explicit="isExplicit" />
|
2023-04-16 01:28:06 +02:00
|
|
|
<widgets-abridged-indicator v-if="isAbridged" />
|
2023-02-25 00:31:16 +01:00
|
|
|
</div>
|
2022-08-07 17:38:13 +02:00
|
|
|
</h1>
|
|
|
|
|
|
|
|
<p v-if="bookSubtitle" class="text-gray-200 text-xl md:text-2xl">{{ bookSubtitle }}</p>
|
|
|
|
|
|
|
|
<nuxt-link v-for="_series in seriesList" :key="_series.id" :to="`/library/${libraryId}/series/${_series.id}`" class="hover:underline font-sans text-gray-300 text-lg leading-7"> {{ _series.text }}</nuxt-link>
|
2022-03-11 01:45:02 +01:00
|
|
|
|
2022-05-31 02:26:53 +02:00
|
|
|
<template v-if="!isVideo">
|
|
|
|
<p v-if="isPodcast" class="mb-2 mt-0.5 text-gray-200 text-lg md:text-xl">by {{ podcastAuthor || 'Unknown' }}</p>
|
2023-01-07 00:10:55 +01:00
|
|
|
<p v-else-if="musicArtists.length" class="mb-2 mt-0.5 text-gray-200 text-lg md:text-xl max-w-[calc(100vw-2rem)] overflow-hidden overflow-ellipsis">
|
|
|
|
<nuxt-link v-for="(artist, index) in musicArtists" :key="index" :to="`/artist/${$encode(artist)}`" class="hover:underline">{{ artist }}<span v-if="index < musicArtists.length - 1">, </span></nuxt-link>
|
|
|
|
</p>
|
2022-11-19 17:20:10 +01:00
|
|
|
<p v-else-if="authors.length" class="mb-2 mt-0.5 text-gray-200 text-lg md:text-xl max-w-[calc(100vw-2rem)] overflow-hidden overflow-ellipsis">
|
2023-10-19 00:10:53 +02:00
|
|
|
by <nuxt-link v-for="(author, index) in authors" :key="index" :to="`/author/${author.id}`" class="hover:underline">{{ author.name }}<span v-if="index < authors.length - 1">, </span></nuxt-link>
|
2022-05-31 02:26:53 +02:00
|
|
|
</p>
|
|
|
|
<p v-else class="mb-2 mt-0.5 text-gray-200 text-xl">by Unknown</p>
|
|
|
|
</template>
|
2022-03-11 01:45:02 +01:00
|
|
|
|
2023-04-30 16:41:49 +02:00
|
|
|
<content-library-item-details :library-item="libraryItem" />
|
2022-03-11 01:45:02 +01:00
|
|
|
</div>
|
|
|
|
<div class="hidden md:block flex-grow" />
|
|
|
|
</div>
|
|
|
|
|
2022-04-30 01:29:40 +02:00
|
|
|
<!-- Podcast episode downloads queue -->
|
2022-04-24 02:41:06 +02:00
|
|
|
<div v-if="episodeDownloadsQueued.length" class="px-4 py-2 mt-4 bg-info bg-opacity-40 text-sm font-semibold rounded-md text-gray-100 relative max-w-max mx-auto md:mx-0">
|
|
|
|
<div class="flex items-center">
|
2022-11-08 15:37:39 +01:00
|
|
|
<p class="text-sm py-1">{{ $getString('MessageEpisodesQueuedForDownload', [episodeDownloadsQueued.length]) }}</p>
|
2022-04-24 02:41:06 +02:00
|
|
|
|
2022-04-30 01:29:40 +02:00
|
|
|
<span v-if="userIsAdminOrUp" class="material-icons hover:text-error text-xl ml-3 cursor-pointer" @click="clearDownloadQueue">close</span>
|
2022-04-24 02:41:06 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-04-30 01:29:40 +02:00
|
|
|
<!-- Podcast episodes currently downloading -->
|
2022-04-24 02:41:06 +02:00
|
|
|
<div v-if="episodesDownloading.length" class="px-4 py-2 mt-4 bg-success bg-opacity-20 text-sm font-semibold rounded-md text-gray-100 relative max-w-max mx-auto md:mx-0">
|
|
|
|
<div v-for="episode in episodesDownloading" :key="episode.id" class="flex items-center">
|
|
|
|
<widgets-loading-spinner />
|
2022-11-08 15:37:39 +01:00
|
|
|
<p class="text-sm py-1 pl-4">{{ $strings.MessageDownloadingEpisode }} "{{ episode.episodeDisplayTitle }}"</p>
|
2022-04-24 02:41:06 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-03-11 01:45:02 +01:00
|
|
|
<!-- Progress -->
|
2022-03-26 23:41:26 +01:00
|
|
|
<div v-if="!isPodcast && progressPercent > 0" class="px-4 py-2 mt-4 bg-primary text-sm font-semibold rounded-md text-gray-100 relative max-w-max mx-auto md:mx-0" :class="resettingProgress ? 'opacity-25' : ''">
|
2022-11-08 15:37:39 +01:00
|
|
|
<p v-if="progressPercent < 1" class="leading-6">{{ $strings.LabelYourProgress }}: {{ Math.round(progressPercent * 100) }}%</p>
|
|
|
|
<p v-else class="text-xs">{{ $strings.LabelFinished }} {{ $formatDate(userProgressFinishedAt, dateFormat) }}</p>
|
2023-03-24 23:57:41 +01:00
|
|
|
<p v-if="progressPercent < 1 && !useEBookProgress" class="text-gray-200 text-xs">{{ $getString('LabelTimeRemaining', [$elapsedPretty(userTimeRemaining)]) }}</p>
|
2022-11-08 15:37:39 +01:00
|
|
|
<p class="text-gray-400 text-xs pt-1">{{ $strings.LabelStarted }} {{ $formatDate(userProgressStartedAt, dateFormat) }}</p>
|
2022-03-11 01:45:02 +01:00
|
|
|
|
|
|
|
<div v-if="!resettingProgress" class="absolute -top-1.5 -right-1.5 p-1 w-5 h-5 rounded-full bg-bg hover:bg-error border border-primary flex items-center justify-center cursor-pointer" @click.stop="clearProgressClick">
|
|
|
|
<span class="material-icons text-sm">close</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-03-27 22:37:04 +02:00
|
|
|
<!-- Icon buttons -->
|
2022-03-11 01:45:02 +01:00
|
|
|
<div class="flex items-center justify-center md:justify-start pt-4">
|
2022-08-28 20:12:38 +02:00
|
|
|
<ui-btn v-if="showPlayButton" :disabled="isStreaming" color="success" :padding-x="4" small class="flex items-center h-9 mr-2" @click="playItem">
|
2022-11-21 14:18:10 +01:00
|
|
|
<span v-show="!isStreaming" class="material-icons text-2xl -ml-2 pr-1 text-white">play_arrow</span>
|
2022-11-08 15:37:39 +01:00
|
|
|
{{ isStreaming ? $strings.ButtonPlaying : $strings.ButtonPlay }}
|
2022-03-11 01:45:02 +01:00
|
|
|
</ui-btn>
|
2022-12-22 23:38:55 +01:00
|
|
|
|
2022-03-11 01:45:02 +01:00
|
|
|
<ui-btn v-else-if="isMissing || isInvalid" color="error" :padding-x="4" small class="flex items-center h-9 mr-2">
|
2022-11-21 14:18:10 +01:00
|
|
|
<span v-show="!isStreaming" class="material-icons text-2xl -ml-2 pr-1 text-white">error</span>
|
2022-11-08 15:37:39 +01:00
|
|
|
{{ isMissing ? $strings.LabelMissing : $strings.LabelIncomplete }}
|
2022-03-11 01:45:02 +01:00
|
|
|
</ui-btn>
|
|
|
|
|
2022-11-12 23:48:35 +01:00
|
|
|
<ui-tooltip v-if="showQueueBtn" :text="isQueued ? $strings.ButtonQueueRemoveItem : $strings.ButtonQueueAddItem" direction="top">
|
2022-11-26 23:25:14 +01:00
|
|
|
<ui-icon-btn :icon="isQueued ? 'playlist_add_check' : 'playlist_play'" :bg-color="isQueued ? 'primary' : 'success bg-opacity-60'" class="mx-0.5" :class="isQueued ? 'text-success' : ''" @click="queueBtnClick" />
|
2022-11-12 23:48:35 +01:00
|
|
|
</ui-tooltip>
|
|
|
|
|
2022-05-20 23:34:51 +02:00
|
|
|
<ui-btn v-if="showReadButton" color="info" :padding-x="4" small class="flex items-center h-9 mr-2" @click="openEbook">
|
2022-11-21 14:18:10 +01:00
|
|
|
<span class="material-icons text-2xl -ml-2 pr-2 text-white">auto_stories</span>
|
2022-11-08 15:37:39 +01:00
|
|
|
{{ $strings.ButtonRead }}
|
2022-03-11 01:45:02 +01:00
|
|
|
</ui-btn>
|
|
|
|
|
2022-11-12 23:48:35 +01:00
|
|
|
<ui-tooltip v-if="userCanUpdate" :text="$strings.LabelEdit" direction="top">
|
2022-03-11 01:45:02 +01:00
|
|
|
<ui-icon-btn icon="edit" class="mx-0.5" @click="editClick" />
|
|
|
|
</ui-tooltip>
|
|
|
|
|
2022-12-22 23:38:55 +01:00
|
|
|
<ui-tooltip v-if="!isPodcast && !isMusic" :text="userIsFinished ? $strings.MessageMarkAsNotFinished : $strings.MessageMarkAsFinished" direction="top">
|
2022-03-17 19:33:22 +01:00
|
|
|
<ui-read-icon-btn :disabled="isProcessingReadUpdate" :is-read="userIsFinished" class="mx-0.5" @click="toggleFinished" />
|
2022-03-11 01:45:02 +01:00
|
|
|
</ui-tooltip>
|
|
|
|
|
2022-04-29 23:42:40 +02:00
|
|
|
<!-- Only admin or root user can download new episodes -->
|
2022-11-08 15:37:39 +01:00
|
|
|
<ui-tooltip v-if="isPodcast && userIsAdminOrUp" :text="$strings.LabelFindEpisodes" direction="top">
|
2022-03-27 22:37:04 +02:00
|
|
|
<ui-icon-btn icon="search" class="mx-0.5" :loading="fetchingRSSFeed" outlined @click="findEpisodesClick" />
|
|
|
|
</ui-tooltip>
|
2022-05-02 21:41:59 +02:00
|
|
|
|
2023-06-07 22:48:23 +02:00
|
|
|
<ui-context-menu-dropdown v-if="contextMenuItems.length" :items="contextMenuItems" :menu-width="148" @action="contextMenuAction">
|
2023-04-14 01:03:39 +02:00
|
|
|
<template #default="{ showMenu, clickShowMenu, disabled }">
|
|
|
|
<button type="button" :disabled="disabled" class="mx-0.5 icon-btn bg-primary border border-gray-600 w-9 h-9 rounded-md flex items-center justify-center relative" aria-haspopup="listbox" :aria-expanded="showMenu" @click.stop.prevent="clickShowMenu">
|
2023-04-14 23:48:24 +02:00
|
|
|
<span class="material-icons">more_horiz</span>
|
2023-04-14 01:03:39 +02:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
</ui-context-menu-dropdown>
|
2022-03-11 01:45:02 +01:00
|
|
|
</div>
|
|
|
|
|
2023-10-19 23:30:33 +02:00
|
|
|
<div class="my-4 w-full">
|
2022-03-11 01:45:02 +01:00
|
|
|
<p class="text-base text-gray-100 whitespace-pre-line">{{ description }}</p>
|
|
|
|
</div>
|
|
|
|
|
2022-04-25 01:05:15 +02:00
|
|
|
<div v-if="invalidAudioFiles.length" class="bg-error border-red-800 shadow-md p-4">
|
|
|
|
<p class="text-sm mb-2">Invalid audio files</p>
|
|
|
|
|
|
|
|
<p v-for="audioFile in invalidAudioFiles" :key="audioFile.id" class="text-xs pl-2">- {{ audioFile.metadata.filename }} ({{ audioFile.error }})</p>
|
|
|
|
</div>
|
|
|
|
|
2022-04-28 02:42:34 +02:00
|
|
|
<widgets-audiobook-data v-if="tracks.length" :library-item-id="libraryItemId" :is-file="isFile" :media="media" />
|
2022-03-26 17:59:34 +01:00
|
|
|
|
2023-12-31 21:51:01 +01:00
|
|
|
<tables-podcast-lazy-episodes-table v-if="isPodcast" :library-item="libraryItem" />
|
2022-03-26 23:41:26 +01:00
|
|
|
|
2022-05-11 00:03:41 +02:00
|
|
|
<tables-chapters-table v-if="chapters.length" :library-item="libraryItem" class="mt-6" />
|
|
|
|
|
2023-06-10 19:46:57 +02:00
|
|
|
<tables-ebook-files-table v-if="ebookFiles.length" :library-item="libraryItem" class="mt-6" />
|
|
|
|
|
|
|
|
<tables-library-files-table v-if="libraryFiles.length" :library-item="libraryItem" class="mt-6" />
|
2022-03-11 01:45:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-03-27 22:37:04 +02:00
|
|
|
|
|
|
|
<modals-podcast-episode-feed v-model="showPodcastEpisodeFeed" :library-item="libraryItem" :episodes="podcastFeedEpisodes" />
|
2022-07-30 02:06:52 +02:00
|
|
|
<modals-bookmarks-modal v-model="showBookmarksModal" :bookmarks="bookmarks" :library-item-id="libraryItemId" hide-create @select="selectBookmark" />
|
2022-03-11 01:45:02 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
async asyncData({ store, params, app, redirect, route }) {
|
|
|
|
if (!store.state.user.user) {
|
|
|
|
return redirect(`/login?redirect=${route.path}`)
|
|
|
|
}
|
2022-04-24 02:41:06 +02:00
|
|
|
|
|
|
|
// Include episode downloads for podcasts
|
2023-09-03 17:04:14 +02:00
|
|
|
var item = await app.$axios.$get(`/api/items/${params.id}?expanded=1&include=downloads,rssfeed`).catch((error) => {
|
2022-03-11 01:45:02 +01:00
|
|
|
console.error('Failed', error)
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
if (!item) {
|
|
|
|
console.error('No item...', params.id)
|
|
|
|
return redirect('/')
|
|
|
|
}
|
|
|
|
return {
|
2022-05-02 23:42:30 +02:00
|
|
|
libraryItem: item,
|
2022-12-26 23:58:36 +01:00
|
|
|
rssFeed: item.rssFeed || null
|
2022-03-11 01:45:02 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
resettingProgress: false,
|
2022-03-27 22:37:04 +02:00
|
|
|
isProcessingReadUpdate: false,
|
|
|
|
fetchingRSSFeed: false,
|
|
|
|
showPodcastEpisodeFeed: false,
|
2022-04-24 02:41:06 +02:00
|
|
|
podcastFeedEpisodes: [],
|
|
|
|
episodesDownloading: [],
|
2022-05-02 23:42:30 +02:00
|
|
|
episodeDownloadsQueued: [],
|
2022-07-30 02:06:52 +02:00
|
|
|
showBookmarksModal: false
|
2022-03-11 01:45:02 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2023-04-10 00:05:35 +02:00
|
|
|
userToken() {
|
|
|
|
return this.$store.getters['user/getToken']
|
|
|
|
},
|
2023-04-14 01:03:39 +02:00
|
|
|
downloadUrl() {
|
2023-04-10 00:05:35 +02:00
|
|
|
return `${process.env.serverUrl}/api/items/${this.libraryItemId}/download?token=${this.userToken}`
|
|
|
|
},
|
2022-06-17 10:26:10 +02:00
|
|
|
dateFormat() {
|
|
|
|
return this.$store.state.serverSettings.dateFormat
|
|
|
|
},
|
2022-04-29 23:42:40 +02:00
|
|
|
userIsAdminOrUp() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
bookCoverAspectRatio() {
|
2022-08-13 20:56:37 +02:00
|
|
|
return this.$store.getters['libraries/getBookCoverAspectRatio']
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
bookCoverWidth() {
|
|
|
|
return 208
|
|
|
|
},
|
|
|
|
isDeveloperMode() {
|
|
|
|
return this.$store.state.developerMode
|
|
|
|
},
|
2023-04-14 01:03:39 +02:00
|
|
|
isFile() {
|
|
|
|
return this.libraryItem.isFile
|
|
|
|
},
|
2022-12-22 23:38:55 +01:00
|
|
|
isBook() {
|
|
|
|
return this.libraryItem.mediaType === 'book'
|
|
|
|
},
|
2022-03-22 01:24:38 +01:00
|
|
|
isPodcast() {
|
|
|
|
return this.libraryItem.mediaType === 'podcast'
|
|
|
|
},
|
2022-05-31 02:26:53 +02:00
|
|
|
isVideo() {
|
|
|
|
return this.libraryItem.mediaType === 'video'
|
|
|
|
},
|
2022-12-22 23:38:55 +01:00
|
|
|
isMusic() {
|
|
|
|
return this.libraryItem.mediaType === 'music'
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
isMissing() {
|
|
|
|
return this.libraryItem.isMissing
|
|
|
|
},
|
|
|
|
isInvalid() {
|
|
|
|
return this.libraryItem.isInvalid
|
|
|
|
},
|
2023-02-22 13:48:12 +01:00
|
|
|
isExplicit() {
|
2023-03-23 00:05:43 +01:00
|
|
|
return !!this.mediaMetadata.explicit
|
|
|
|
},
|
|
|
|
isAbridged() {
|
|
|
|
return !!this.mediaMetadata.abridged
|
2023-02-22 13:48:12 +01:00
|
|
|
},
|
2022-04-25 01:05:15 +02:00
|
|
|
invalidAudioFiles() {
|
2022-12-22 23:38:55 +01:00
|
|
|
if (!this.isBook) return []
|
2022-04-25 01:05:15 +02:00
|
|
|
return this.libraryItem.media.audioFiles.filter((af) => af.invalid)
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
showPlayButton() {
|
2022-03-22 01:24:38 +01:00
|
|
|
if (this.isMissing || this.isInvalid) return false
|
2022-12-22 23:38:55 +01:00
|
|
|
if (this.isMusic) return !!this.audioFile
|
2022-05-31 02:26:53 +02:00
|
|
|
if (this.isVideo) return !!this.videoFile
|
2022-03-22 01:24:38 +01:00
|
|
|
if (this.isPodcast) return this.podcastEpisodes.length
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.tracks.length
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-05-20 23:34:51 +02:00
|
|
|
showReadButton() {
|
2023-06-10 21:11:51 +02:00
|
|
|
return this.ebookFile
|
2022-05-20 23:34:51 +02:00
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
libraryId() {
|
|
|
|
return this.libraryItem.libraryId
|
|
|
|
},
|
|
|
|
libraryItemId() {
|
|
|
|
return this.libraryItem.id
|
|
|
|
},
|
|
|
|
media() {
|
|
|
|
return this.libraryItem.media || {}
|
|
|
|
},
|
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
|
|
|
},
|
2022-05-11 00:03:41 +02:00
|
|
|
chapters() {
|
|
|
|
return this.media.chapters || []
|
|
|
|
},
|
2022-07-30 02:06:52 +02:00
|
|
|
bookmarks() {
|
|
|
|
if (this.isPodcast) return []
|
|
|
|
return this.$store.getters['user/getUserBookmarksForItem'](this.libraryItemId)
|
|
|
|
},
|
2022-03-26 17:59:34 +01:00
|
|
|
tracks() {
|
|
|
|
return this.media.tracks || []
|
|
|
|
},
|
2022-03-22 01:24:38 +01:00
|
|
|
podcastEpisodes() {
|
|
|
|
return this.media.episodes || []
|
2022-03-17 18:25:12 +01:00
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
title() {
|
|
|
|
return this.mediaMetadata.title || 'No Title'
|
|
|
|
},
|
2022-03-22 01:24:38 +01:00
|
|
|
bookSubtitle() {
|
|
|
|
if (this.isPodcast) return null
|
2022-03-11 01:45:02 +01:00
|
|
|
return this.mediaMetadata.subtitle
|
|
|
|
},
|
2022-03-22 01:24:38 +01:00
|
|
|
podcastAuthor() {
|
|
|
|
return this.mediaMetadata.author || ''
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
authors() {
|
|
|
|
return this.mediaMetadata.authors || []
|
|
|
|
},
|
2023-01-07 00:10:55 +01:00
|
|
|
musicArtists() {
|
|
|
|
return this.mediaMetadata.artists || []
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
series() {
|
2022-04-21 01:20:31 +02:00
|
|
|
return this.mediaMetadata.series || []
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
seriesList() {
|
|
|
|
return this.series.map((se) => {
|
2023-01-07 00:10:55 +01:00
|
|
|
let text = se.name
|
2022-03-11 01:45:02 +01:00
|
|
|
if (se.sequence) text += ` #${se.sequence}`
|
|
|
|
return {
|
|
|
|
...se,
|
|
|
|
text
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
duration() {
|
2023-01-07 00:10:55 +01:00
|
|
|
if (!this.tracks.length && !this.audioFile) return 0
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.media.duration
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
libraryFiles() {
|
|
|
|
return this.libraryItem.libraryFiles || []
|
|
|
|
},
|
2023-06-10 19:46:57 +02:00
|
|
|
ebookFiles() {
|
|
|
|
return this.libraryFiles.filter((lf) => lf.fileType === 'ebook')
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
ebookFile() {
|
|
|
|
return this.media.ebookFile
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-05-31 02:26:53 +02:00
|
|
|
videoFile() {
|
|
|
|
return this.media.videoFile
|
|
|
|
},
|
2022-12-22 23:38:55 +01:00
|
|
|
audioFile() {
|
|
|
|
// Music track
|
|
|
|
return this.media.audioFile
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
description() {
|
|
|
|
return this.mediaMetadata.description || ''
|
|
|
|
},
|
2022-03-26 17:59:34 +01:00
|
|
|
userMediaProgress() {
|
2022-12-22 23:38:55 +01:00
|
|
|
if (this.isMusic) return null
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.$store.getters['user/getUserMediaProgress'](this.libraryItemId)
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-03-17 19:33:22 +01:00
|
|
|
userIsFinished() {
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.userMediaProgress ? !!this.userMediaProgress.isFinished : false
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
userTimeRemaining() {
|
2022-03-26 17:59:34 +01:00
|
|
|
if (!this.userMediaProgress) return 0
|
2023-01-07 00:10:55 +01:00
|
|
|
const duration = this.userMediaProgress.duration || this.duration
|
2022-03-26 17:59:34 +01:00
|
|
|
return duration - this.userMediaProgress.currentTime
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2023-03-24 23:57:41 +01:00
|
|
|
useEBookProgress() {
|
|
|
|
if (!this.userMediaProgress || this.userMediaProgress.progress) return false
|
|
|
|
return this.userMediaProgress.ebookProgress > 0
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
progressPercent() {
|
2023-03-24 23:57:41 +01:00
|
|
|
if (this.useEBookProgress) return Math.max(Math.min(1, this.userMediaProgress.ebookProgress), 0)
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.userMediaProgress ? Math.max(Math.min(1, this.userMediaProgress.progress), 0) : 0
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
userProgressStartedAt() {
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.userMediaProgress ? this.userMediaProgress.startedAt : 0
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
userProgressFinishedAt() {
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.userMediaProgress ? this.userMediaProgress.finishedAt : 0
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-03-14 01:34:31 +01:00
|
|
|
streamLibraryItem() {
|
|
|
|
return this.$store.state.streamLibraryItem
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-07-30 02:06:52 +02:00
|
|
|
isStreaming() {
|
2022-03-14 01:34:31 +01:00
|
|
|
return this.streamLibraryItem && this.streamLibraryItem.id === this.libraryItemId
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-11-12 23:48:35 +01:00
|
|
|
isQueued() {
|
|
|
|
return this.$store.getters['getIsMediaQueued'](this.libraryItemId)
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
userCanUpdate() {
|
|
|
|
return this.$store.getters['user/getUserCanUpdate']
|
|
|
|
},
|
|
|
|
userCanDelete() {
|
|
|
|
return this.$store.getters['user/getUserCanDelete']
|
|
|
|
},
|
|
|
|
userCanDownload() {
|
|
|
|
return this.$store.getters['user/getUserCanDownload']
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
|
|
|
showRssFeedBtn() {
|
2022-12-26 23:58:36 +01:00
|
|
|
if (!this.rssFeed && !this.podcastEpisodes.length && !this.tracks.length) return false // Cannot open RSS feed with no episodes/tracks
|
2022-05-12 01:34:17 +02:00
|
|
|
|
2022-05-02 23:42:30 +02:00
|
|
|
// If rss feed is open then show feed url to users otherwise just show to admins
|
2022-12-26 23:58:36 +01:00
|
|
|
return this.userIsAdminOrUp || this.rssFeed
|
2022-11-12 23:48:35 +01:00
|
|
|
},
|
|
|
|
showQueueBtn() {
|
2022-12-22 23:38:55 +01:00
|
|
|
if (!this.isBook) return false
|
2022-11-12 23:48:35 +01:00
|
|
|
return !this.$store.getters['getIsStreamingFromDifferentLibrary'] && this.streamLibraryItem
|
2022-12-22 23:38:55 +01:00
|
|
|
},
|
|
|
|
showCollectionsButton() {
|
|
|
|
return this.isBook && this.userCanUpdate
|
2023-04-14 01:03:39 +02:00
|
|
|
},
|
|
|
|
contextMenuItems() {
|
|
|
|
const items = []
|
|
|
|
|
|
|
|
if (this.showCollectionsButton) {
|
|
|
|
items.push({
|
|
|
|
text: this.$strings.LabelCollections,
|
|
|
|
action: 'collections'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.isPodcast && this.tracks.length) {
|
|
|
|
items.push({
|
|
|
|
text: this.$strings.LabelYourPlaylists,
|
|
|
|
action: 'playlists'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.bookmarks.length) {
|
|
|
|
items.push({
|
|
|
|
text: this.$strings.LabelYourBookmarks,
|
|
|
|
action: 'bookmarks'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.showRssFeedBtn) {
|
|
|
|
items.push({
|
|
|
|
text: this.$strings.LabelOpenRSSFeed,
|
|
|
|
action: 'rss-feeds'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.userCanDownload) {
|
|
|
|
items.push({
|
|
|
|
text: this.$strings.LabelDownload,
|
|
|
|
action: 'download'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-05-30 00:38:38 +02:00
|
|
|
if (this.ebookFile && this.$store.state.libraries.ereaderDevices?.length) {
|
|
|
|
items.push({
|
|
|
|
text: this.$strings.LabelSendEbookToDevice,
|
|
|
|
subitems: this.$store.state.libraries.ereaderDevices.map((d) => {
|
|
|
|
return {
|
|
|
|
text: d.name,
|
|
|
|
action: 'sendToDevice',
|
|
|
|
data: d.name
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-04-14 23:44:41 +02:00
|
|
|
if (this.userCanDelete) {
|
|
|
|
items.push({
|
|
|
|
text: this.$strings.ButtonDelete,
|
|
|
|
action: 'delete'
|
|
|
|
})
|
|
|
|
}
|
2023-04-14 01:03:39 +02:00
|
|
|
|
|
|
|
return items
|
2022-03-11 01:45:02 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2022-07-30 02:06:52 +02:00
|
|
|
selectBookmark(bookmark) {
|
|
|
|
if (!bookmark) return
|
|
|
|
if (this.isStreaming) {
|
|
|
|
this.$eventBus.$emit('playback-seek', bookmark.time)
|
|
|
|
} else if (this.streamLibraryItem) {
|
2022-07-30 18:53:48 +02:00
|
|
|
this.showBookmarksModal = false
|
|
|
|
console.log('Already streaming library item so ask about it')
|
|
|
|
const payload = {
|
|
|
|
message: `Start playback for "${this.title}" at ${this.$secondsToTimestamp(bookmark.time)}?`,
|
|
|
|
callback: (confirmed) => {
|
|
|
|
if (confirmed) {
|
2022-08-28 20:12:38 +02:00
|
|
|
this.playItem(bookmark.time)
|
2022-07-30 18:53:48 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
type: 'yesNo'
|
2022-07-30 02:06:52 +02:00
|
|
|
}
|
2022-07-30 18:53:48 +02:00
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
2022-07-30 02:06:52 +02:00
|
|
|
} else {
|
2022-08-28 20:12:38 +02:00
|
|
|
this.playItem(bookmark.time)
|
2022-07-30 02:06:52 +02:00
|
|
|
}
|
|
|
|
this.showBookmarksModal = false
|
|
|
|
},
|
2022-04-24 02:41:06 +02:00
|
|
|
clearDownloadQueue() {
|
|
|
|
if (confirm('Are you sure you want to clear episode download queue?')) {
|
|
|
|
this.$axios
|
|
|
|
.$get(`/api/podcasts/${this.libraryItemId}/clear-queue`)
|
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Episode download queue cleared')
|
|
|
|
this.episodeDownloadQueued = []
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to clear queue', error)
|
|
|
|
this.$toast.error('Failed to clear queue')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2022-03-27 22:37:04 +02:00
|
|
|
async findEpisodesClick() {
|
|
|
|
if (!this.mediaMetadata.feedUrl) {
|
|
|
|
return this.$toast.error('Podcast does not have an RSS Feed')
|
|
|
|
}
|
|
|
|
this.fetchingRSSFeed = true
|
2022-04-13 23:55:48 +02:00
|
|
|
var payload = await this.$axios.$post(`/api/podcasts/feed`, { rssFeed: this.mediaMetadata.feedUrl }).catch((error) => {
|
2022-03-27 22:37:04 +02:00
|
|
|
console.error('Failed to get feed', error)
|
|
|
|
this.$toast.error('Failed to get podcast feed')
|
|
|
|
return null
|
|
|
|
})
|
|
|
|
this.fetchingRSSFeed = false
|
2022-04-13 23:55:48 +02:00
|
|
|
if (!payload) return
|
2022-03-27 22:37:04 +02:00
|
|
|
|
2022-04-13 23:55:48 +02:00
|
|
|
console.log('Podcast feed', payload)
|
|
|
|
const podcastfeed = payload.podcast
|
2022-03-27 22:37:04 +02:00
|
|
|
if (!podcastfeed.episodes || !podcastfeed.episodes.length) {
|
|
|
|
this.$toast.info('No episodes found in RSS feed')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.podcastFeedEpisodes = podcastfeed.episodes
|
|
|
|
this.showPodcastEpisodeFeed = true
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
showEditCover() {
|
|
|
|
this.$store.commit('setBookshelfBookIds', [])
|
|
|
|
this.$store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'cover' })
|
|
|
|
},
|
|
|
|
openEbook() {
|
2023-06-10 19:46:57 +02:00
|
|
|
this.$store.commit('showEReader', { libraryItem: this.libraryItem, keepProgress: true })
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-07-30 19:40:43 +02:00
|
|
|
toggleFinished(confirmed = false) {
|
|
|
|
if (!this.userIsFinished && this.progressPercent > 0 && !confirmed) {
|
|
|
|
const payload = {
|
|
|
|
message: `Are you sure you want to mark "${this.title}" as finished?`,
|
|
|
|
callback: (confirmed) => {
|
|
|
|
if (confirmed) {
|
|
|
|
this.toggleFinished(true)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
type: 'yesNo'
|
|
|
|
}
|
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-11 01:45:02 +01:00
|
|
|
var updatePayload = {
|
2022-03-17 19:33:22 +01:00
|
|
|
isFinished: !this.userIsFinished
|
2022-03-11 01:45:02 +01:00
|
|
|
}
|
|
|
|
this.isProcessingReadUpdate = true
|
|
|
|
this.$axios
|
2022-03-17 19:33:22 +01:00
|
|
|
.$patch(`/api/me/progress/${this.libraryItemId}`, updatePayload)
|
2022-03-11 01:45:02 +01:00
|
|
|
.then(() => {
|
|
|
|
this.isProcessingReadUpdate = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed', error)
|
|
|
|
this.isProcessingReadUpdate = false
|
2022-11-09 00:10:08 +01:00
|
|
|
this.$toast.error(updatePayload.isFinished ? this.$strings.ToastItemMarkedAsFinishedFailed : this.$strings.ToastItemMarkedAsNotFinishedFailed)
|
2022-03-11 01:45:02 +01:00
|
|
|
})
|
|
|
|
},
|
2022-08-28 20:12:38 +02:00
|
|
|
playItem(startTime = null) {
|
2022-12-22 23:38:55 +01:00
|
|
|
let episodeId = null
|
2022-08-28 20:12:38 +02:00
|
|
|
const queueItems = []
|
2022-03-26 23:41:26 +01:00
|
|
|
if (this.isPodcast) {
|
2022-09-02 00:11:57 +02:00
|
|
|
const episodesInListeningOrder = this.podcastEpisodes.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' }))
|
|
|
|
|
|
|
|
// Find most recent episode unplayed
|
2022-12-22 23:38:55 +01:00
|
|
|
let episodeIndex = episodesInListeningOrder.findLastIndex((ep) => {
|
|
|
|
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, ep.id)
|
2022-03-26 23:41:26 +01:00
|
|
|
return !podcastProgress || !podcastProgress.isFinished
|
|
|
|
})
|
2022-08-28 20:12:38 +02:00
|
|
|
if (episodeIndex < 0) episodeIndex = 0
|
|
|
|
|
2022-09-02 00:11:57 +02:00
|
|
|
episodeId = episodesInListeningOrder[episodeIndex].id
|
|
|
|
|
|
|
|
for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) {
|
|
|
|
const episode = episodesInListeningOrder[i]
|
|
|
|
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, episode.id)
|
|
|
|
if (!podcastProgress || !podcastProgress.isFinished) {
|
|
|
|
queueItems.push({
|
|
|
|
libraryItemId: this.libraryItemId,
|
2022-11-12 23:48:35 +01:00
|
|
|
libraryId: this.libraryId,
|
2022-09-02 00:11:57 +02:00
|
|
|
episodeId: episode.id,
|
|
|
|
title: episode.title,
|
|
|
|
subtitle: this.title,
|
2023-02-27 19:04:26 +01:00
|
|
|
caption: episode.publishedAt ? `Published ${this.$formatDate(episode.publishedAt, this.dateFormat)}` : 'Unknown publish date',
|
2022-09-02 00:11:57 +02:00
|
|
|
duration: episode.audioFile.duration || null,
|
|
|
|
coverPath: this.libraryItem.media.coverPath || null
|
|
|
|
})
|
|
|
|
}
|
2022-08-28 20:12:38 +02:00
|
|
|
}
|
2022-11-12 23:48:35 +01:00
|
|
|
} else {
|
|
|
|
const queueItem = {
|
|
|
|
libraryItemId: this.libraryItemId,
|
|
|
|
libraryId: this.libraryId,
|
|
|
|
episodeId: null,
|
|
|
|
title: this.title,
|
|
|
|
subtitle: this.authors.map((au) => au.name).join(', '),
|
|
|
|
caption: '',
|
|
|
|
duration: this.duration || null,
|
|
|
|
coverPath: this.media.coverPath || null
|
|
|
|
}
|
|
|
|
queueItems.push(queueItem)
|
2022-03-26 23:41:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.$eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.libraryItem.id,
|
2022-07-30 02:06:52 +02:00
|
|
|
episodeId,
|
2022-08-28 20:12:38 +02:00
|
|
|
startTime,
|
|
|
|
queueItems
|
2022-03-26 23:41:26 +01:00
|
|
|
})
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
editClick() {
|
|
|
|
this.$store.commit('setBookshelfBookIds', [])
|
|
|
|
this.$store.commit('showEditModal', this.libraryItem)
|
|
|
|
},
|
2022-03-26 17:59:34 +01:00
|
|
|
libraryItemUpdated(libraryItem) {
|
|
|
|
if (libraryItem.id === this.libraryItemId) {
|
|
|
|
console.log('Item was updated', libraryItem)
|
|
|
|
this.libraryItem = libraryItem
|
|
|
|
}
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
|
|
|
clearProgressClick() {
|
2023-05-20 22:19:09 +02:00
|
|
|
if (!this.userMediaProgress) return
|
2022-03-11 01:45:02 +01:00
|
|
|
if (confirm(`Are you sure you want to reset your progress?`)) {
|
|
|
|
this.resettingProgress = true
|
|
|
|
this.$axios
|
2023-05-20 22:19:09 +02:00
|
|
|
.$delete(`/api/me/progress/${this.userMediaProgress.id}`)
|
2022-03-11 01:45:02 +01:00
|
|
|
.then(() => {
|
|
|
|
console.log('Progress reset complete')
|
|
|
|
this.$toast.success(`Your progress was reset`)
|
|
|
|
this.resettingProgress = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Progress reset failed', error)
|
|
|
|
this.resettingProgress = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2022-05-02 23:42:30 +02:00
|
|
|
clickRSSFeed() {
|
2022-12-31 22:26:37 +01:00
|
|
|
this.$store.commit('globals/setRSSFeedOpenCloseModal', {
|
|
|
|
id: this.libraryItemId,
|
|
|
|
name: this.title,
|
|
|
|
type: 'item',
|
|
|
|
feed: this.rssFeed,
|
|
|
|
hasEpisodesWithoutPubDate: this.podcastEpisodes.some((ep) => !ep.pubDate)
|
|
|
|
})
|
2022-05-02 21:41:59 +02:00
|
|
|
},
|
2022-04-24 02:41:06 +02:00
|
|
|
episodeDownloadQueued(episodeDownload) {
|
|
|
|
if (episodeDownload.libraryItemId === this.libraryItemId) {
|
|
|
|
this.episodeDownloadsQueued.push(episodeDownload)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
episodeDownloadStarted(episodeDownload) {
|
|
|
|
if (episodeDownload.libraryItemId === this.libraryItemId) {
|
|
|
|
this.episodeDownloadsQueued = this.episodeDownloadsQueued.filter((d) => d.id !== episodeDownload.id)
|
|
|
|
this.episodesDownloading.push(episodeDownload)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
episodeDownloadFinished(episodeDownload) {
|
|
|
|
if (episodeDownload.libraryItemId === this.libraryItemId) {
|
|
|
|
this.episodeDownloadsQueued = this.episodeDownloadsQueued.filter((d) => d.id !== episodeDownload.id)
|
|
|
|
this.episodesDownloading = this.episodesDownloading.filter((d) => d.id !== episodeDownload.id)
|
|
|
|
}
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
|
|
|
rssFeedOpen(data) {
|
2022-06-08 01:29:43 +02:00
|
|
|
if (data.entityId === this.libraryItemId) {
|
2022-05-02 23:42:30 +02:00
|
|
|
console.log('RSS Feed Opened', data)
|
2022-12-26 23:58:36 +01:00
|
|
|
this.rssFeed = data
|
2022-05-02 23:42:30 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
rssFeedClosed(data) {
|
2022-06-08 01:29:43 +02:00
|
|
|
if (data.entityId === this.libraryItemId) {
|
2022-05-02 23:42:30 +02:00
|
|
|
console.log('RSS Feed Closed', data)
|
2022-12-26 23:58:36 +01:00
|
|
|
this.rssFeed = null
|
2022-05-02 23:42:30 +02:00
|
|
|
}
|
2022-11-12 23:48:35 +01:00
|
|
|
},
|
|
|
|
queueBtnClick() {
|
|
|
|
if (this.isQueued) {
|
|
|
|
// Remove from queue
|
|
|
|
this.$store.commit('removeItemFromQueue', { libraryItemId: this.libraryItemId })
|
|
|
|
} else {
|
|
|
|
// Add to queue
|
|
|
|
|
|
|
|
const queueItem = {
|
|
|
|
libraryItemId: this.libraryItemId,
|
|
|
|
libraryId: this.libraryId,
|
|
|
|
episodeId: null,
|
|
|
|
title: this.title,
|
|
|
|
subtitle: this.authors.map((au) => au.name).join(', '),
|
|
|
|
caption: '',
|
|
|
|
duration: this.duration || null,
|
|
|
|
coverPath: this.media.coverPath || null
|
|
|
|
}
|
|
|
|
this.$store.commit('addItemToQueue', queueItem)
|
|
|
|
}
|
2023-04-14 01:03:39 +02:00
|
|
|
},
|
|
|
|
downloadLibraryItem() {
|
2023-05-28 22:10:34 +02:00
|
|
|
this.$downloadFile(this.downloadUrl)
|
2023-04-14 01:03:39 +02:00
|
|
|
},
|
|
|
|
deleteLibraryItem() {
|
|
|
|
const payload = {
|
2023-10-20 23:08:57 +02:00
|
|
|
message: this.$strings.MessageConfirmDeleteLibraryItem,
|
|
|
|
checkboxLabel: this.$strings.LabelDeleteFromFileSystemCheckbox,
|
2023-04-14 23:44:41 +02:00
|
|
|
yesButtonText: this.$strings.ButtonDelete,
|
|
|
|
yesButtonColor: 'error',
|
2023-11-09 23:36:28 +01:00
|
|
|
checkboxDefaultValue: !Number(localStorage.getItem('softDeleteDefault') || 0),
|
2023-04-14 23:44:41 +02:00
|
|
|
callback: (confirmed, hardDelete) => {
|
2023-04-14 01:03:39 +02:00
|
|
|
if (confirmed) {
|
2023-11-09 23:36:28 +01:00
|
|
|
localStorage.setItem('softDeleteDefault', hardDelete ? 0 : 1)
|
|
|
|
|
2023-04-14 01:03:39 +02:00
|
|
|
this.$axios
|
2023-04-14 23:44:41 +02:00
|
|
|
.$delete(`/api/items/${this.libraryItemId}?hard=${hardDelete ? 1 : 0}`)
|
2023-04-14 01:03:39 +02:00
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('Item deleted')
|
2023-04-14 23:44:41 +02:00
|
|
|
this.$router.replace(`/library/${this.libraryId}`)
|
2023-04-14 01:03:39 +02:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to delete item', error)
|
|
|
|
this.$toast.error('Failed to delete item')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
type: 'yesNo'
|
|
|
|
}
|
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
|
|
|
},
|
2023-05-30 00:38:38 +02:00
|
|
|
sendToDevice(deviceName) {
|
|
|
|
const payload = {
|
|
|
|
message: this.$getString('MessageConfirmSendEbookToDevice', [this.ebookFile.ebookFormat, this.title, deviceName]),
|
|
|
|
callback: (confirmed) => {
|
|
|
|
if (confirmed) {
|
|
|
|
const payload = {
|
|
|
|
libraryItemId: this.libraryItemId,
|
|
|
|
deviceName
|
|
|
|
}
|
|
|
|
this.processing = true
|
|
|
|
this.$axios
|
|
|
|
.$post(`/api/emails/send-ebook-to-device`, payload)
|
|
|
|
.then(() => {
|
|
|
|
this.$toast.success(this.$getString('ToastSendEbookToDeviceSuccess', [deviceName]))
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
2023-05-30 23:37:24 +02:00
|
|
|
console.error('Failed to send ebook to device', error)
|
2023-05-30 00:38:38 +02:00
|
|
|
this.$toast.error(this.$strings.ToastSendEbookToDeviceFailed)
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.processing = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
type: 'yesNo'
|
|
|
|
}
|
|
|
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
|
|
|
},
|
|
|
|
contextMenuAction({ action, data }) {
|
2023-04-14 01:03:39 +02:00
|
|
|
if (action === 'collections') {
|
|
|
|
this.$store.commit('setSelectedLibraryItem', this.libraryItem)
|
|
|
|
this.$store.commit('globals/setShowCollectionsModal', true)
|
|
|
|
} else if (action === 'playlists') {
|
|
|
|
this.$store.commit('globals/setSelectedPlaylistItems', [{ libraryItem: this.libraryItem }])
|
|
|
|
this.$store.commit('globals/setShowPlaylistsModal', true)
|
|
|
|
} else if (action === 'bookmarks') {
|
|
|
|
this.showBookmarksModal = true
|
|
|
|
} else if (action === 'rss-feeds') {
|
|
|
|
this.clickRSSFeed()
|
|
|
|
} else if (action === 'download') {
|
|
|
|
this.downloadLibraryItem()
|
|
|
|
} else if (action === 'delete') {
|
|
|
|
this.deleteLibraryItem()
|
2023-05-30 00:38:38 +02:00
|
|
|
} else if (action === 'sendToDevice') {
|
|
|
|
this.sendToDevice(data)
|
2023-04-14 01:03:39 +02:00
|
|
|
}
|
2022-03-11 01:45:02 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2023-03-05 17:35:34 +01:00
|
|
|
this.episodeDownloadsQueued = this.libraryItem.episodeDownloadsQueued || []
|
|
|
|
this.episodesDownloading = this.libraryItem.episodesDownloading || []
|
2022-04-24 02:41:06 +02:00
|
|
|
|
2022-03-26 17:59:34 +01:00
|
|
|
// use this items library id as the current
|
2022-03-11 01:45:02 +01:00
|
|
|
if (this.libraryId) {
|
|
|
|
this.$store.commit('libraries/setCurrentLibrary', this.libraryId)
|
|
|
|
}
|
2023-09-03 00:49:28 +02:00
|
|
|
this.$eventBus.$on(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
|
2022-03-26 17:59:34 +01:00
|
|
|
this.$root.socket.on('item_updated', this.libraryItemUpdated)
|
2022-05-02 23:42:30 +02:00
|
|
|
this.$root.socket.on('rss_feed_open', this.rssFeedOpen)
|
|
|
|
this.$root.socket.on('rss_feed_closed', this.rssFeedClosed)
|
2022-04-24 02:41:06 +02:00
|
|
|
this.$root.socket.on('episode_download_queued', this.episodeDownloadQueued)
|
|
|
|
this.$root.socket.on('episode_download_started', this.episodeDownloadStarted)
|
|
|
|
this.$root.socket.on('episode_download_finished', this.episodeDownloadFinished)
|
2022-03-11 01:45:02 +01:00
|
|
|
},
|
2022-03-26 17:59:34 +01:00
|
|
|
beforeDestroy() {
|
2023-09-03 00:49:28 +02:00
|
|
|
this.$eventBus.$off(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
|
2022-03-26 17:59:34 +01:00
|
|
|
this.$root.socket.off('item_updated', this.libraryItemUpdated)
|
2022-05-02 23:42:30 +02:00
|
|
|
this.$root.socket.off('rss_feed_open', this.rssFeedOpen)
|
|
|
|
this.$root.socket.off('rss_feed_closed', this.rssFeedClosed)
|
2022-04-24 02:41:06 +02:00
|
|
|
this.$root.socket.off('episode_download_queued', this.episodeDownloadQueued)
|
|
|
|
this.$root.socket.off('episode_download_started', this.episodeDownloadStarted)
|
|
|
|
this.$root.socket.off('episode_download_finished', this.episodeDownloadFinished)
|
2022-03-26 17:59:34 +01:00
|
|
|
}
|
2022-03-11 01:45:02 +01:00
|
|
|
}
|
|
|
|
</script>
|