mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-06 02:32:44 +02:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d05e9ebfdd | |||
| 92c2c53c09 | |||
| 80f8a784c8 | |||
| de9c0ef034 | |||
| b32b99418a | |||
| 98c1ee01fd | |||
| 97a065030e | |||
| ee1dc92898 | |||
| 74d2987310 | |||
| c20aaf3cb2 | |||
| 994eb2862e | |||
| ff1eeda468 | |||
| 7d9ed75a28 | |||
| 09aed354b3 | |||
| e3425acd75 | |||
| 03e39640be | |||
| 48f0e039e5 | |||
| aa872948d5 | |||
| 88e2bac3f5 | |||
| 18c1d8f1a3 | |||
| b9dee8704f |
+3
-6
@@ -1,18 +1,15 @@
|
|||||||
### STAGE 0: FFMPEG ###
|
### STAGE 0: Build client ###
|
||||||
FROM jrottenberg/ffmpeg:4.1-alpine AS ffmpeg
|
|
||||||
|
|
||||||
### STAGE 1: Build client ###
|
|
||||||
FROM node:12-alpine AS build
|
FROM node:12-alpine AS build
|
||||||
WORKDIR /client
|
WORKDIR /client
|
||||||
COPY /client /client
|
COPY /client /client
|
||||||
RUN npm install
|
RUN npm install
|
||||||
RUN npm run generate
|
RUN npm run generate
|
||||||
|
|
||||||
### STAGE 2: Build server ###
|
### STAGE 1: Build server ###
|
||||||
FROM node:12-alpine
|
FROM node:12-alpine
|
||||||
|
RUN apk update && apk add --no-cache --update ffmpeg
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
COPY --from=build /client/dist /client/dist
|
COPY --from=build /client/dist /client/dist
|
||||||
COPY --from=ffmpeg / /
|
|
||||||
COPY index.js index.js
|
COPY index.js index.js
|
||||||
COPY package.json package.json
|
COPY package.json package.json
|
||||||
COPY server server
|
COPY server server
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
@import url('./transitions.css');
|
@import './fonts.css';
|
||||||
@import url('./draggable.css');
|
@import './transitions.css';
|
||||||
|
@import './draggable.css';
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/* fallback */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Material Icons';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src: url(/fonts/material-icons.woff2) format('woff2');
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-icons {
|
||||||
|
font-family: 'Material Icons';
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
line-height: 1;
|
||||||
|
letter-spacing: normal;
|
||||||
|
text-transform: none;
|
||||||
|
display: inline-block;
|
||||||
|
white-space: nowrap;
|
||||||
|
word-wrap: normal;
|
||||||
|
direction: ltr;
|
||||||
|
-webkit-font-feature-settings: 'liga';
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
.material-icons:not(.text-sm):not(.text-md):not(.text-base):not(.text-lg):not(.text-xl):not(.text-2xl):not(.text-3xl):not(.text-4xl):not(.text-5xl):not(.text-6xl) {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Gentium Book Basic';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/fonts/GentiumBookBasic.woff2) format('woff2');
|
||||||
|
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||||
|
}
|
||||||
|
/* latin */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Gentium Book Basic';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
font-display: swap;
|
||||||
|
src: url(/fonts/GentiumBookBasic.woff2) format('woff2');
|
||||||
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="absolute right-32 top-0 bottom-0">
|
<div class="absolute right-32 top-0 bottom-0">
|
||||||
<controls-volume-control v-model="volume" @input="updateVolume" />
|
<controls-volume-control ref="volumeControl" v-model="volume" @input="updateVolume" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex my-2">
|
<div class="flex my-2">
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
@@ -91,7 +91,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
hlsInstance: null,
|
hlsInstance: null,
|
||||||
staleHlsInstance: null,
|
staleHlsInstance: null,
|
||||||
volume: 0.5,
|
volume: 1,
|
||||||
playbackRate: 1,
|
playbackRate: 1,
|
||||||
trackWidth: 0,
|
trackWidth: 0,
|
||||||
isPaused: true,
|
isPaused: true,
|
||||||
@@ -451,7 +451,8 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
showChapters() {
|
showChapters() {
|
||||||
this.showChaptersModal = true
|
if (!this.chapters.length) return
|
||||||
|
this.showChaptersModal = !this.showChaptersModal
|
||||||
},
|
},
|
||||||
play() {
|
play() {
|
||||||
if (!this.$refs.audio) {
|
if (!this.$refs.audio) {
|
||||||
@@ -486,6 +487,9 @@ export default {
|
|||||||
this.playbackRate = this.$store.getters['user/getUserSetting']('playbackRate') || 1
|
this.playbackRate = this.$store.getters['user/getUserSetting']('playbackRate') || 1
|
||||||
|
|
||||||
this.audioEl = this.$refs.audio
|
this.audioEl = this.$refs.audio
|
||||||
|
this.setTrackWidth()
|
||||||
|
},
|
||||||
|
setTrackWidth() {
|
||||||
if (this.$refs.track) {
|
if (this.$refs.track) {
|
||||||
this.trackWidth = this.$refs.track.clientWidth
|
this.trackWidth = this.$refs.track.clientWidth
|
||||||
} else {
|
} else {
|
||||||
@@ -496,14 +500,66 @@ export default {
|
|||||||
if (settings.playbackRate && this.playbackRate !== settings.playbackRate) {
|
if (settings.playbackRate && this.playbackRate !== settings.playbackRate) {
|
||||||
this.updatePlaybackRate(settings.playbackRate)
|
this.updatePlaybackRate(settings.playbackRate)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
volumeUp() {
|
||||||
|
if (this.volume >= 1) return
|
||||||
|
this.volume = Math.min(1, this.volume + 0.1)
|
||||||
|
this.updateVolume(this.volume)
|
||||||
|
},
|
||||||
|
volumeDown() {
|
||||||
|
if (this.volume <= 0) return
|
||||||
|
this.volume = Math.max(0, this.volume - 0.1)
|
||||||
|
this.updateVolume(this.volume)
|
||||||
|
},
|
||||||
|
toggleMute() {
|
||||||
|
if (this.$refs.volumeControl && this.$refs.volumeControl.toggleMute) {
|
||||||
|
this.$refs.volumeControl.toggleMute()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
increasePlaybackRate() {
|
||||||
|
var rates = [0.25, 0.5, 0.8, 1, 1.3, 1.5, 2, 2.5, 3]
|
||||||
|
var currentRateIndex = rates.findIndex((r) => r === this.playbackRate)
|
||||||
|
if (currentRateIndex >= rates.length - 1) return
|
||||||
|
this.playbackRate = rates[currentRateIndex + 1] || 1
|
||||||
|
this.playbackRateChanged(this.playbackRate)
|
||||||
|
},
|
||||||
|
decreasePlaybackRate() {
|
||||||
|
var rates = [0.25, 0.5, 0.8, 1, 1.3, 1.5, 2, 2.5, 3]
|
||||||
|
var currentRateIndex = rates.findIndex((r) => r === this.playbackRate)
|
||||||
|
if (currentRateIndex <= 0) return
|
||||||
|
this.playbackRate = rates[currentRateIndex - 1] || 1
|
||||||
|
this.playbackRateChanged(this.playbackRate)
|
||||||
|
},
|
||||||
|
closePlayer() {
|
||||||
|
if (this.loading) return
|
||||||
|
this.$emit('close')
|
||||||
|
},
|
||||||
|
hotkey(action) {
|
||||||
|
if (action === 'Space') this.playPauseClick()
|
||||||
|
else if (action === 'ArrowRight') this.forward10()
|
||||||
|
else if (action === 'ArrowLeft') this.backward10()
|
||||||
|
else if (action === 'ArrowUp') this.volumeUp()
|
||||||
|
else if (action === 'ArrowDown') this.volumeDown()
|
||||||
|
else if (action === 'KeyM') this.toggleMute()
|
||||||
|
else if (action === 'KeyL') this.showChapters()
|
||||||
|
else if (action === 'Shift-ArrowUp') this.increasePlaybackRate()
|
||||||
|
else if (action === 'Shift-ArrowDown') this.decreasePlaybackRate()
|
||||||
|
else if (action === 'Escape') this.closePlayer()
|
||||||
|
},
|
||||||
|
windowResize() {
|
||||||
|
this.setTrackWidth()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
window.addEventListener('resize', this.windowResize)
|
||||||
this.$store.commit('user/addSettingsListener', { id: 'audioplayer', meth: this.settingsUpdated })
|
this.$store.commit('user/addSettingsListener', { id: 'audioplayer', meth: this.settingsUpdated })
|
||||||
this.init()
|
this.init()
|
||||||
|
this.$eventBus.$on('player-hotkey', this.hotkey)
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
window.removeEventListener('resize', this.windowResize)
|
||||||
this.$store.commit('user/removeSettingsListener', 'audioplayer')
|
this.$store.commit('user/removeSettingsListener', 'audioplayer')
|
||||||
|
this.$eventBus.$off('player-hotkey', this.hotkey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -8,13 +8,6 @@
|
|||||||
</a>
|
</a>
|
||||||
<h1 class="text-2xl font-book mr-6">AudioBookshelf</h1>
|
<h1 class="text-2xl font-book mr-6">AudioBookshelf</h1>
|
||||||
|
|
||||||
<!-- <div class="bg-black bg-opacity-20 rounded-md py-1.5 px-3 flex items-center text-white text-opacity-70 cursor-pointer hover:bg-opacity-10 hover:text-opacity-90" @click="clickLibrary">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4" />
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
<p class="text-sm leading-3 font-sans pl-2">{{ libraryName }}</p>
|
|
||||||
</div> -->
|
|
||||||
<ui-libraries-dropdown />
|
<ui-libraries-dropdown />
|
||||||
|
|
||||||
<controls-global-search />
|
<controls-global-search />
|
||||||
@@ -133,9 +126,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clickLibrary() {
|
|
||||||
this.$store.commit('libraries/setShowModal', true)
|
|
||||||
},
|
|
||||||
async back() {
|
async back() {
|
||||||
var popped = await this.$store.dispatch('popRoute')
|
var popped = await this.$store.dispatch('popRoute')
|
||||||
var backTo = popped || '/'
|
var backTo = popped || '/'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="bookshelf" ref="wrapper" class="w-full h-full overflow-y-scroll relative">
|
<div id="bookshelf" ref="wrapper" class="w-full h-full overflow-y-scroll relative">
|
||||||
<!-- Cover size widget -->
|
<!-- Cover size widget -->
|
||||||
<div v-show="!isSelectionMode" class="fixed bottom-2 right-4 z-20">
|
<div v-show="!isSelectionMode" class="fixed bottom-2 right-4 z-30">
|
||||||
<div class="rounded-full py-1 bg-primary px-2 border border-black-100 text-center flex items-center box-shadow-md" @mousedown.prevent @mouseup.prevent>
|
<div class="rounded-full py-1 bg-primary px-2 border border-black-100 text-center flex items-center box-shadow-md" @mousedown.prevent @mouseup.prevent>
|
||||||
<span class="material-icons" :class="selectedSizeIndex === 0 ? 'text-gray-400' : 'hover:text-yellow-300 cursor-pointer'" style="font-size: 0.9rem" @mousedown.prevent @click="decreaseSize">remove</span>
|
<span class="material-icons" :class="selectedSizeIndex === 0 ? 'text-gray-400' : 'hover:text-yellow-300 cursor-pointer'" style="font-size: 0.9rem" @mousedown.prevent @click="decreaseSize">remove</span>
|
||||||
<p class="px-2 font-mono">{{ bookCoverWidth }}</p>
|
<p class="px-2 font-mono">{{ bookCoverWidth }}</p>
|
||||||
@@ -16,6 +16,14 @@
|
|||||||
<ui-btn color="success" class="w-52" @click="scan">Scan Audiobooks</ui-btn>
|
<ui-btn color="success" class="w-52" @click="scan">Scan Audiobooks</ui-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="page === 'search'" id="bookshelf-categorized" class="w-full flex flex-col items-center">
|
||||||
|
<template v-for="(shelf, index) in categorizedShelves">
|
||||||
|
<app-book-shelf-row :key="index" :index="index" :shelf="shelf" :size-multiplier="sizeMultiplier" :book-cover-width="bookCoverWidth" />
|
||||||
|
</template>
|
||||||
|
<div v-show="!categorizedShelves.length" class="w-full py-16 text-center text-xl">
|
||||||
|
<div class="py-4 mb-6"><p class="text-2xl">No Results</p></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-else id="bookshelf" class="w-full flex flex-col items-center">
|
<div v-else id="bookshelf" class="w-full flex flex-col items-center">
|
||||||
<template v-for="(shelf, index) in shelves">
|
<template v-for="(shelf, index) in shelves">
|
||||||
<div :key="index" class="w-full bookshelfRow relative">
|
<div :key="index" class="w-full bookshelfRow relative">
|
||||||
@@ -45,8 +53,8 @@ export default {
|
|||||||
page: String,
|
page: String,
|
||||||
selectedSeries: String,
|
selectedSeries: String,
|
||||||
searchResults: {
|
searchResults: {
|
||||||
type: Array,
|
type: Object,
|
||||||
default: () => []
|
default: () => {}
|
||||||
},
|
},
|
||||||
searchQuery: String
|
searchQuery: String
|
||||||
},
|
},
|
||||||
@@ -74,7 +82,7 @@ export default {
|
|||||||
},
|
},
|
||||||
searchResults() {
|
searchResults() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$store.commit('audiobooks/setSearchResults', this.searchResults)
|
// this.$store.commit('audiobooks/setSearchResults', this.searchResults)
|
||||||
this.setBookshelfEntities()
|
this.setBookshelfEntities()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -94,6 +102,9 @@ export default {
|
|||||||
audiobooks() {
|
audiobooks() {
|
||||||
return this.$store.state.audiobooks.audiobooks
|
return this.$store.state.audiobooks.audiobooks
|
||||||
},
|
},
|
||||||
|
sizeMultiplier() {
|
||||||
|
return this.bookCoverWidth / 120
|
||||||
|
},
|
||||||
bookCoverWidth() {
|
bookCoverWidth() {
|
||||||
return this.availableSizes[this.selectedSizeIndex]
|
return this.availableSizes[this.selectedSizeIndex]
|
||||||
},
|
},
|
||||||
@@ -122,11 +133,54 @@ export default {
|
|||||||
showGroups() {
|
showGroups() {
|
||||||
return this.page !== '' && this.page !== 'search' && !this.selectedSeries
|
return this.page !== '' && this.page !== 'search' && !this.selectedSeries
|
||||||
},
|
},
|
||||||
|
categorizedShelves() {
|
||||||
|
if (this.page !== 'search') return []
|
||||||
|
var audiobookSearchResults = this.searchResults ? this.searchResults.audiobooks || [] : []
|
||||||
|
const shelves = []
|
||||||
|
|
||||||
|
if (audiobookSearchResults.length) {
|
||||||
|
shelves.push({
|
||||||
|
label: 'Books',
|
||||||
|
books: audiobookSearchResults.map((absr) => absr.audiobook)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.searchResults.series && this.searchResults.series.length) {
|
||||||
|
var seriesGroups = this.searchResults.series.map((seriesResult) => {
|
||||||
|
return {
|
||||||
|
type: 'series',
|
||||||
|
name: seriesResult.series || '',
|
||||||
|
books: seriesResult.audiobooks || []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
shelves.push({
|
||||||
|
label: 'Series',
|
||||||
|
series: seriesGroups
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.searchResults.tags && this.searchResults.tags.length) {
|
||||||
|
var tagGroups = this.searchResults.tags.map((tagResult) => {
|
||||||
|
return {
|
||||||
|
type: 'tags',
|
||||||
|
name: tagResult.tag || '',
|
||||||
|
books: tagResult.audiobooks || []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
shelves.push({
|
||||||
|
label: 'Tags',
|
||||||
|
series: tagGroups
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return shelves
|
||||||
|
},
|
||||||
entities() {
|
entities() {
|
||||||
if (this.page === '') {
|
if (this.page === '') {
|
||||||
return this.$store.getters['audiobooks/getFilteredAndSorted']()
|
return this.$store.getters['audiobooks/getFilteredAndSorted']()
|
||||||
} else if (this.page === 'search') {
|
} else if (this.page === 'search') {
|
||||||
return this.searchResults || []
|
var audiobookSearchResults = this.searchResults ? this.searchResults.audiobooks || [] : []
|
||||||
|
return audiobookSearchResults.map((absr) => absr.audiobook)
|
||||||
} else {
|
} else {
|
||||||
var seriesGroups = this.$store.getters['audiobooks/getSeriesGroups']()
|
var seriesGroups = this.$store.getters['audiobooks/getSeriesGroups']()
|
||||||
if (this.selectedSeries) {
|
if (this.selectedSeries) {
|
||||||
|
|||||||
@@ -51,9 +51,6 @@ export default {
|
|||||||
sizeMultiplier() {
|
sizeMultiplier() {
|
||||||
return this.bookCoverWidth / 120
|
return this.bookCoverWidth / 120
|
||||||
},
|
},
|
||||||
signSizeMultiplier() {
|
|
||||||
return (1 - this.sizeMultiplier) / 2 + this.sizeMultiplier
|
|
||||||
},
|
|
||||||
paddingX() {
|
paddingX() {
|
||||||
return 16 * this.sizeMultiplier
|
return 16 * this.sizeMultiplier
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,11 +2,23 @@
|
|||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div ref="shelf" class="w-full max-w-full bookshelfRowCategorized relative overflow-x-scroll overflow-y-hidden z-10" :style="{ paddingLeft: 2.5 * sizeMultiplier + 'rem' }" @scroll="scrolled">
|
<div ref="shelf" class="w-full max-w-full bookshelfRowCategorized relative overflow-x-scroll overflow-y-hidden z-10" :style="{ paddingLeft: 2.5 * sizeMultiplier + 'rem' }" @scroll="scrolled">
|
||||||
<div class="w-full h-full" :style="{ marginTop: sizeMultiplier + 'rem' }">
|
<div class="w-full h-full" :style="{ marginTop: sizeMultiplier + 'rem' }">
|
||||||
<div class="flex items-center -mb-2">
|
<div v-if="shelf.books" class="flex items-center -mb-2">
|
||||||
<template v-for="entity in shelf.books">
|
<template v-for="entity in shelf.books">
|
||||||
<cards-book-card :key="entity.id" :width="bookCoverWidth" :user-progress="userAudiobooks[entity.id]" :audiobook="entity" @hook:updated="updatedBookCard" @edit="editBook" />
|
<cards-book-card :key="entity.id" :width="bookCoverWidth" :user-progress="userAudiobooks[entity.id]" :audiobook="entity" @hook:updated="updatedBookCard" @edit="editBook" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="shelf.series" class="flex items-center -mb-2">
|
||||||
|
<template v-for="entity in shelf.series">
|
||||||
|
<cards-group-card :key="entity.name" :width="bookCoverWidth" :group="entity" @click="$emit('clickSeries', entity)" />
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="shelf.tags" class="flex items-center -mb-2">
|
||||||
|
<template v-for="entity in shelf.tags">
|
||||||
|
<nuxt-link :key="entity.name" :to="`/library/${currentLibraryId}/bookshelf?filter=tags.${$encode(entity.name)}`">
|
||||||
|
<cards-group-card :width="bookCoverWidth" :group="entity" />
|
||||||
|
</nuxt-link>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -67,7 +79,6 @@ export default {
|
|||||||
},
|
},
|
||||||
scrollLeft() {
|
scrollLeft() {
|
||||||
if (!this.$refs.shelf) {
|
if (!this.$refs.shelf) {
|
||||||
console.error('No Shelf', this.index)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.isScrolling = true
|
this.isScrolling = true
|
||||||
@@ -75,7 +86,6 @@ export default {
|
|||||||
},
|
},
|
||||||
scrollRight() {
|
scrollRight() {
|
||||||
if (!this.$refs.shelf) {
|
if (!this.$refs.shelf) {
|
||||||
console.error('No Shelf', this.index)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.isScrolling = true
|
this.isScrolling = true
|
||||||
@@ -89,7 +99,6 @@ export default {
|
|||||||
},
|
},
|
||||||
checkCanScroll() {
|
checkCanScroll() {
|
||||||
if (!this.$refs.shelf) {
|
if (!this.$refs.shelf) {
|
||||||
console.error('No Shelf', this.index)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var clientWidth = this.$refs.shelf.clientWidth
|
var clientWidth = this.$refs.shelf.clientWidth
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ export default {
|
|||||||
isHome: Boolean,
|
isHome: Boolean,
|
||||||
selectedSeries: String,
|
selectedSeries: String,
|
||||||
searchResults: {
|
searchResults: {
|
||||||
type: Array,
|
type: Object,
|
||||||
default: () => []
|
default: () => {}
|
||||||
},
|
},
|
||||||
searchQuery: String
|
searchQuery: String
|
||||||
},
|
},
|
||||||
@@ -60,7 +60,8 @@ export default {
|
|||||||
if (this.page === '') {
|
if (this.page === '') {
|
||||||
return this.$store.getters['audiobooks/getFiltered']().length
|
return this.$store.getters['audiobooks/getFiltered']().length
|
||||||
} else if (this.page === 'search') {
|
} else if (this.page === 'search') {
|
||||||
return (this.searchResults || []).length
|
var audiobookSearchResults = this.searchResults ? this.searchResults.audiobooks || [] : []
|
||||||
|
return audiobookSearchResults.length
|
||||||
} else {
|
} else {
|
||||||
var groups = this.$store.getters['audiobooks/getSeriesGroups']()
|
var groups = this.$store.getters['audiobooks/getSeriesGroups']()
|
||||||
if (this.selectedSeries) {
|
if (this.selectedSeries) {
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-44 fixed left-0 top-16 z-40 h-full bg-bg bg-opacity-70 shadow-lg border-r border-white border-opacity-5 py-4">
|
||||||
|
<nuxt-link to="/config" class="w-full px-4 h-12 border-b border-opacity-0 flex items-center cursor-pointer relative" :class="routeName === 'config' ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'">
|
||||||
|
<p>Settings</p>
|
||||||
|
<div v-show="routeName === 'config'" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
||||||
|
</nuxt-link>
|
||||||
|
<nuxt-link to="/config/libraries" class="w-full px-4 h-12 border-b border-opacity-0 flex items-center cursor-pointer relative" :class="routeName === 'config-libraries' ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'">
|
||||||
|
<p>Libraries</p>
|
||||||
|
<div v-show="routeName === 'config-libraries'" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
||||||
|
</nuxt-link>
|
||||||
|
<nuxt-link to="/config/users" class="w-full px-4 h-12 border-b border-opacity-0 flex items-center cursor-pointer relative" :class="routeName === 'config-users' ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'">
|
||||||
|
<p>Users</p>
|
||||||
|
<div v-show="routeName === 'config-users'" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
||||||
|
</nuxt-link>
|
||||||
|
<nuxt-link to="/config/backups" class="w-full px-4 h-12 border-b border-opacity-0 flex items-center cursor-pointer relative" :class="routeName === 'config-backups' ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'">
|
||||||
|
<p>Backups</p>
|
||||||
|
<div v-show="routeName === 'config-backups'" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
||||||
|
</nuxt-link>
|
||||||
|
<nuxt-link to="/config/log" class="w-full px-4 h-12 border-b border-opacity-0 flex items-center cursor-pointer relative" :class="routeName === 'config-log' ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'">
|
||||||
|
<p>Log</p>
|
||||||
|
<div v-show="routeName === 'config-log'" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
||||||
|
</nuxt-link>
|
||||||
|
|
||||||
|
<div class="w-full h-12 px-4 border-t border-black border-opacity-20 absolute bottom-20 left-0 flex flex-col justify-center">
|
||||||
|
<p class="font-mono text-sm">v{{ $config.version }}</p>
|
||||||
|
<a v-if="hasUpdate" :href="githubTagUrl" target="_blank" class="text-warning text-sm">Update available: {{ latestVersion }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
routeName() {
|
||||||
|
return this.$route.name
|
||||||
|
},
|
||||||
|
versionData() {
|
||||||
|
return this.$store.state.versionData || {}
|
||||||
|
},
|
||||||
|
hasUpdate() {
|
||||||
|
return !!this.versionData.hasUpdate
|
||||||
|
},
|
||||||
|
latestVersion() {
|
||||||
|
return this.versionData.latestVersion
|
||||||
|
},
|
||||||
|
githubTagUrl() {
|
||||||
|
return this.versionData.githubTagUrl
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -1,347 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div v-if="show" class="w-screen h-screen fixed top-0 left-0 z-50 bg-white text-black">
|
|
||||||
<div class="absolute top-4 right-4 z-10">
|
|
||||||
<span class="material-icons cursor-pointer text-4xl" @click="show = false">close</span>
|
|
||||||
</div>
|
|
||||||
<!-- <div v-if="chapters.length" class="absolute top-0 left-0 w-52">
|
|
||||||
<select v-model="selectedChapter" class="w-52" @change="changedChapter">
|
|
||||||
<option v-for="chapter in chapters" :key="chapter.href" :value="chapter.href">{{ chapter.label }}</option>
|
|
||||||
</select>
|
|
||||||
</div> -->
|
|
||||||
<div class="absolute top-4 left-4 font-book">
|
|
||||||
<h1 class="text-2xl mb-1">{{ title || abTitle }}</h1>
|
|
||||||
<p v-if="author || abAuthor">by {{ author || abAuthor }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- EPUB -->
|
|
||||||
<div v-if="ebookType === 'epub'" class="h-full flex items-center">
|
|
||||||
<div style="width: 100px; max-width: 100px" class="h-full flex items-center overflow-x-hidden">
|
|
||||||
<span v-show="hasPrev" class="material-icons text-black text-opacity-30 hover:text-opacity-80 cursor-pointer text-8xl" @mousedown.prevent @click="pageLeft">chevron_left</span>
|
|
||||||
</div>
|
|
||||||
<div id="frame" class="w-full" style="height: 650px">
|
|
||||||
<div id="viewer" class="spreads"></div>
|
|
||||||
|
|
||||||
<div class="px-16 flex justify-center" style="height: 50px">
|
|
||||||
<p class="px-4">{{ progress }}%</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="width: 100px; max-width: 100px" class="h-full flex items-center overflow-x-hidden">
|
|
||||||
<span v-show="hasNext" class="material-icons text-black text-opacity-30 hover:text-opacity-80 cursor-pointer text-8xl" @mousedown.prevent @click="pageRight">chevron_right</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- MOBI/AZW3 -->
|
|
||||||
<div v-else-if="ebookType === 'mobi'" class="h-full max-h-full w-full">
|
|
||||||
<div class="ebook-viewer absolute overflow-y-scroll left-0 right-0 top-12 w-full max-w-4xl m-auto z-10 border border-black border-opacity-20">
|
|
||||||
<iframe title="html-viewer" width="100%"> Loading </iframe>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- PDF -->
|
|
||||||
<div v-else-if="ebookType === 'pdf'" class="h-full flex items-center">
|
|
||||||
<app-pdf-reader :src="ebookUrl" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="absolute bottom-2 left-2">{{ ebookType }}</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ePub from 'epubjs'
|
|
||||||
import MobiParser from '@/assets/ebooks/mobi.js'
|
|
||||||
import HtmlParser from '@/assets/ebooks/htmlParser.js'
|
|
||||||
import defaultCss from '@/assets/ebooks/basic.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
scale: 1,
|
|
||||||
book: null,
|
|
||||||
rendition: null,
|
|
||||||
chapters: [],
|
|
||||||
title: '',
|
|
||||||
author: '',
|
|
||||||
progress: 0,
|
|
||||||
hasNext: true,
|
|
||||||
hasPrev: false,
|
|
||||||
ebookType: '',
|
|
||||||
ebookUrl: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
show(newVal) {
|
|
||||||
if (newVal) {
|
|
||||||
this.init()
|
|
||||||
} else {
|
|
||||||
this.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
show: {
|
|
||||||
get() {
|
|
||||||
return this.$store.state.showEReader
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
this.$store.commit('setShowEReader', val)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
abTitle() {
|
|
||||||
return this.selectedAudiobook.book.title
|
|
||||||
},
|
|
||||||
abAuthor() {
|
|
||||||
return this.selectedAudiobook.book.author
|
|
||||||
},
|
|
||||||
selectedAudiobook() {
|
|
||||||
return this.$store.state.selectedAudiobook
|
|
||||||
},
|
|
||||||
libraryId() {
|
|
||||||
return this.selectedAudiobook.libraryId
|
|
||||||
},
|
|
||||||
folderId() {
|
|
||||||
return this.selectedAudiobook.folderId
|
|
||||||
},
|
|
||||||
ebooks() {
|
|
||||||
return this.selectedAudiobook.ebooks || []
|
|
||||||
},
|
|
||||||
epubEbook() {
|
|
||||||
return this.ebooks.find((eb) => eb.ext === '.epub')
|
|
||||||
},
|
|
||||||
mobiEbook() {
|
|
||||||
return this.ebooks.find((eb) => eb.ext === '.mobi' || eb.ext === '.azw3')
|
|
||||||
},
|
|
||||||
pdfEbook() {
|
|
||||||
return this.ebooks.find((eb) => eb.ext === '.pdf')
|
|
||||||
},
|
|
||||||
userToken() {
|
|
||||||
return this.$store.getters['user/getToken']
|
|
||||||
},
|
|
||||||
selectedAudiobookFile() {
|
|
||||||
return this.$store.state.selectedAudiobookFile
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
getEbookUrl(path) {
|
|
||||||
return `/ebook/${this.libraryId}/${this.folderId}/${path}`
|
|
||||||
},
|
|
||||||
changedChapter() {
|
|
||||||
if (this.rendition) {
|
|
||||||
this.rendition.display(this.selectedChapter)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
pageLeft() {
|
|
||||||
if (this.rendition) {
|
|
||||||
this.rendition.prev()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
pageRight() {
|
|
||||||
if (this.rendition) {
|
|
||||||
this.rendition.next()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
keyUp(e) {
|
|
||||||
if (!this.rendition) {
|
|
||||||
console.error('No rendition')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((e.keyCode || e.which) == 37) {
|
|
||||||
this.rendition.prev()
|
|
||||||
} else if ((e.keyCode || e.which) == 39) {
|
|
||||||
this.rendition.next()
|
|
||||||
} else if ((e.keyCode || e.which) == 27) {
|
|
||||||
this.show = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
registerListeners() {
|
|
||||||
document.addEventListener('keyup', this.keyUp)
|
|
||||||
},
|
|
||||||
unregisterListeners() {
|
|
||||||
document.removeEventListener('keyup', this.keyUp)
|
|
||||||
},
|
|
||||||
init() {
|
|
||||||
this.registerListeners()
|
|
||||||
if (this.selectedAudiobookFile) {
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.selectedAudiobookFile.path)
|
|
||||||
if (this.selectedAudiobookFile.ext === '.pdf') {
|
|
||||||
this.ebookType = 'pdf'
|
|
||||||
} else if (this.selectedAudiobookFile.ext === '.mobi' || this.selectedAudiobookFile.ext === '.azw3') {
|
|
||||||
this.ebookType = 'mobi'
|
|
||||||
this.initMobi()
|
|
||||||
} else if (this.selectedAudiobookFile.ext === '.epub') {
|
|
||||||
this.ebookType = 'epub'
|
|
||||||
this.initEpub()
|
|
||||||
}
|
|
||||||
} else if (this.epubEbook) {
|
|
||||||
this.ebookType = 'epub'
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.epubEbook.path)
|
|
||||||
this.initEpub()
|
|
||||||
} else if (this.mobiEbook) {
|
|
||||||
this.ebookType = 'mobi'
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.mobiEbook.path)
|
|
||||||
this.initMobi()
|
|
||||||
} else if (this.pdfEbook) {
|
|
||||||
this.ebookType = 'pdf'
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.pdfEbook.path)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
addHtmlCss() {
|
|
||||||
let iframe = document.getElementsByTagName('iframe')[0]
|
|
||||||
if (!iframe) return
|
|
||||||
let doc = iframe.contentDocument
|
|
||||||
if (!doc) return
|
|
||||||
let style = doc.createElement('style')
|
|
||||||
style.id = 'default-style'
|
|
||||||
style.textContent = defaultCss
|
|
||||||
doc.head.appendChild(style)
|
|
||||||
},
|
|
||||||
handleIFrameHeight(iFrame) {
|
|
||||||
const isElement = (obj) => !!(obj && obj.nodeType === 1)
|
|
||||||
|
|
||||||
var body = iFrame.contentWindow.document.body,
|
|
||||||
html = iFrame.contentWindow.document.documentElement
|
|
||||||
iFrame.height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight) * 2
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
let lastchild = body.lastElementChild
|
|
||||||
let lastEle = body.lastChild
|
|
||||||
|
|
||||||
let itemAs = body.querySelectorAll('a')
|
|
||||||
let itemPs = body.querySelectorAll('p')
|
|
||||||
let lastItemA = itemAs[itemAs.length - 1]
|
|
||||||
let lastItemP = itemPs[itemPs.length - 1]
|
|
||||||
let lastItem
|
|
||||||
if (isElement(lastItemA) && isElement(lastItemP)) {
|
|
||||||
if (lastItemA.clientHeight + lastItemA.offsetTop > lastItemP.clientHeight + lastItemP.offsetTop) {
|
|
||||||
lastItem = lastItemA
|
|
||||||
} else {
|
|
||||||
lastItem = lastItemP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lastchild && !lastItem && !lastEle) return
|
|
||||||
if (lastEle.nodeType === 3 && !lastchild && !lastItem) return
|
|
||||||
|
|
||||||
let nodeHeight = 0
|
|
||||||
if (lastEle.nodeType === 3 && document.createRange) {
|
|
||||||
let range = document.createRange()
|
|
||||||
range.selectNodeContents(lastEle)
|
|
||||||
if (range.getBoundingClientRect) {
|
|
||||||
let rect = range.getBoundingClientRect()
|
|
||||||
if (rect) {
|
|
||||||
nodeHeight = rect.bottom - rect.top
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var lastChildHeight = isElement(lastchild) ? lastchild.clientHeight + lastchild.offsetTop : 0
|
|
||||||
var lastEleHeight = isElement(lastEle) ? lastEle.clientHeight + lastEle.offsetTop : 0
|
|
||||||
var lastItemHeight = isElement(lastItem) ? lastItem.clientHeight + lastItem.offsetTop : 0
|
|
||||||
iFrame.height = Math.max(lastChildHeight, lastEleHeight, lastItemHeight) + 100 + nodeHeight
|
|
||||||
}, 500)
|
|
||||||
},
|
|
||||||
async initMobi() {
|
|
||||||
// Fetch mobi file as blob
|
|
||||||
var buff = await this.$axios.$get(this.ebookUrl, {
|
|
||||||
responseType: 'blob'
|
|
||||||
})
|
|
||||||
var reader = new FileReader()
|
|
||||||
reader.onload = async (event) => {
|
|
||||||
var file_content = event.target.result
|
|
||||||
|
|
||||||
let mobiFile = new MobiParser(file_content)
|
|
||||||
|
|
||||||
let content = await mobiFile.render()
|
|
||||||
let htmlParser = new HtmlParser(new DOMParser().parseFromString(content.outerHTML, 'text/html'))
|
|
||||||
var anchoredDoc = htmlParser.getAnchoredDoc()
|
|
||||||
|
|
||||||
let iFrame = document.getElementsByTagName('iframe')[0]
|
|
||||||
iFrame.contentDocument.body.innerHTML = anchoredDoc.documentElement.outerHTML
|
|
||||||
|
|
||||||
// Add css
|
|
||||||
let style = iFrame.contentDocument.createElement('style')
|
|
||||||
style.id = 'default-style'
|
|
||||||
style.textContent = defaultCss
|
|
||||||
iFrame.contentDocument.head.appendChild(style)
|
|
||||||
|
|
||||||
this.handleIFrameHeight(iFrame)
|
|
||||||
}
|
|
||||||
reader.readAsArrayBuffer(buff)
|
|
||||||
},
|
|
||||||
initEpub() {
|
|
||||||
// var book = ePub(this.url, {
|
|
||||||
// requestHeaders: {
|
|
||||||
// Authorization: `Bearer ${this.userToken}`
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
var book = ePub(this.ebookUrl)
|
|
||||||
this.book = book
|
|
||||||
|
|
||||||
this.rendition = book.renderTo('viewer', {
|
|
||||||
width: window.innerWidth - 200,
|
|
||||||
height: 600,
|
|
||||||
ignoreClass: 'annotator-hl',
|
|
||||||
manager: 'continuous',
|
|
||||||
spread: 'always'
|
|
||||||
})
|
|
||||||
var displayed = this.rendition.display()
|
|
||||||
|
|
||||||
book.ready
|
|
||||||
.then(() => {
|
|
||||||
console.log('Book ready')
|
|
||||||
return book.locations.generate(1600)
|
|
||||||
})
|
|
||||||
.then((locations) => {
|
|
||||||
// console.log('Loaded locations', locations)
|
|
||||||
// Wait for book to be rendered to get current page
|
|
||||||
displayed.then(() => {
|
|
||||||
// Get the current CFI
|
|
||||||
var currentLocation = this.rendition.currentLocation()
|
|
||||||
if (!currentLocation.start) {
|
|
||||||
console.error('No Start', currentLocation)
|
|
||||||
} else {
|
|
||||||
var currentPage = book.locations.percentageFromCfi(currentLocation.start.cfi)
|
|
||||||
// console.log('current page', currentPage)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
book.loaded.navigation.then((toc) => {
|
|
||||||
var _chapters = []
|
|
||||||
toc.forEach((chapter) => {
|
|
||||||
_chapters.push(chapter)
|
|
||||||
})
|
|
||||||
this.chapters = _chapters
|
|
||||||
})
|
|
||||||
book.loaded.metadata.then((metadata) => {
|
|
||||||
this.author = metadata.creator
|
|
||||||
this.title = metadata.title
|
|
||||||
})
|
|
||||||
|
|
||||||
this.rendition.on('keyup', this.keyUp)
|
|
||||||
|
|
||||||
this.rendition.on('relocated', (location) => {
|
|
||||||
var percent = book.locations.percentageFromCfi(location.start.cfi)
|
|
||||||
var percentage = Math.floor(percent * 100)
|
|
||||||
this.progress = percentage
|
|
||||||
|
|
||||||
this.hasNext = !location.atEnd
|
|
||||||
this.hasPrev = !location.atStart
|
|
||||||
})
|
|
||||||
},
|
|
||||||
close() {
|
|
||||||
this.unregisterListeners()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
if (this.show) this.init()
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
this.unregisterListeners()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
/* @import url(@/assets/calibre/basic.css); */
|
|
||||||
.ebook-viewer {
|
|
||||||
height: calc(100% - 96px);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<span v-if="stream" class="material-icons px-4 cursor-pointer" @click="cancelStream">close</span>
|
<span v-if="stream" class="material-icons px-4 cursor-pointer" @click="cancelStream">close</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<audio-player ref="audioPlayer" :chapters="chapters" :loading="isLoading" @updateTime="updateTime" @hook:mounted="audioPlayerMounted" />
|
<audio-player ref="audioPlayer" :chapters="chapters" :loading="isLoading" @close="cancelStream" @updateTime="updateTime" @hook:mounted="audioPlayerMounted" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-full px-1 overflow-hidden">
|
<div class="flex h-full px-1 overflow-hidden">
|
||||||
<cards-book-cover :audiobook="audiobook" :width="50" />
|
<cards-book-cover :audiobook="audiobook" :width="50" />
|
||||||
<div class="flex-grow px-2 searchCardContent h-full">
|
<div class="flex-grow px-2 audiobookSearchCardContent">
|
||||||
<p class="truncate text-sm">{{ title }}</p>
|
<p v-if="matchKey !== 'title'" class="truncate text-sm">{{ title }}</p>
|
||||||
<p class="text-xs text-gray-200 truncate">by {{ author }}</p>
|
<p v-else class="truncate text-sm" v-html="matchHtml" />
|
||||||
|
|
||||||
|
<p v-if="matchKey === 'subtitle'" class="truncate text-xs text-gray-300">{{ matchHtml }}</p>
|
||||||
|
|
||||||
|
<p v-if="matchKey !== 'authorFL'" class="text-xs text-gray-200 truncate">by {{ authorFL }}</p>
|
||||||
|
<p v-else class="truncate text-xs text-gray-200" v-html="matchHtml" />
|
||||||
|
|
||||||
|
<div v-if="matchKey === 'series' || matchKey === 'tags'" class="m-0 p-0 truncate" v-html="matchHtml" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -14,7 +21,10 @@ export default {
|
|||||||
audiobook: {
|
audiobook: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
}
|
},
|
||||||
|
search: String,
|
||||||
|
matchKey: String,
|
||||||
|
matchText: String
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {}
|
return {}
|
||||||
@@ -26,8 +36,35 @@ export default {
|
|||||||
title() {
|
title() {
|
||||||
return this.book ? this.book.title : 'No Title'
|
return this.book ? this.book.title : 'No Title'
|
||||||
},
|
},
|
||||||
author() {
|
subtitle() {
|
||||||
return this.book ? this.book.author : 'Unknown'
|
return this.book ? this.book.subtitle : ''
|
||||||
|
},
|
||||||
|
authorFL() {
|
||||||
|
return this.book ? this.book.authorFL : 'Unknown'
|
||||||
|
},
|
||||||
|
matchHtml() {
|
||||||
|
if (!this.matchText || !this.search) return ''
|
||||||
|
if (this.matchKey === 'subtitle') return ''
|
||||||
|
var matchSplit = this.matchText.toLowerCase().split(this.search.toLowerCase().trim())
|
||||||
|
if (matchSplit.length < 2) return ''
|
||||||
|
|
||||||
|
var html = ''
|
||||||
|
var totalLenSoFar = 0
|
||||||
|
for (let i = 0; i < matchSplit.length - 1; i++) {
|
||||||
|
var indexOf = matchSplit[i].length
|
||||||
|
var firstPart = this.matchText.substr(totalLenSoFar, indexOf)
|
||||||
|
var actualWasThere = this.matchText.substr(totalLenSoFar + indexOf, this.search.length)
|
||||||
|
totalLenSoFar += indexOf + this.search.length
|
||||||
|
|
||||||
|
html += `${firstPart}<strong class="text-warning">${actualWasThere}</strong>`
|
||||||
|
}
|
||||||
|
var lastPart = this.matchText.substr(totalLenSoFar)
|
||||||
|
html += lastPart
|
||||||
|
|
||||||
|
if (this.matchKey === 'tags') return `<p class="truncate">Tags: ${html}</p>`
|
||||||
|
if (this.matchKey === 'authorFL') return `by ${html}`
|
||||||
|
if (this.matchKey === 'series') return `<p class="truncate">Series: ${html}</p>`
|
||||||
|
return `${html}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {},
|
methods: {},
|
||||||
@@ -36,9 +73,9 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.searchCardContent {
|
.audiobookSearchCardContent {
|
||||||
width: calc(100% - 80px);
|
width: calc(100% - 80px);
|
||||||
height: calc(50px * 1.5);
|
height: 75px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-full px-1 overflow-hidden">
|
<div class="flex h-full px-1 overflow-hidden">
|
||||||
<img src="https://rpgplanner.com/wp-content/uploads/2020/06/no-photo-available.png" class="w-40 h-40 max-h-40 object-contain" style="max-height: 40px; max-width: 40px" />
|
<img src="/icons/NoUserPhoto.png" class="w-40 h-40 max-h-40 object-contain" style="max-height: 40px; max-width: 40px" />
|
||||||
<div class="flex-grow px-2 authorSearchCardContent h-full">
|
<div class="flex-grow px-2 authorSearchCardContent h-full">
|
||||||
<p class="truncate text-sm">{{ author }}</p>
|
<p class="truncate text-sm">{{ author }}</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -22,7 +22,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.searchCardContent {
|
.authorSearchCardContent {
|
||||||
width: calc(100% - 80px);
|
width: calc(100% - 80px);
|
||||||
height: 40px;
|
height: 40px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -164,11 +164,14 @@ export default {
|
|||||||
showError() {
|
showError() {
|
||||||
return this.hasMissingParts || this.hasInvalidParts || this.isMissing || this.isIncomplete
|
return this.hasMissingParts || this.hasInvalidParts || this.isMissing || this.isIncomplete
|
||||||
},
|
},
|
||||||
|
isStreaming() {
|
||||||
|
return this.$store.getters['getAudiobookIdStreaming'] === this.audiobookId
|
||||||
|
},
|
||||||
showReadButton() {
|
showReadButton() {
|
||||||
return !this.isSelectionMode && this.showExperimentalFeatures && !this.showPlayButton && this.hasEbook
|
return !this.isSelectionMode && this.showExperimentalFeatures && !this.showPlayButton && this.hasEbook
|
||||||
},
|
},
|
||||||
showPlayButton() {
|
showPlayButton() {
|
||||||
return !this.isSelectionMode && !this.isMissing && !this.isIncomplete && this.hasTracks
|
return !this.isSelectionMode && !this.isMissing && !this.isIncomplete && this.hasTracks && !this.isStreaming
|
||||||
},
|
},
|
||||||
showSmallEBookIcon() {
|
showSmallEBookIcon() {
|
||||||
return !this.isSelectionMode && this.showExperimentalFeatures && this.hasEbook
|
return !this.isSelectionMode && this.showExperimentalFeatures && this.hasEbook
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="rounded-sm h-full overflow-hidden relative" :style="{ padding: `16px ${paddingX}px` }" @mouseover="isHovering = true" @mouseleave="isHovering = false" @click="clickCard">
|
<div class="rounded-sm h-full overflow-hidden relative" :style="{ padding: `16px ${paddingX}px` }" @mouseover="isHovering = true" @mouseleave="isHovering = false" @click="clickCard">
|
||||||
<nuxt-link :to="`/library/${currentLibraryId}/bookshelf/series?${groupType}=${groupEncode}`" class="cursor-pointer">
|
<nuxt-link :to="groupTo" class="cursor-pointer">
|
||||||
<div class="w-full relative" :class="isHovering ? 'bg-black-400' : 'bg-primary'" :style="{ height: height + 'px', width: height + 'px' }">
|
<div class="w-full relative" :class="isHovering ? 'bg-black-400' : 'bg-primary'" :style="{ height: height + 'px', width: height + 'px' }">
|
||||||
<cards-group-cover ref="groupcover" :name="groupName" :book-items="bookItems" :width="height" :height="height" />
|
<cards-group-cover ref="groupcover" :name="groupName" :book-items="bookItems" :width="height" :height="height" />
|
||||||
|
|
||||||
@@ -54,6 +54,16 @@ export default {
|
|||||||
_group() {
|
_group() {
|
||||||
return this.group || {}
|
return this.group || {}
|
||||||
},
|
},
|
||||||
|
groupType() {
|
||||||
|
return this._group.type
|
||||||
|
},
|
||||||
|
groupTo() {
|
||||||
|
if (this.groupType === 'series') {
|
||||||
|
return `/library/${this.currentLibraryId}/bookshelf/series?series=${this.groupEncode}`
|
||||||
|
} else {
|
||||||
|
return `/library/${this.currentLibraryId}/bookshelf?filter=tags.${this.groupEncode}`
|
||||||
|
}
|
||||||
|
},
|
||||||
height() {
|
height() {
|
||||||
return this.width * 1.6
|
return this.width * 1.6
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex h-full px-1 overflow-hidden">
|
||||||
|
<div class="w-10 h-10 flex items-center justify-center">
|
||||||
|
<span class="material-icons text-2xl text-gray-200">local_offer</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex-grow px-2 tagSearchCardContent h-full">
|
||||||
|
<p class="truncate text-sm">{{ tag }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
tag: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.tagSearchCardContent {
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<template v-for="item in audiobookResults">
|
<template v-for="item in audiobookResults">
|
||||||
<li :key="item.audiobook.id" class="text-gray-50 select-none relative cursor-pointer hover:bg-black-400 py-1" role="option">
|
<li :key="item.audiobook.id" class="text-gray-50 select-none relative cursor-pointer hover:bg-black-400 py-1" role="option">
|
||||||
<nuxt-link :to="`/audiobook/${item.audiobook.id}`">
|
<nuxt-link :to="`/audiobook/${item.audiobook.id}`">
|
||||||
<cards-audiobook-search-card :audiobook="item.audiobook" />
|
<cards-audiobook-search-card :audiobook="item.audiobook" :match-key="item.matchKey" :match-text="item.matchText" :search="lastSearch" />
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
@@ -39,12 +39,21 @@
|
|||||||
|
|
||||||
<p v-if="seriesResults.length" class="uppercase text-xs text-gray-400 mb-1 mt-3 px-1 font-semibold">Series</p>
|
<p v-if="seriesResults.length" class="uppercase text-xs text-gray-400 mb-1 mt-3 px-1 font-semibold">Series</p>
|
||||||
<template v-for="item in seriesResults">
|
<template v-for="item in seriesResults">
|
||||||
<li :key="item.series" class="text-gray-50 select-none relative cursor-pointer hover:bg-black-400 py-1" role="option" @click="clickedOption(item.series)">
|
<li :key="item.series" class="text-gray-50 select-none relative cursor-pointer hover:bg-black-400 py-1" role="option">
|
||||||
<nuxt-link :to="`/library/${currentLibraryId}/bookshelf/series?series=${$encode(item.series)}`">
|
<nuxt-link :to="`/library/${currentLibraryId}/bookshelf/series?series=${$encode(item.series)}`">
|
||||||
<cards-series-search-card :series="item.series" :book-items="item.audiobooks" />
|
<cards-series-search-card :series="item.series" :book-items="item.audiobooks" />
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<p v-if="tagResults.length" class="uppercase text-xs text-gray-400 mb-1 mt-3 px-1 font-semibold">Tags</p>
|
||||||
|
<template v-for="item in tagResults">
|
||||||
|
<li :key="item.tag" class="text-gray-50 select-none relative cursor-pointer hover:bg-black-400 py-1" role="option">
|
||||||
|
<nuxt-link :to="`/library/${currentLibraryId}/bookshelf?filter=tags.${$encode(item.tag)}`">
|
||||||
|
<cards-tag-search-card :tag="item.tag" />
|
||||||
|
</nuxt-link>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -64,6 +73,7 @@ export default {
|
|||||||
audiobookResults: [],
|
audiobookResults: [],
|
||||||
authorResults: [],
|
authorResults: [],
|
||||||
seriesResults: [],
|
seriesResults: [],
|
||||||
|
tagResults: [],
|
||||||
searchTimeout: null,
|
searchTimeout: null,
|
||||||
lastSearch: null
|
lastSearch: null
|
||||||
}
|
}
|
||||||
@@ -76,19 +86,27 @@ export default {
|
|||||||
return this.$store.state.libraries.currentLibraryId
|
return this.$store.state.libraries.currentLibraryId
|
||||||
},
|
},
|
||||||
totalResults() {
|
totalResults() {
|
||||||
return this.audiobookResults.length + this.seriesResults.length + this.authorResults.length
|
return this.audiobookResults.length + this.seriesResults.length + this.authorResults.length + this.tagResults.length
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submitSearch() {
|
submitSearch() {
|
||||||
if (!this.search) return
|
if (!this.search) return
|
||||||
this.$router.push(`/library/${this.currentLibraryId}/bookshelf/search?query=${this.search}`)
|
var search = this.search
|
||||||
|
this.clearResults()
|
||||||
|
this.$router.push(`/library/${this.currentLibraryId}/bookshelf/search?query=${search}`)
|
||||||
|
},
|
||||||
|
clearResults() {
|
||||||
this.search = null
|
this.search = null
|
||||||
|
this.lastSearch = null
|
||||||
this.audiobookResults = []
|
this.audiobookResults = []
|
||||||
this.authorResults = []
|
this.authorResults = []
|
||||||
this.seriesResults = []
|
this.seriesResults = []
|
||||||
|
this.tagResults = []
|
||||||
this.showMenu = false
|
this.showMenu = false
|
||||||
|
this.isFetching = false
|
||||||
|
this.isTyping = false
|
||||||
|
clearTimeout(this.searchTimeout)
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.$refs.input) {
|
if (this.$refs.input) {
|
||||||
this.$refs.input.blur()
|
this.$refs.input.blur()
|
||||||
@@ -117,9 +135,14 @@ export default {
|
|||||||
console.error('Search error', error)
|
console.error('Search error', error)
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Search was canceled
|
||||||
|
if (!this.isFetching) return
|
||||||
|
|
||||||
this.audiobookResults = searchResults.audiobooks || []
|
this.audiobookResults = searchResults.audiobooks || []
|
||||||
this.authorResults = searchResults.authors || []
|
this.authorResults = searchResults.authors || []
|
||||||
this.seriesResults = searchResults.series || []
|
this.seriesResults = searchResults.series || []
|
||||||
|
this.tagResults = searchResults.tags || []
|
||||||
|
|
||||||
this.isFetching = false
|
this.isFetching = false
|
||||||
if (!this.showMenu) {
|
if (!this.showMenu) {
|
||||||
@@ -135,19 +158,15 @@ export default {
|
|||||||
}
|
}
|
||||||
this.isTyping = true
|
this.isTyping = true
|
||||||
this.searchTimeout = setTimeout(() => {
|
this.searchTimeout = setTimeout(() => {
|
||||||
|
// Canceled search
|
||||||
|
if (!this.isTyping) return
|
||||||
|
|
||||||
this.isTyping = false
|
this.isTyping = false
|
||||||
this.runSearch(val)
|
this.runSearch(val)
|
||||||
}, 750)
|
}, 750)
|
||||||
},
|
},
|
||||||
clickClear() {
|
clickClear() {
|
||||||
if (this.search) {
|
this.clearResults()
|
||||||
this.search = null
|
|
||||||
this.lastSearch = null
|
|
||||||
this.audiobookResults = []
|
|
||||||
this.authorResults = []
|
|
||||||
this.seriesResults = []
|
|
||||||
this.showMenu = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {}
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ export default {
|
|||||||
this.volume = this.lastValue || 0.5
|
this.volume = this.lastValue || 0.5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
toggleMute() {
|
||||||
|
this.clickVolumeIcon()
|
||||||
|
},
|
||||||
clickVolumeTrack(e) {
|
clickVolumeTrack(e) {
|
||||||
var vol = e.offsetX / this.trackWidth
|
var vol = e.offsetX / this.trackWidth
|
||||||
vol = Math.min(Math.max(vol, 0), 1)
|
vol = Math.min(Math.max(vol, 0), 1)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<modals-modal v-model="show" :width="800" :height="'unset'" :processing="processing">
|
<modals-modal v-model="show" name="account" :width="800" :height="'unset'" :processing="processing">
|
||||||
<template #outer>
|
<template #outer>
|
||||||
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
||||||
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
||||||
@@ -64,6 +64,19 @@
|
|||||||
<ui-toggle-switch v-model="newUser.permissions.upload" />
|
<ui-toggle-switch v-model="newUser.permissions.upload" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center my-2 max-w-md">
|
||||||
|
<div class="w-1/2">
|
||||||
|
<p>Can Access All Libraries</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-1/2">
|
||||||
|
<ui-toggle-switch v-model="newUser.permissions.accessAllLibraries" @input="accessAllLibrariesToggled" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="!newUser.permissions.accessAllLibraries" class="my-4">
|
||||||
|
<ui-multi-select-dropdown v-model="newUser.librariesAccessible" :items="libraryItems" label="Libraries Accessible to User" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex pt-4">
|
<div class="flex pt-4">
|
||||||
@@ -116,14 +129,31 @@ export default {
|
|||||||
},
|
},
|
||||||
isEditingRoot() {
|
isEditingRoot() {
|
||||||
return this.account && this.account.type === 'root'
|
return this.account && this.account.type === 'root'
|
||||||
|
},
|
||||||
|
libraries() {
|
||||||
|
return this.$store.state.libraries.libraries
|
||||||
|
},
|
||||||
|
libraryItems() {
|
||||||
|
return this.libraries.map((lib) => ({ text: lib.name, value: lib.id }))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
accessAllLibrariesToggled(val) {
|
||||||
|
if (!val && !this.newUser.librariesAccessible.length) {
|
||||||
|
this.newUser.librariesAccessible = this.libraries.map((l) => l.id)
|
||||||
|
} else if (val && this.newUser.librariesAccessible.length) {
|
||||||
|
this.newUser.librariesAccessible = []
|
||||||
|
}
|
||||||
|
},
|
||||||
submitForm() {
|
submitForm() {
|
||||||
if (!this.newUser.username) {
|
if (!this.newUser.username) {
|
||||||
this.$toast.error('Enter a username')
|
this.$toast.error('Enter a username')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!this.newUser.permissions.accessAllLibraries && !this.newUser.librariesAccessible.length) {
|
||||||
|
this.$toast.error('Must select at least one library')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
this.submitCreateAccount()
|
this.submitCreateAccount()
|
||||||
@@ -139,6 +169,7 @@ export default {
|
|||||||
if (account.type === 'root' && !account.isActive) return
|
if (account.type === 'root' && !account.isActive) return
|
||||||
|
|
||||||
this.processing = true
|
this.processing = true
|
||||||
|
console.log('Calling update', account)
|
||||||
this.$axios
|
this.$axios
|
||||||
.$patch(`/api/user/${this.account.id}`, account)
|
.$patch(`/api/user/${this.account.id}`, account)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@@ -146,14 +177,16 @@ export default {
|
|||||||
if (data.error) {
|
if (data.error) {
|
||||||
this.$toast.error(`Failed to update account: ${data.error}`)
|
this.$toast.error(`Failed to update account: ${data.error}`)
|
||||||
} else {
|
} else {
|
||||||
|
console.log('Account updated', data.user)
|
||||||
this.$toast.success('Account updated')
|
this.$toast.success('Account updated')
|
||||||
this.show = false
|
this.show = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed to update account', error)
|
|
||||||
this.processing = false
|
this.processing = false
|
||||||
this.$toast.error('Failed to update account')
|
console.error('Failed to update account', error)
|
||||||
|
var errMsg = error.response ? error.response.data || '' : ''
|
||||||
|
this.$toast.error(errMsg || 'Failed to update account')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
submitCreateAccount() {
|
submitCreateAccount() {
|
||||||
@@ -176,9 +209,10 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed to create account', error)
|
|
||||||
this.processing = false
|
this.processing = false
|
||||||
this.$toast.error('Failed to create account')
|
console.error('Failed to create account', error)
|
||||||
|
var errMsg = error.response ? error.response.data || '' : ''
|
||||||
|
this.$toast.error(errMsg || 'Failed to create account')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toggleActive() {
|
toggleActive() {
|
||||||
@@ -195,12 +229,14 @@ export default {
|
|||||||
init() {
|
init() {
|
||||||
this.isNew = !this.account
|
this.isNew = !this.account
|
||||||
if (this.account) {
|
if (this.account) {
|
||||||
|
var librariesAccessible = this.account.librariesAccessible || []
|
||||||
this.newUser = {
|
this.newUser = {
|
||||||
username: this.account.username,
|
username: this.account.username,
|
||||||
password: this.account.password,
|
password: this.account.password,
|
||||||
type: this.account.type,
|
type: this.account.type,
|
||||||
isActive: this.account.isActive,
|
isActive: this.account.isActive,
|
||||||
permissions: { ...this.account.permissions }
|
permissions: { ...this.account.permissions },
|
||||||
|
librariesAccessible: [...librariesAccessible]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.newUser = {
|
this.newUser = {
|
||||||
@@ -212,8 +248,10 @@ export default {
|
|||||||
download: true,
|
download: true,
|
||||||
update: false,
|
update: false,
|
||||||
delete: false,
|
delete: false,
|
||||||
upload: false
|
upload: false,
|
||||||
}
|
accessAllLibraries: true
|
||||||
|
},
|
||||||
|
librariesAccessible: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<modals-modal v-model="show" :width="500" :height="'unset'">
|
<modals-modal v-model="show" name="chapters" :width="500" :height="'unset'">
|
||||||
<div ref="container" class="w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
|
<div ref="container" class="w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
|
||||||
<template v-for="chap in chapters">
|
<template v-for="chap in chapters">
|
||||||
<div :key="chap.id" :id="`chapter-row-${chap.id}`" class="flex items-center px-6 py-3 justify-start cursor-pointer hover:bg-bg relative" :class="chap.id === currentChapterId ? 'bg-bg bg-opacity-80' : 'bg-opacity-20'" @click="clickChapter(chap)">
|
<div :key="chap.id" :id="`chapter-row-${chap.id}`" class="flex items-center px-6 py-3 justify-start cursor-pointer hover:bg-bg relative" :class="chap.id === currentChapterId ? 'bg-bg bg-opacity-80' : 'bg-opacity-20'" @click="clickChapter(chap)">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<modals-modal v-model="show" :width="700" :height="'unset'" :processing="processing">
|
<modals-modal v-model="show" name="edit-library" :width="700" :height="'unset'" :processing="processing">
|
||||||
<template #outer>
|
<template #outer>
|
||||||
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
||||||
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<modals-modal v-model="show" :width="800" :height="height" :processing="processing" :content-margin-top="75">
|
<modals-modal v-model="show" name="edit-book" :width="800" :height="height" :processing="processing" :content-margin-top="75">
|
||||||
<template #outer>
|
<template #outer>
|
||||||
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
||||||
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
||||||
@@ -93,6 +93,9 @@ export default {
|
|||||||
this.fetchOnShow = false
|
this.fetchOnShow = false
|
||||||
this.audiobook = null
|
this.audiobook = null
|
||||||
this.init()
|
this.init()
|
||||||
|
this.registerListeners()
|
||||||
|
} else {
|
||||||
|
this.unregisterListeners()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +182,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
goNextBook() {
|
goNextBook() {
|
||||||
if (this.currentBookshelfIndex >= this.bookshelfBookIds.length) return
|
if (this.currentBookshelfIndex >= this.bookshelfBookIds.length - 1) return
|
||||||
|
|
||||||
var nextBookId = this.bookshelfBookIds[this.currentBookshelfIndex + 1]
|
var nextBookId = this.bookshelfBookIds[this.currentBookshelfIndex + 1]
|
||||||
var nextBook = this.$store.getters['audiobooks/getAudiobook'](nextBookId)
|
var nextBook = this.$store.getters['audiobooks/getAudiobook'](nextBookId)
|
||||||
if (nextBook) {
|
if (nextBook) {
|
||||||
@@ -212,9 +216,25 @@ export default {
|
|||||||
this.processing = false
|
this.processing = false
|
||||||
this.show = false
|
this.show = false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
hotkey(action) {
|
||||||
|
if (action === 'ArrowRight') {
|
||||||
|
this.goNextBook()
|
||||||
|
} else if (action === 'ArrowLeft') {
|
||||||
|
this.goPrevBook()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
registerListeners() {
|
||||||
|
this.$eventBus.$on('modal-hotkey', this.hotkey)
|
||||||
|
},
|
||||||
|
unregisterListeners() {
|
||||||
|
this.$eventBus.$off('modal-hotkey', this.hotkey)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.unregisterListeners()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
<template>
|
|
||||||
<modals-modal v-model="show" :width="700" :height="'unset'" :processing="processing">
|
|
||||||
<template #outer>
|
|
||||||
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
|
||||||
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div v-if="show" class="p-4 w-full text-sm py-6 rounded-lg bg-bg shadow-lg border border-black-300 relative overflow-hidden" style="min-height: 200px; max-height: 80vh">
|
|
||||||
<div v-if="!showAddLibrary" class="w-full h-full flex flex-col justify-center px-4">
|
|
||||||
<div class="flex items-center mb-4">
|
|
||||||
<p>{{ libraries.length }} Libraries</p>
|
|
||||||
<!-- <div class="flex-grow" />
|
|
||||||
<ui-btn @click="addLibraryClick">Add Library</ui-btn> -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template v-for="library in libraries">
|
|
||||||
<modals-libraries-library-item :key="library.id" :library="library" :selected="currentLibraryId === library.id" :show-edit="false" @edit="editLibrary" @delete="deleteLibrary" @click="clickLibrary" />
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
<modals-libraries-edit-library v-else :library="selectedLibrary" :show="showAddLibrary" :processing.sync="processing" @back="showAddLibrary = false" @close="showAddLibrary = false" />
|
|
||||||
</div>
|
|
||||||
</modals-modal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
selectedLibrary: null,
|
|
||||||
processing: false,
|
|
||||||
showAddLibrary: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
show: {
|
|
||||||
get() {
|
|
||||||
return this.$store.state.libraries.showModal
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
this.$store.commit('libraries/setShowModal', val)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
title() {
|
|
||||||
return 'Libraries'
|
|
||||||
},
|
|
||||||
currentLibrary() {
|
|
||||||
return this.$store.getters['libraries/getCurrentLibrary']
|
|
||||||
},
|
|
||||||
currentLibraryId() {
|
|
||||||
return this.currentLibrary ? this.currentLibrary.id : null
|
|
||||||
},
|
|
||||||
libraries() {
|
|
||||||
return this.$store.state.libraries.libraries
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
show(newVal) {
|
|
||||||
if (newVal) this.showAddLibrary = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async clickLibrary(library) {
|
|
||||||
await this.$store.dispatch('libraries/fetch', library.id)
|
|
||||||
this.$router.push(`/library/${library.id}`)
|
|
||||||
this.show = false
|
|
||||||
},
|
|
||||||
editLibrary(library) {
|
|
||||||
this.selectedLibrary = library
|
|
||||||
this.showAddLibrary = true
|
|
||||||
},
|
|
||||||
addLibraryClick() {
|
|
||||||
this.selectedLibrary = null
|
|
||||||
this.showAddLibrary = true
|
|
||||||
},
|
|
||||||
deleteLibrary(library) {
|
|
||||||
if (confirm(`Are you sure you want to delete library "${library.name}"?\n(no files will be deleted but book data will be lost)`)) {
|
|
||||||
console.log('Delete library', library)
|
|
||||||
this.processing = true
|
|
||||||
this.$axios
|
|
||||||
.$delete(`/api/library/${library.id}`)
|
|
||||||
.then(() => {
|
|
||||||
console.log('Library delete success')
|
|
||||||
this.$toast.success(`Library "${library.name}" deleted`)
|
|
||||||
|
|
||||||
this.processing = false
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Failed to delete library', error)
|
|
||||||
var errMsg = error.response ? error.response.data || 'Unknown Error' : 'Unknown Error'
|
|
||||||
this.$toast.error(errMsg)
|
|
||||||
this.processing = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {},
|
|
||||||
beforeDestroy() {}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<div ref="wrapper" class="modal modal-bg w-full h-full fixed top-0 left-0 bg-primary bg-opacity-75 flex items-center justify-center z-40 opacity-0">
|
<div ref="wrapper" class="modal modal-bg w-full h-full fixed top-0 left-0 bg-primary bg-opacity-75 flex items-center justify-center z-40 opacity-0">
|
||||||
<div class="absolute top-0 left-0 right-0 w-full h-36 bg-gradient-to-t from-transparent via-black-500 to-black-700 opacity-90 pointer-events-none" />
|
<div class="absolute top-0 left-0 right-0 w-full h-36 bg-gradient-to-t from-transparent via-black-500 to-black-700 opacity-90 pointer-events-none" />
|
||||||
|
|
||||||
<div class="absolute top-5 right-5 h-12 w-12 flex items-center justify-center cursor-pointer text-white hover:text-gray-300" @click="show = false">
|
<div class="absolute top-5 right-5 h-12 w-12 flex items-center justify-center cursor-pointer text-white hover:text-gray-300" @click="clickClose">
|
||||||
<span class="material-icons text-4xl">close</span>
|
<span class="material-icons text-4xl">close</span>
|
||||||
</div>
|
</div>
|
||||||
<slot name="outer" />
|
<slot name="outer" />
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
name: String,
|
||||||
value: Boolean,
|
value: Boolean,
|
||||||
processing: Boolean,
|
processing: Boolean,
|
||||||
persistent: {
|
persistent: {
|
||||||
@@ -73,23 +74,37 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
clickClose() {
|
||||||
|
this.show = false
|
||||||
|
},
|
||||||
clickBg(vm, ev) {
|
clickBg(vm, ev) {
|
||||||
if (this.processing && this.persistent) return
|
if (this.processing && this.persistent) return
|
||||||
if (vm.srcElement.classList.contains('modal-bg')) {
|
if (vm.srcElement.classList.contains('modal-bg')) {
|
||||||
this.show = false
|
this.show = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
hotkey(action) {
|
||||||
|
if (action === 'Escape') {
|
||||||
|
this.show = false
|
||||||
|
}
|
||||||
|
},
|
||||||
setShow() {
|
setShow() {
|
||||||
document.body.appendChild(this.el)
|
document.body.appendChild(this.el)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.content.style.transform = 'scale(1)'
|
this.content.style.transform = 'scale(1)'
|
||||||
}, 10)
|
}, 10)
|
||||||
document.documentElement.classList.add('modal-open')
|
document.documentElement.classList.add('modal-open')
|
||||||
|
|
||||||
|
this.$eventBus.$on('modal-hotkey', this.hotkey)
|
||||||
|
this.$store.commit('setOpenModal', this.name)
|
||||||
},
|
},
|
||||||
setHide() {
|
setHide() {
|
||||||
this.content.style.transform = 'scale(0)'
|
this.content.style.transform = 'scale(0)'
|
||||||
this.el.remove()
|
this.el.remove()
|
||||||
document.documentElement.classList.remove('modal-open')
|
document.documentElement.classList.remove('modal-open')
|
||||||
|
|
||||||
|
this.$eventBus.$off('modal-hotkey', this.hotkey)
|
||||||
|
this.$store.commit('setOpenModal', null)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
<div v-if="hasSearched" class="flex items-center flex-wrap justify-center max-h-80 overflow-y-scroll mt-2 max-w-full">
|
<div v-if="hasSearched" class="flex items-center flex-wrap justify-center max-h-80 overflow-y-scroll mt-2 max-w-full">
|
||||||
<p v-if="!coversFound.length">No Covers Found</p>
|
<p v-if="!coversFound.length">No Covers Found</p>
|
||||||
<template v-for="cover in coversFound">
|
<template v-for="cover in coversFound">
|
||||||
<div :key="cover" class="m-0.5 border-2 border-transparent hover:border-yellow-300 cursor-pointer" :class="cover === imageUrl ? 'border-yellow-300' : ''" @click="setCover(cover)">
|
<div :key="cover" class="m-0.5 border-2 border-transparent hover:border-yellow-300 cursor-pointer" :class="cover === imageUrl ? 'border-yellow-300' : ''" @click="updateCover(cover)">
|
||||||
<cards-preview-cover :src="cover" :width="80" show-open-new-tab />
|
<cards-preview-cover :src="cover" :width="80" show-open-new-tab />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -79,8 +79,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Path from 'path'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
processing: Boolean,
|
processing: Boolean,
|
||||||
@@ -190,13 +188,13 @@ export default {
|
|||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
this.showLocalCovers = false
|
this.showLocalCovers = false
|
||||||
if (this.coversFound.length && (this.searchTitle !== this.book.title || this.searchAuthor !== this.book.author)) {
|
if (this.coversFound.length && (this.searchTitle !== this.book.title || this.searchAuthor !== this.book.authorFL)) {
|
||||||
this.coversFound = []
|
this.coversFound = []
|
||||||
this.hasSearched = false
|
this.hasSearched = false
|
||||||
}
|
}
|
||||||
this.imageUrl = this.book.cover || ''
|
this.imageUrl = this.book.cover || ''
|
||||||
this.searchTitle = this.book.title || ''
|
this.searchTitle = this.book.title || ''
|
||||||
this.searchAuthor = this.book.author || ''
|
this.searchAuthor = this.book.authorFL || ''
|
||||||
},
|
},
|
||||||
removeCover() {
|
removeCover() {
|
||||||
if (!this.book.cover) {
|
if (!this.book.cover) {
|
||||||
|
|||||||
@@ -60,8 +60,8 @@
|
|||||||
<ui-btn v-if="isRootUser" :loading="savingMetadata" color="bg" type="button" class="h-full" small @click.stop.prevent="saveMetadata">Save Metadata</ui-btn>
|
<ui-btn v-if="isRootUser" :loading="savingMetadata" color="bg" type="button" class="h-full" small @click.stop.prevent="saveMetadata">Save Metadata</ui-btn>
|
||||||
</ui-tooltip>
|
</ui-tooltip>
|
||||||
|
|
||||||
<ui-tooltip :disabled="libraryScan" text="(Root User Only) Rescan audiobook including metadata" direction="bottom" class="ml-4">
|
<ui-tooltip :disabled="!!libraryScan" text="(Root User Only) Rescan audiobook including metadata" direction="bottom" class="ml-4">
|
||||||
<ui-btn v-if="isRootUser" :loading="rescanning" :disabled="libraryScan" color="bg" type="button" class="h-full" small @click.stop.prevent="rescan">Re-Scan</ui-btn>
|
<ui-btn v-if="isRootUser" :loading="rescanning" :disabled="!!libraryScan" color="bg" type="button" class="h-full" small @click.stop.prevent="rescan">Re-Scan</ui-btn>
|
||||||
</ui-tooltip>
|
</ui-tooltip>
|
||||||
|
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
|
|||||||
@@ -0,0 +1,238 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-full h-full">
|
||||||
|
<div v-show="showPageMenu" v-click-outside="clickOutside" class="pagemenu absolute top-9 right-20 rounded-md overflow-y-auto bg-bg shadow-lg z-20 border border-gray-400 w-52">
|
||||||
|
<div v-for="(file, index) in pages" :key="file" class="w-full cursor-pointer hover:bg-black-200 px-2 py-1" :class="page === index ? 'bg-black-200' : ''" @click="setPage(index)">
|
||||||
|
<p class="text-sm truncate">{{ file }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-show="showInfoMenu" v-click-outside="clickOutside" class="pagemenu absolute top-9 right-10 rounded-md overflow-y-auto bg-bg shadow-lg z-20 border border-gray-400 w-96">
|
||||||
|
<div v-for="key in comicMetadataKeys" :key="key" class="w-full px-2 py-1">
|
||||||
|
<p class="text-xs">
|
||||||
|
<strong>{{ key }}</strong
|
||||||
|
>: {{ comicMetadata[key] }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="comicMetadata" class="absolute top-0 right-52 bg-bg text-gray-100 border-b border-l border-r border-gray-400 hover:bg-black-200 cursor-pointer rounded-b-md w-10 h-9 flex items-center justify-center text-center z-20" @mousedown.prevent @click.stop.prevent="showInfoMenu = !showInfoMenu">
|
||||||
|
<span class="material-icons text-xl">more</span>
|
||||||
|
</div>
|
||||||
|
<div class="absolute top-0 bg-bg text-gray-100 border-b border-l border-r border-gray-400 hover:bg-black-200 cursor-pointer rounded-b-md w-10 h-9 flex items-center justify-center text-center z-20" style="right: 156px" @mousedown.prevent @click.stop.prevent="showPageMenu = !showPageMenu">
|
||||||
|
<span class="material-icons text-xl">menu</span>
|
||||||
|
</div>
|
||||||
|
<div class="absolute top-0 right-20 bg-bg text-gray-100 border-b border-l border-r border-gray-400 rounded-b-md px-2 h-9 flex items-center text-center z-20">
|
||||||
|
<p class="font-mono">{{ page + 1 }} / {{ numPages }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overflow-hidden m-auto comicwrapper relative">
|
||||||
|
<div v-show="canGoPrev" class="absolute top-0 left-0 h-full w-1/2 hover:opacity-100 opacity-0 z-10 cursor-pointer" @click.stop.prevent="prev" @mousedown.prevent>
|
||||||
|
<div class="flex items-center justify-center h-full w-1/2">
|
||||||
|
<span v-show="loadedFirstPage" class="material-icons text-5xl text-white cursor-pointer text-opacity-30 hover:text-opacity-90">arrow_back_ios</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-show="canGoNext" class="absolute top-0 right-0 h-full w-1/2 hover:opacity-100 opacity-0 z-10 cursor-pointer" @click.stop.prevent="next" @mousedown.prevent>
|
||||||
|
<div class="flex items-center justify-center h-full w-1/2 ml-auto">
|
||||||
|
<span v-show="loadedFirstPage" class="material-icons text-5xl text-white cursor-pointer text-opacity-30 hover:text-opacity-90">arrow_forward_ios</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="h-full flex justify-center">
|
||||||
|
<img v-if="mainImg" :src="mainImg" class="object-contain comicimg" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-show="loading" class="w-full h-full absolute top-0 left-0 flex items-center justify-center z-10">
|
||||||
|
<ui-loading-indicator />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div v-show="loading" class="w-screen h-screen absolute top-0 left-0 bg-black bg-opacity-20 flex items-center justify-center">
|
||||||
|
<ui-loading-indicator />
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Path from 'path'
|
||||||
|
import { Archive } from 'libarchive.js/main.js'
|
||||||
|
|
||||||
|
Archive.init({
|
||||||
|
workerUrl: '/libarchive/worker-bundle.js'
|
||||||
|
})
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
url: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
pages: null,
|
||||||
|
filesObject: null,
|
||||||
|
mainImg: null,
|
||||||
|
page: 0,
|
||||||
|
numPages: 0,
|
||||||
|
showPageMenu: false,
|
||||||
|
showInfoMenu: false,
|
||||||
|
loadTimeout: null,
|
||||||
|
loadedFirstPage: false,
|
||||||
|
comicMetadata: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
url: {
|
||||||
|
immediate: true,
|
||||||
|
handler() {
|
||||||
|
this.extract()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
comicMetadataKeys() {
|
||||||
|
return this.comicMetadata ? Object.keys(this.comicMetadata) : []
|
||||||
|
},
|
||||||
|
canGoNext() {
|
||||||
|
return this.page < this.numPages - 1
|
||||||
|
},
|
||||||
|
canGoPrev() {
|
||||||
|
return this.page > 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
clickOutside() {
|
||||||
|
if (this.showPageMenu) this.showPageMenu = false
|
||||||
|
if (this.showInfoMenu) this.showInfoMenu = false
|
||||||
|
},
|
||||||
|
next() {
|
||||||
|
if (!this.canGoNext) return
|
||||||
|
this.setPage(this.page + 1)
|
||||||
|
},
|
||||||
|
prev() {
|
||||||
|
if (!this.canGoPrev) return
|
||||||
|
this.setPage(this.page - 1)
|
||||||
|
},
|
||||||
|
setPage(index) {
|
||||||
|
if (index < 0 || index > this.numPages - 1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var filename = this.pages[index]
|
||||||
|
this.page = index
|
||||||
|
return this.extractFile(filename)
|
||||||
|
},
|
||||||
|
setLoadTimeout() {
|
||||||
|
this.loadTimeout = setTimeout(() => {
|
||||||
|
this.loading = true
|
||||||
|
}, 150)
|
||||||
|
},
|
||||||
|
extractFile(filename) {
|
||||||
|
return new Promise(async (resolve) => {
|
||||||
|
this.setLoadTimeout()
|
||||||
|
var file = await this.filesObject[filename].extract()
|
||||||
|
var reader = new FileReader()
|
||||||
|
reader.onload = (e) => {
|
||||||
|
this.mainImg = e.target.result
|
||||||
|
this.loading = false
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
reader.onerror = (e) => {
|
||||||
|
console.error(e)
|
||||||
|
this.$toast.error('Read page file failed')
|
||||||
|
this.loading = false
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
clearTimeout(this.loadTimeout)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async extract() {
|
||||||
|
this.loading = true
|
||||||
|
console.log('Extracting', this.url)
|
||||||
|
|
||||||
|
var buff = await this.$axios.$get(this.url, {
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
const archive = await Archive.open(buff)
|
||||||
|
this.filesObject = await archive.getFilesObject()
|
||||||
|
var filenames = Object.keys(this.filesObject)
|
||||||
|
this.parseFilenames(filenames)
|
||||||
|
|
||||||
|
var xmlFile = filenames.find((f) => (Path.extname(f) || '').toLowerCase() === '.xml')
|
||||||
|
if (xmlFile) await this.extractXmlFile(xmlFile)
|
||||||
|
|
||||||
|
this.numPages = this.pages.length
|
||||||
|
|
||||||
|
if (this.pages.length) {
|
||||||
|
this.loading = false
|
||||||
|
await this.setPage(0)
|
||||||
|
this.loadedFirstPage = true
|
||||||
|
} else {
|
||||||
|
this.$toast.error('Unable to extract pages')
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async extractXmlFile(filename) {
|
||||||
|
console.log('extracting xml filename', filename)
|
||||||
|
try {
|
||||||
|
var file = await this.filesObject[filename].extract()
|
||||||
|
var reader = new FileReader()
|
||||||
|
reader.onload = (e) => {
|
||||||
|
this.comicMetadata = this.$xmlToJson(e.target.result)
|
||||||
|
console.log('Metadata', this.comicMetadata)
|
||||||
|
}
|
||||||
|
reader.onerror = (e) => {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
reader.readAsText(file)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parseImageFilename(filename) {
|
||||||
|
var basename = Path.basename(filename, Path.extname(filename))
|
||||||
|
var numbersinpath = basename.match(/\d{1,4}/g)
|
||||||
|
if (!numbersinpath || !numbersinpath.length) {
|
||||||
|
return {
|
||||||
|
index: -1,
|
||||||
|
filename
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
index: Number(numbersinpath[numbersinpath.length - 1]),
|
||||||
|
filename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parseFilenames(filenames) {
|
||||||
|
const acceptableImages = ['.jpeg', '.jpg', '.png']
|
||||||
|
var imageFiles = filenames.filter((f) => {
|
||||||
|
return acceptableImages.includes((Path.extname(f) || '').toLowerCase())
|
||||||
|
})
|
||||||
|
var imageFileObjs = imageFiles.map((img) => {
|
||||||
|
return this.parseImageFilename(img)
|
||||||
|
})
|
||||||
|
|
||||||
|
var imagesWithNum = imageFileObjs.filter((i) => i.index >= 0)
|
||||||
|
var orderedImages = imagesWithNum.sort((a, b) => a.index - b.index).map((i) => i.filename)
|
||||||
|
var noNumImages = imageFileObjs.filter((i) => i.index < 0)
|
||||||
|
orderedImages = orderedImages.concat(noNumImages.map((i) => i.filename))
|
||||||
|
|
||||||
|
this.pages = orderedImages
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {},
|
||||||
|
beforeDestroy() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.pagemenu {
|
||||||
|
max-height: calc(100vh - 60px);
|
||||||
|
}
|
||||||
|
.comicimg {
|
||||||
|
height: calc(100vh - 40px);
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
.comicwrapper {
|
||||||
|
width: 100vw;
|
||||||
|
height: calc(100vh - 40px);
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<template>
|
||||||
|
<div class="h-full w-full">
|
||||||
|
<div class="h-full flex items-center">
|
||||||
|
<div style="width: 100px; max-width: 100px" class="h-full flex items-center overflow-x-hidden justify-center">
|
||||||
|
<span v-show="hasPrev" class="material-icons text-white text-opacity-50 hover:text-opacity-80 cursor-pointer text-6xl" @mousedown.prevent @click="prev">chevron_left</span>
|
||||||
|
</div>
|
||||||
|
<div id="frame" class="w-full" style="height: 650px">
|
||||||
|
<div id="viewer" class="border border-gray-100 bg-white shadow-md"></div>
|
||||||
|
|
||||||
|
<div class="py-4 flex justify-center" style="height: 50px">
|
||||||
|
<p>{{ progress }}%</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="width: 100px; max-width: 100px" class="h-full flex items-center justify-center overflow-x-hidden">
|
||||||
|
<span v-show="hasNext" class="material-icons text-white text-opacity-50 hover:text-opacity-80 cursor-pointer text-6xl" @mousedown.prevent @click="next">chevron_right</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ePub from 'epubjs'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
url: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
book: null,
|
||||||
|
rendition: null,
|
||||||
|
chapters: [],
|
||||||
|
title: '',
|
||||||
|
author: '',
|
||||||
|
progress: 0,
|
||||||
|
hasNext: true,
|
||||||
|
hasPrev: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {
|
||||||
|
changedChapter() {
|
||||||
|
if (this.rendition) {
|
||||||
|
this.rendition.display(this.selectedChapter)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
prev() {
|
||||||
|
if (this.rendition) {
|
||||||
|
this.rendition.prev()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
next() {
|
||||||
|
if (this.rendition) {
|
||||||
|
this.rendition.next()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
keyUp() {
|
||||||
|
if ((e.keyCode || e.which) == 37) {
|
||||||
|
this.prev()
|
||||||
|
} else if ((e.keyCode || e.which) == 39) {
|
||||||
|
this.next()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initEpub() {
|
||||||
|
// var book = ePub(this.url, {
|
||||||
|
// requestHeaders: {
|
||||||
|
// Authorization: `Bearer ${this.userToken}`
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
var book = ePub(this.url)
|
||||||
|
this.book = book
|
||||||
|
|
||||||
|
this.rendition = book.renderTo('viewer', {
|
||||||
|
width: window.innerWidth - 200,
|
||||||
|
height: 600,
|
||||||
|
ignoreClass: 'annotator-hl',
|
||||||
|
manager: 'continuous',
|
||||||
|
spread: 'always'
|
||||||
|
})
|
||||||
|
var displayed = this.rendition.display()
|
||||||
|
|
||||||
|
book.ready
|
||||||
|
.then(() => {
|
||||||
|
console.log('Book ready')
|
||||||
|
return book.locations.generate(1600)
|
||||||
|
})
|
||||||
|
.then((locations) => {
|
||||||
|
// console.log('Loaded locations', locations)
|
||||||
|
// Wait for book to be rendered to get current page
|
||||||
|
displayed.then(() => {
|
||||||
|
// Get the current CFI
|
||||||
|
var currentLocation = this.rendition.currentLocation()
|
||||||
|
if (!currentLocation.start) {
|
||||||
|
console.error('No Start', currentLocation)
|
||||||
|
} else {
|
||||||
|
var currentPage = book.locations.percentageFromCfi(currentLocation.start.cfi)
|
||||||
|
// console.log('current page', currentPage)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
book.loaded.navigation.then((toc) => {
|
||||||
|
var _chapters = []
|
||||||
|
toc.forEach((chapter) => {
|
||||||
|
_chapters.push(chapter)
|
||||||
|
})
|
||||||
|
this.chapters = _chapters
|
||||||
|
})
|
||||||
|
book.loaded.metadata.then((metadata) => {
|
||||||
|
this.author = metadata.creator
|
||||||
|
this.title = metadata.title
|
||||||
|
})
|
||||||
|
|
||||||
|
this.rendition.on('keyup', this.keyUp)
|
||||||
|
|
||||||
|
this.rendition.on('relocated', (location) => {
|
||||||
|
var percent = book.locations.percentageFromCfi(location.start.cfi)
|
||||||
|
this.progress = Math.floor(percent * 100)
|
||||||
|
|
||||||
|
this.hasNext = !location.atEnd
|
||||||
|
this.hasPrev = !location.atStart
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.initEpub()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-full h-full">
|
||||||
|
<div class="h-full max-h-full w-full">
|
||||||
|
<div class="ebook-viewer absolute overflow-y-scroll left-0 right-0 top-12 w-full max-w-4xl m-auto z-10 border border-black border-opacity-20 shadow-md bg-white">
|
||||||
|
<iframe title="html-viewer" width="100%"> Loading </iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import MobiParser from '@/assets/ebooks/mobi.js'
|
||||||
|
import HtmlParser from '@/assets/ebooks/htmlParser.js'
|
||||||
|
import defaultCss from '@/assets/ebooks/basic.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
url: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {
|
||||||
|
addHtmlCss() {
|
||||||
|
let iframe = document.getElementsByTagName('iframe')[0]
|
||||||
|
if (!iframe) return
|
||||||
|
let doc = iframe.contentDocument
|
||||||
|
if (!doc) return
|
||||||
|
let style = doc.createElement('style')
|
||||||
|
style.id = 'default-style'
|
||||||
|
style.textContent = defaultCss
|
||||||
|
doc.head.appendChild(style)
|
||||||
|
},
|
||||||
|
handleIFrameHeight(iFrame) {
|
||||||
|
const isElement = (obj) => !!(obj && obj.nodeType === 1)
|
||||||
|
|
||||||
|
var body = iFrame.contentWindow.document.body,
|
||||||
|
html = iFrame.contentWindow.document.documentElement
|
||||||
|
iFrame.height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight) * 2
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
let lastchild = body.lastElementChild
|
||||||
|
let lastEle = body.lastChild
|
||||||
|
|
||||||
|
let itemAs = body.querySelectorAll('a')
|
||||||
|
let itemPs = body.querySelectorAll('p')
|
||||||
|
let lastItemA = itemAs[itemAs.length - 1]
|
||||||
|
let lastItemP = itemPs[itemPs.length - 1]
|
||||||
|
let lastItem
|
||||||
|
if (isElement(lastItemA) && isElement(lastItemP)) {
|
||||||
|
if (lastItemA.clientHeight + lastItemA.offsetTop > lastItemP.clientHeight + lastItemP.offsetTop) {
|
||||||
|
lastItem = lastItemA
|
||||||
|
} else {
|
||||||
|
lastItem = lastItemP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lastchild && !lastItem && !lastEle) return
|
||||||
|
if (lastEle.nodeType === 3 && !lastchild && !lastItem) return
|
||||||
|
|
||||||
|
let nodeHeight = 0
|
||||||
|
if (lastEle.nodeType === 3 && document.createRange) {
|
||||||
|
let range = document.createRange()
|
||||||
|
range.selectNodeContents(lastEle)
|
||||||
|
if (range.getBoundingClientRect) {
|
||||||
|
let rect = range.getBoundingClientRect()
|
||||||
|
if (rect) {
|
||||||
|
nodeHeight = rect.bottom - rect.top
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var lastChildHeight = isElement(lastchild) ? lastchild.clientHeight + lastchild.offsetTop : 0
|
||||||
|
var lastEleHeight = isElement(lastEle) ? lastEle.clientHeight + lastEle.offsetTop : 0
|
||||||
|
var lastItemHeight = isElement(lastItem) ? lastItem.clientHeight + lastItem.offsetTop : 0
|
||||||
|
iFrame.height = Math.max(lastChildHeight, lastEleHeight, lastItemHeight) + 100 + nodeHeight
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
|
async initMobi() {
|
||||||
|
// Fetch mobi file as blob
|
||||||
|
var buff = await this.$axios.$get(this.url, {
|
||||||
|
responseType: 'blob'
|
||||||
|
})
|
||||||
|
var reader = new FileReader()
|
||||||
|
reader.onload = async (event) => {
|
||||||
|
var file_content = event.target.result
|
||||||
|
|
||||||
|
let mobiFile = new MobiParser(file_content)
|
||||||
|
|
||||||
|
let content = await mobiFile.render()
|
||||||
|
let htmlParser = new HtmlParser(new DOMParser().parseFromString(content.outerHTML, 'text/html'))
|
||||||
|
var anchoredDoc = htmlParser.getAnchoredDoc()
|
||||||
|
|
||||||
|
let iFrame = document.getElementsByTagName('iframe')[0]
|
||||||
|
iFrame.contentDocument.body.innerHTML = anchoredDoc.documentElement.outerHTML
|
||||||
|
|
||||||
|
// Add css
|
||||||
|
let style = iFrame.contentDocument.createElement('style')
|
||||||
|
style.id = 'default-style'
|
||||||
|
style.textContent = defaultCss
|
||||||
|
iFrame.contentDocument.head.appendChild(style)
|
||||||
|
|
||||||
|
this.handleIFrameHeight(iFrame)
|
||||||
|
}
|
||||||
|
reader.readAsArrayBuffer(buff)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.initMobi()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.ebook-viewer {
|
||||||
|
height: calc(100% - 96px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,23 +1,31 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-full pt-20">
|
<div class="w-full h-full pt-20 relative">
|
||||||
|
<div v-show="canGoPrev" class="absolute top-0 left-0 h-full w-1/2 hover:opacity-100 opacity-0 z-10 cursor-pointer" @click.stop.prevent="prev" @mousedown.prevent>
|
||||||
|
<div class="flex items-center justify-center h-full w-1/2">
|
||||||
|
<span class="material-icons text-5xl text-white cursor-pointer text-opacity-30 hover:text-opacity-90">arrow_back_ios</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-show="canGoNext" class="absolute top-0 right-0 h-full w-1/2 hover:opacity-100 opacity-0 z-10 cursor-pointer" @click.stop.prevent="next" @mousedown.prevent>
|
||||||
|
<div class="flex items-center justify-center h-full w-1/2 ml-auto">
|
||||||
|
<span class="material-icons text-5xl text-white cursor-pointer text-opacity-30 hover:text-opacity-90">arrow_forward_ios</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="absolute top-0 right-20 bg-bg text-gray-100 border-b border-l border-r border-gray-400 rounded-b-md px-2 h-9 flex items-center text-center">
|
||||||
|
<p class="font-mono">{{ page }} / {{ numPages }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div :style="{ height: pdfHeight + 'px' }" class="overflow-hidden m-auto">
|
<div :style="{ height: pdfHeight + 'px' }" class="overflow-hidden m-auto">
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<div class="px-12">
|
|
||||||
<span class="material-icons text-5xl text-black" :class="!canGoPrev ? 'text-opacity-10' : 'cursor-pointer text-opacity-30 hover:text-opacity-90'" @click.stop.prevent="goPrevPage" @mousedown.prevent>arrow_back_ios</span>
|
|
||||||
</div>
|
|
||||||
<div :style="{ width: pdfWidth + 'px', height: pdfHeight + 'px' }" class="w-full h-full overflow-auto">
|
<div :style="{ width: pdfWidth + 'px', height: pdfHeight + 'px' }" class="w-full h-full overflow-auto">
|
||||||
<div v-if="loadedRatio > 0 && loadedRatio < 1" style="background-color: green; color: white; text-align: center" :style="{ width: loadedRatio * 100 + '%' }">{{ Math.floor(loadedRatio * 100) }}%</div>
|
<div v-if="loadedRatio > 0 && loadedRatio < 1" style="background-color: green; color: white; text-align: center" :style="{ width: loadedRatio * 100 + '%' }">{{ Math.floor(loadedRatio * 100) }}%</div>
|
||||||
<pdf ref="pdf" class="m-auto z-10 border border-black border-opacity-20 shadow-md" :src="src" :page="page" :rotate="rotate" @progress="loadedRatio = $event" @error="error" @num-pages="numPagesLoaded" @link-clicked="page = $event"></pdf>
|
<pdf ref="pdf" class="m-auto z-10 border border-black border-opacity-20 shadow-md" :src="url" :page="page" :rotate="rotate" @progress="loadedRatio = $event" @error="error" @num-pages="numPagesLoaded" @link-clicked="page = $event"></pdf>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="px-12">
|
|
||||||
<span class="material-icons text-5xl text-black" :class="!canGoNext ? 'text-opacity-10' : 'cursor-pointer text-opacity-30 hover:text-opacity-90'" @click.stop.prevent="goNextPage" @mousedown.prevent>arrow_forward_ios</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center py-2 text-lg">
|
<!-- <div class="text-center py-2 text-lg">
|
||||||
<p>{{ page }} / {{ numPages }}</p>
|
<p>{{ page }} / {{ numPages }}</p>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -29,7 +37,7 @@ export default {
|
|||||||
pdf
|
pdf
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
src: String
|
url: String
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -57,11 +65,11 @@ export default {
|
|||||||
numPagesLoaded(e) {
|
numPagesLoaded(e) {
|
||||||
this.numPages = e
|
this.numPages = e
|
||||||
},
|
},
|
||||||
goPrevPage() {
|
prev() {
|
||||||
if (this.page <= 1) return
|
if (this.page <= 1) return
|
||||||
this.page--
|
this.page--
|
||||||
},
|
},
|
||||||
goNextPage() {
|
next() {
|
||||||
if (this.page >= this.numPages) return
|
if (this.page >= this.numPages) return
|
||||||
this.page++
|
this.page++
|
||||||
},
|
},
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="show" class="w-screen h-screen fixed top-0 left-0 z-50 bg-primary text-white">
|
||||||
|
<div class="absolute top-4 right-4 z-20">
|
||||||
|
<span class="material-icons cursor-pointer text-4xl" @click="close">close</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="absolute top-4 left-4 font-book">
|
||||||
|
<h1 class="text-2xl mb-1">{{ abTitle }}</h1>
|
||||||
|
<p v-if="abAuthor">by {{ abAuthor }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<component v-if="componentName" ref="readerComponent" :is="componentName" :url="ebookUrl" />
|
||||||
|
|
||||||
|
<div class="absolute bottom-2 left-2">{{ ebookType }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
ebookType: '',
|
||||||
|
ebookUrl: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
show(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
show: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.showEReader
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.commit('setShowEReader', val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
componentName() {
|
||||||
|
if (this.ebookType === 'epub') return 'readers-epub-reader'
|
||||||
|
else if (this.ebookType === 'mobi') return 'readers-mobi-reader'
|
||||||
|
else if (this.ebookType === 'pdf') return 'readers-pdf-reader'
|
||||||
|
else if (this.ebookType === 'comic') return 'readers-comic-reader'
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
abTitle() {
|
||||||
|
return this.selectedAudiobook.book.title
|
||||||
|
},
|
||||||
|
abAuthor() {
|
||||||
|
return this.selectedAudiobook.book.author
|
||||||
|
},
|
||||||
|
selectedAudiobook() {
|
||||||
|
return this.$store.state.selectedAudiobook
|
||||||
|
},
|
||||||
|
libraryId() {
|
||||||
|
return this.selectedAudiobook.libraryId
|
||||||
|
},
|
||||||
|
folderId() {
|
||||||
|
return this.selectedAudiobook.folderId
|
||||||
|
},
|
||||||
|
ebooks() {
|
||||||
|
return this.selectedAudiobook.ebooks || []
|
||||||
|
},
|
||||||
|
epubEbook() {
|
||||||
|
return this.ebooks.find((eb) => eb.ext === '.epub')
|
||||||
|
},
|
||||||
|
mobiEbook() {
|
||||||
|
return this.ebooks.find((eb) => eb.ext === '.mobi' || eb.ext === '.azw3')
|
||||||
|
},
|
||||||
|
pdfEbook() {
|
||||||
|
return this.ebooks.find((eb) => eb.ext === '.pdf')
|
||||||
|
},
|
||||||
|
comicEbook() {
|
||||||
|
return this.ebooks.find((eb) => eb.ext === '.cbz' || eb.ext === '.cbr')
|
||||||
|
},
|
||||||
|
userToken() {
|
||||||
|
return this.$store.getters['user/getToken']
|
||||||
|
},
|
||||||
|
selectedAudiobookFile() {
|
||||||
|
return this.$store.state.selectedAudiobookFile
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getEbookUrl(path) {
|
||||||
|
return `/ebook/${this.libraryId}/${this.folderId}/${path}`
|
||||||
|
},
|
||||||
|
hotkey(action) {
|
||||||
|
console.log('Reader hotkey', action)
|
||||||
|
if (!this.$refs.readerComponent) return
|
||||||
|
|
||||||
|
if (action === 'ArrowRight') {
|
||||||
|
if (this.$refs.readerComponent.next) this.$refs.readerComponent.next()
|
||||||
|
} else if (action === 'ArrowLeft') {
|
||||||
|
if (this.$refs.readerComponent.prev) this.$refs.readerComponent.prev()
|
||||||
|
} else if (action === 'Escape') {
|
||||||
|
this.close()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
registerListeners() {
|
||||||
|
this.$eventBus.$on('reader-hotkey', this.hotkey)
|
||||||
|
},
|
||||||
|
unregisterListeners() {
|
||||||
|
this.$eventBus.$off('reader-hotkey', this.hotkey)
|
||||||
|
},
|
||||||
|
init() {
|
||||||
|
this.registerListeners()
|
||||||
|
|
||||||
|
if (this.selectedAudiobookFile) {
|
||||||
|
this.ebookUrl = this.getEbookUrl(this.selectedAudiobookFile.path)
|
||||||
|
if (this.selectedAudiobookFile.ext === '.pdf') {
|
||||||
|
this.ebookType = 'pdf'
|
||||||
|
} else if (this.selectedAudiobookFile.ext === '.mobi' || this.selectedAudiobookFile.ext === '.azw3') {
|
||||||
|
this.ebookType = 'mobi'
|
||||||
|
// this.initMobi()
|
||||||
|
} else if (this.selectedAudiobookFile.ext === '.epub') {
|
||||||
|
this.ebookType = 'epub'
|
||||||
|
// this.initEpub()
|
||||||
|
} else if (this.selectedAudiobookFile.ext === '.cbr' || this.selectedAudiobookFile.ext === '.cbz') {
|
||||||
|
this.ebookType = 'comic'
|
||||||
|
}
|
||||||
|
} else if (this.epubEbook) {
|
||||||
|
this.ebookType = 'epub'
|
||||||
|
this.ebookUrl = this.getEbookUrl(this.epubEbook.path)
|
||||||
|
// this.initEpub()
|
||||||
|
} else if (this.mobiEbook) {
|
||||||
|
this.ebookType = 'mobi'
|
||||||
|
this.ebookUrl = this.getEbookUrl(this.mobiEbook.path)
|
||||||
|
// this.initMobi()
|
||||||
|
} else if (this.pdfEbook) {
|
||||||
|
this.ebookType = 'pdf'
|
||||||
|
this.ebookUrl = this.getEbookUrl(this.pdfEbook.path)
|
||||||
|
} else if (this.comicEbook) {
|
||||||
|
this.ebookType = 'comic'
|
||||||
|
this.ebookUrl = this.getEbookUrl(this.comicEbook.path)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
this.unregisterListeners()
|
||||||
|
this.show = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.show) this.init()
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.unregisterListeners()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* @import url(@/assets/calibre/basic.css); */
|
||||||
|
.ebook-viewer {
|
||||||
|
height: calc(100% - 96px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -102,11 +102,17 @@ export default {
|
|||||||
this.libraryCopies = this.libraries.map((lib) => {
|
this.libraryCopies = this.libraries.map((lib) => {
|
||||||
return { ...lib }
|
return { ...lib }
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
librariesUpdated() {
|
||||||
|
this.init()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$store.commit('libraries/addListener', { id: 'libraries-table', meth: this.librariesUpdated })
|
||||||
this.init()
|
this.init()
|
||||||
},
|
},
|
||||||
beforeDestroy() {}
|
beforeDestroy() {
|
||||||
|
this.$store.commit('libraries/removeListener', 'libraries-table')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -17,17 +17,11 @@
|
|||||||
<th class="w-32">Created</th>
|
<th class="w-32">Created</th>
|
||||||
<th class="w-32"></th>
|
<th class="w-32"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="user in users" :key="user.id" :class="user.isActive ? '' : 'bg-error bg-opacity-20'">
|
<tr v-for="user in users" :key="user.id" class="cursor-pointer" :class="user.isActive ? '' : 'bg-error bg-opacity-20'" @click="$router.push(`/config/users/${user.id}`)">
|
||||||
<td>
|
<td>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span v-if="usersOnline[user.id]" class="w-3 h-3 text-sm mr-2 text-success animate-pulse"
|
<widgets-online-indicator :value="!!usersOnline[user.id]" />
|
||||||
><svg viewBox="0 0 24 24">
|
<span class="pl-2">{{ user.username }}</span> <span v-show="$isDev" class="text-xs text-gray-400 italic pl-4">({{ user.id }})</span>
|
||||||
<path fill="currentColor" d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" /></svg
|
|
||||||
></span>
|
|
||||||
<svg v-else class="w-3 h-3 mr-2 text-white text-opacity-20" viewBox="0 0 24 24">
|
|
||||||
<path fill="currentColor" d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
|
|
||||||
</svg>
|
|
||||||
{{ user.username }} <span v-show="$isDev" class="text-xs text-gray-400 italic pl-4">({{ user.id }})</span>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-sm">{{ user.type }}</td>
|
<td class="text-sm">{{ user.type }}</td>
|
||||||
@@ -49,10 +43,15 @@
|
|||||||
{{ $formatDate(user.createdAt, 'MMM d, yyyy') }}
|
{{ $formatDate(user.createdAt, 'MMM d, yyyy') }}
|
||||||
</ui-tooltip>
|
</ui-tooltip>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="py-0">
|
||||||
<div class="w-full flex justify-center">
|
<div class="w-full flex justify-center">
|
||||||
<span class="material-icons hover:text-gray-400 cursor-pointer text-base pr-2" @click="editUser(user)">edit</span>
|
<!-- <span class="material-icons hover:text-gray-400 cursor-pointer text-base pr-2" @click.stop="editUser(user)">edit</span> -->
|
||||||
<span v-show="user.type !== 'root'" class="material-icons text-base hover:text-error cursor-pointer" @click="deleteUserClick(user)">delete</span>
|
<div class="h-8 w-8 flex items-center justify-center text-white text-opacity-50 hover:text-opacity-100 cursor-pointer" @click.stop="editUser(user)">
|
||||||
|
<span class="material-icons text-base">edit</span>
|
||||||
|
</div>
|
||||||
|
<div v-show="user.type !== 'root'" class="h-8 w-8 flex items-center justify-center text-white text-opacity-50 hover:text-error cursor-pointer" @click.stop="deleteUserClick(user)">
|
||||||
|
<span class="material-icons text-base">delete</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -81,21 +80,8 @@ export default {
|
|||||||
return this.$store.state.streamAudiobook
|
return this.$store.state.streamAudiobook
|
||||||
},
|
},
|
||||||
usersOnline() {
|
usersOnline() {
|
||||||
var _users = this.$store.state.users.users
|
var usermap = {}
|
||||||
|
this.$store.state.users.users.forEach((u) => (usermap[u.id] = { online: true, stream: u.stream }))
|
||||||
var currUserStream = null
|
|
||||||
if (this.userStream) {
|
|
||||||
currUserStream = {
|
|
||||||
audiobook: this.userStream
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var usermap = {
|
|
||||||
[this.currentUserId]: {
|
|
||||||
online: true,
|
|
||||||
stream: currUserStream
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_users.forEach((u) => (usermap[u.id] = { online: true, stream: u.stream }))
|
|
||||||
return usermap
|
return usermap
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -104,7 +90,9 @@ export default {
|
|||||||
var abs = Object.values(audiobooks)
|
var abs = Object.values(audiobooks)
|
||||||
if (abs.length) {
|
if (abs.length) {
|
||||||
abs = abs.sort((a, b) => a.lastUpdate - b.lastUpdate)
|
abs = abs.sort((a, b) => a.lastUpdate - b.lastUpdate)
|
||||||
return abs[0] && abs[0].audiobookTitle ? abs[0].audiobookTitle : null
|
// Book object is attached on request
|
||||||
|
if (abs[0].book) return abs[0].book.title
|
||||||
|
return abs[0].audiobookTitle ? abs[0].audiobookTitle : null
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
@@ -141,7 +129,9 @@ export default {
|
|||||||
this.$axios
|
this.$axios
|
||||||
.$get('/api/users')
|
.$get('/api/users')
|
||||||
.then((users) => {
|
.then((users) => {
|
||||||
this.users = users
|
this.users = users.sort((a, b) => {
|
||||||
|
return a.createdAt - b.createdAt
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Failed', error)
|
console.error('Failed', error)
|
||||||
@@ -192,16 +182,21 @@ export default {
|
|||||||
#accounts {
|
#accounts {
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
border: 1px solid #474747;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#accounts td,
|
#accounts td,
|
||||||
#accounts th {
|
#accounts th {
|
||||||
border: 1px solid #2e2e2e;
|
/* border: 1px solid #2e2e2e; */
|
||||||
padding: 8px 8px;
|
padding: 8px 8px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#accounts td.py-0 {
|
||||||
|
padding: 0px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
#accounts tr:nth-child(even) {
|
#accounts tr:nth-child(even) {
|
||||||
background-color: #3a3a3a;
|
background-color: #3a3a3a;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="currentLibrary" class="relative w-36 h-8" v-click-outside="clickOutside">
|
<div v-if="currentLibrary" class="relative w-36 h-8" v-click-outside="clickOutside">
|
||||||
<button type="button" :disabled="disabled" class="relative h-full w-full border border-white border-opacity-10 hover:border-opacity-20 rounded shadow-sm pl-3 pr-10 text-left focus:outline-none cursor-pointer bg-black bg-opacity-20 text-gray-400 hover:text-gray-200" aria-haspopup="listbox" aria-expanded="true" @click.stop.prevent="clickShowMenu">
|
<button type="button" :disabled="disabled" class="relative h-full w-full border border-white border-opacity-10 hover:border-opacity-20 rounded shadow-sm pl-3 pr-3 text-left focus:outline-none cursor-pointer bg-black bg-opacity-20 text-gray-400 hover:text-gray-200" aria-haspopup="listbox" aria-expanded="true" @click.stop.prevent="clickShowMenu">
|
||||||
<span class="flex items-center">
|
<span class="flex items-center">
|
||||||
<widgets-library-icon :icon="currentLibraryIcon" class="mr-2" />
|
<widgets-library-icon :icon="currentLibraryIcon" class="mr-2" />
|
||||||
<span class="block truncate text-sm">{{ currentLibrary.name }}</span>
|
<span class="block truncate text-sm">{{ currentLibrary.name }}</span>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<transition name="menu">
|
<transition name="menu">
|
||||||
<ul v-show="showMenu" class="absolute z-10 -mt-px w-full bg-primary border border-black-200 shadow-lg max-h-56 rounded-b-md py-1 ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm" tabindex="-1" role="listbox">
|
<ul v-show="showMenu" class="absolute z-10 -mt-px w-full bg-primary border border-black-200 shadow-lg max-h-56 rounded-b-md py-1 ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm" tabindex="-1" role="listbox">
|
||||||
<template v-for="library in libraries">
|
<template v-for="library in librariesFiltered">
|
||||||
<li :key="library.id" class="text-gray-100 select-none relative py-2 cursor-pointer hover:bg-black-400" id="listbox-option-0" role="option" @click="selectLibrary(library)">
|
<li :key="library.id" class="text-gray-100 select-none relative py-2 cursor-pointer hover:bg-black-400" id="listbox-option-0" role="option" @click="selectLibrary(library)">
|
||||||
<div class="flex items-center px-3">
|
<div class="flex items-center px-3">
|
||||||
<widgets-library-icon :icon="currentLibraryIcon" class="mr-2" />
|
<widgets-library-icon :icon="currentLibraryIcon" class="mr-2" />
|
||||||
@@ -43,8 +43,17 @@ export default {
|
|||||||
libraries() {
|
libraries() {
|
||||||
return this.$store.getters['libraries/getSortedLibraries']()
|
return this.$store.getters['libraries/getSortedLibraries']()
|
||||||
},
|
},
|
||||||
libraryItems() {
|
canUserAccessAllLibraries() {
|
||||||
return this.libraries.map((lib) => ({ value: lib.id, text: lib.name }))
|
return this.$store.getters['user/getUserCanAccessAllLibraries']
|
||||||
|
},
|
||||||
|
userLibrariesAccessible() {
|
||||||
|
return this.$store.getters['user/getLibrariesAccessible']
|
||||||
|
},
|
||||||
|
librariesFiltered() {
|
||||||
|
if (this.canUserAccessAllLibraries) return this.libraries
|
||||||
|
return this.libraries.filter((lib) => {
|
||||||
|
return this.userLibrariesAccessible.includes(lib.id)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-full" v-click-outside="closeMenu">
|
||||||
|
<p class="px-1 text-sm font-semibold">{{ label }}</p>
|
||||||
|
<div ref="wrapper" class="relative">
|
||||||
|
<div ref="inputWrapper" style="min-height: 40px" class="flex-wrap relative w-full shadow-sm flex items-center bg-primary border border-gray-600 rounded-md px-2 py-1 cursor-pointer" @click.stop.prevent="clickWrapper" @mouseup.stop.prevent @mousedown.prevent>
|
||||||
|
<div v-for="item in selectedItems" :key="item.value" class="rounded-full px-2 py-1 ma-0.5 text-xs bg-bg flex flex-nowrap whitespace-nowrap items-center relative">
|
||||||
|
<div class="w-full h-full rounded-full absolute top-0 left-0 opacity-0 hover:opacity-100 px-1 bg-bg bg-opacity-75 flex items-center justify-end cursor-pointer">
|
||||||
|
<span class="material-icons text-white hover:text-error" style="font-size: 1.1rem" @click.stop="removeItem(item.value)">close</span>
|
||||||
|
</div>
|
||||||
|
{{ item.text }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul ref="menu" v-show="showMenu" class="absolute z-50 mt-1 w-full bg-bg border border-black-200 shadow-lg max-h-56 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm" role="listbox" aria-labelledby="listbox-label">
|
||||||
|
<template v-for="item in items">
|
||||||
|
<li :key="item.value" class="text-gray-50 select-none relative py-2 pr-9 cursor-pointer hover:bg-black-400" role="option" @click="clickedOption($event, item)" @mouseup.stop.prevent @mousedown.prevent>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<span class="font-normal ml-3 block truncate">{{ item.text }}</span>
|
||||||
|
</div>
|
||||||
|
<span v-if="selected.includes(item.value)" class="text-yellow-400 absolute inset-y-0 right-0 flex items-center pr-4">
|
||||||
|
<span class="material-icons text-xl">checkmark</span>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
<li v-if="!items.length" class="text-gray-50 select-none relative py-2 pr-9" role="option">
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<span class="font-normal">No items</span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
items: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
label: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showMenu: false,
|
||||||
|
menu: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
selected: {
|
||||||
|
get() {
|
||||||
|
return this.value
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$emit('input', val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedItems() {
|
||||||
|
return (this.value || []).map((v) => {
|
||||||
|
return this.items.find((i) => i.value === v) || {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
recalcMenuPos() {
|
||||||
|
if (!this.menu) return
|
||||||
|
var boundingBox = this.$refs.inputWrapper.getBoundingClientRect()
|
||||||
|
this.menu.style.top = boundingBox.y + boundingBox.height - 4 + 'px'
|
||||||
|
this.menu.style.left = boundingBox.x + 'px'
|
||||||
|
this.menu.style.width = boundingBox.width + 'px'
|
||||||
|
},
|
||||||
|
unmountMountMenu() {
|
||||||
|
if (!this.$refs.menu) return
|
||||||
|
this.menu = this.$refs.menu
|
||||||
|
|
||||||
|
var boundingBox = this.$refs.inputWrapper.getBoundingClientRect()
|
||||||
|
this.menu.remove()
|
||||||
|
document.body.appendChild(this.menu)
|
||||||
|
this.menu.style.top = boundingBox.y + boundingBox.height - 4 + 'px'
|
||||||
|
this.menu.style.left = boundingBox.x + 'px'
|
||||||
|
this.menu.style.width = boundingBox.width + 'px'
|
||||||
|
},
|
||||||
|
clickedOption(e, item) {
|
||||||
|
if (e) {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
var newSelected = null
|
||||||
|
if (this.selected.includes(item.value)) {
|
||||||
|
newSelected = this.selected.filter((s) => s !== item.value)
|
||||||
|
} else {
|
||||||
|
newSelected = this.selected.concat([item.value])
|
||||||
|
}
|
||||||
|
this.$emit('input', newSelected)
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.recalcMenuPos()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
closeMenu() {
|
||||||
|
this.showMenu = false
|
||||||
|
},
|
||||||
|
clickWrapper() {
|
||||||
|
this.showMenu = !this.showMenu
|
||||||
|
},
|
||||||
|
removeItem(itemValue) {
|
||||||
|
var remaining = this.selected.filter((i) => i !== itemValue)
|
||||||
|
this.$emit('input', remaining)
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.recalcMenuPos()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-3 h-3">
|
||||||
|
<div v-if="value" class="w-full h-full text-sm mr-2 text-success animate-pulse">
|
||||||
|
<svg viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor" d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<svg v-else class="w-full h-full mr-2 text-white text-opacity-20" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor" d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value: Boolean
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div v-show="isScanning" class="fixed bottom-4 left-0 right-0 mx-auto z-20 max-w-lg">
|
|
||||||
<div class="w-full my-1 rounded-lg drop-shadow-lg px-4 py-2 flex items-center justify-center text-center transition-all border border-white border-opacity-40 shadow-md bg-warning">
|
|
||||||
<p class="text-lg font-sans" v-html="text" />
|
|
||||||
</div>
|
|
||||||
<div v-show="!hasCanceled" class="absolute right-0 top-3 bottom-0 px-2">
|
|
||||||
<ui-btn color="red-600" small :padding-x="1" @click="cancelScan">Cancel</ui-btn>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
hasCanceled: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
isScanning(newVal) {
|
|
||||||
if (newVal) {
|
|
||||||
this.hasCanceled = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
text() {
|
|
||||||
var scanText = this.isScanningFiles ? 'Scanning...' : 'Scanning Covers...'
|
|
||||||
return `${scanText} <span class="font-mono">${this.scanNum}</span> of <span class="font-mono">${this.scanTotal}</span> <strong class='font-mono px-2'>${this.scanPercent}</strong>`
|
|
||||||
},
|
|
||||||
isScanning() {
|
|
||||||
return this.isScanningFiles || this.isScanningCovers
|
|
||||||
},
|
|
||||||
isScanningFiles() {
|
|
||||||
return this.$store.state.isScanning
|
|
||||||
},
|
|
||||||
isScanningCovers() {
|
|
||||||
return this.$store.state.isScanningCovers
|
|
||||||
},
|
|
||||||
scanProgressKey() {
|
|
||||||
return this.isScanningFiles ? 'scanProgress' : 'coverScanProgress'
|
|
||||||
},
|
|
||||||
scanProgress() {
|
|
||||||
return this.$store.state[this.scanProgressKey]
|
|
||||||
},
|
|
||||||
scanPercent() {
|
|
||||||
return this.scanProgress ? this.scanProgress.progress + '%' : '0%'
|
|
||||||
},
|
|
||||||
scanNum() {
|
|
||||||
return this.scanProgress ? this.scanProgress.done : 0
|
|
||||||
},
|
|
||||||
scanTotal() {
|
|
||||||
return this.scanProgress ? this.scanProgress.total : 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
cancelScan() {
|
|
||||||
this.hasCanceled = true
|
|
||||||
this.$root.socket.emit('cancel_scan')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -5,10 +5,9 @@
|
|||||||
<Nuxt />
|
<Nuxt />
|
||||||
|
|
||||||
<app-stream-container ref="streamContainer" />
|
<app-stream-container ref="streamContainer" />
|
||||||
<modals-libraries-modal />
|
|
||||||
<modals-edit-modal />
|
<modals-edit-modal />
|
||||||
<app-reader />
|
<readers-reader />
|
||||||
<!-- <widgets-scan-alert /> -->
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -76,6 +75,12 @@ export default {
|
|||||||
if (payload.backups && payload.backups.length) {
|
if (payload.backups && payload.backups.length) {
|
||||||
this.$store.commit('setBackups', payload.backups)
|
this.$store.commit('setBackups', payload.backups)
|
||||||
}
|
}
|
||||||
|
if (payload.usersOnline) {
|
||||||
|
this.$store.commit('users/resetUsers')
|
||||||
|
payload.usersOnline.forEach((user) => {
|
||||||
|
this.$store.commit('users/updateUser', user)
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
streamOpen(stream) {
|
streamOpen(stream) {
|
||||||
if (this.$refs.streamContainer) this.$refs.streamContainer.streamOpen(stream)
|
if (this.$refs.streamContainer) this.$refs.streamContainer.streamOpen(stream)
|
||||||
@@ -320,9 +325,62 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
console.warn(`Update is available but user chose to dismiss it! v${versionData.latestVersion}`)
|
console.warn(`Update is available but user chose to dismiss it! v${versionData.latestVersion}`)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
checkActiveElementIsInput() {
|
||||||
|
var activeElement = document.activeElement
|
||||||
|
var inputs = ['input', 'select', 'button', 'textarea']
|
||||||
|
return activeElement && inputs.indexOf(activeElement.tagName.toLowerCase()) !== -1
|
||||||
|
},
|
||||||
|
keyUp(e) {
|
||||||
|
var keyCode = e.keyCode || e.which
|
||||||
|
if (!this.$keynames[keyCode]) {
|
||||||
|
// Unused hotkey
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var keyName = this.$keynames[keyCode]
|
||||||
|
var name = keyName
|
||||||
|
if (e.shiftKey) name = 'Shift-' + keyName
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
console.log('Hotkey command', name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Input is focused then ignore key press
|
||||||
|
if (this.checkActiveElementIsInput()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modal is open
|
||||||
|
if (this.$store.state.openModal) {
|
||||||
|
this.$eventBus.$emit('modal-hotkey', name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// EReader is open
|
||||||
|
if (this.$store.state.showEReader) {
|
||||||
|
this.$eventBus.$emit('reader-hotkey', name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Batch selecting
|
||||||
|
if (this.$store.getters['getNumAudiobooksSelected']) {
|
||||||
|
// ESCAPE key cancels batch selection
|
||||||
|
if (name === 'Escape') {
|
||||||
|
this.$store.commit('setSelectedAudiobooks', [])
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Playing audiobook
|
||||||
|
if (this.$store.state.streamAudiobook) {
|
||||||
|
this.$eventBus.$emit('player-hotkey', name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
document.addEventListener('keyup', this.keyUp)
|
||||||
|
|
||||||
this.initializeSocket()
|
this.initializeSocket()
|
||||||
this.$store.dispatch('libraries/load')
|
this.$store.dispatch('libraries/load')
|
||||||
|
|
||||||
@@ -343,6 +401,9 @@ export default {
|
|||||||
this.$toast.error(this.$route.query.error)
|
this.$toast.error(this.$route.query.error)
|
||||||
this.$router.replace(this.$route.path)
|
this.$router.replace(this.$route.path)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
document.removeEventListener('keyup', this.keyUp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function (context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (route.name.startsWith('config') || route.name === 'upload' || route.name === 'account' || route.name.startsWith('audiobook-id')) {
|
if (route.name.startsWith('config') || route.name === 'upload' || route.name === 'account' || route.name.startsWith('audiobook-id')) {
|
||||||
if (from.name !== route.name && from.name !== 'audiobook-id-edit' && from.name !== 'config' && from.name !== 'config-log' && from.name !== 'upload' && from.name !== 'account') {
|
if (from.name !== route.name && from.name !== 'audiobook-id-edit' && !from.name.startsWith('config') && from.name !== 'upload' && from.name !== 'account') {
|
||||||
var _history = [...store.state.routeHistory]
|
var _history = [...store.state.routeHistory]
|
||||||
if (!_history.length || _history[_history.length - 1] !== from.fullPath) {
|
if (!_history.length || _history[_history.length - 1] !== from.fullPath) {
|
||||||
_history.push(from.fullPath)
|
_history.push(from.fullPath)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module.exports = {
|
|||||||
|
|
||||||
// Global page headers: https://go.nuxtjs.dev/config-head
|
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||||
head: {
|
head: {
|
||||||
title: 'AudioBookshelf',
|
title: 'Audiobookshelf',
|
||||||
htmlAttrs: {
|
htmlAttrs: {
|
||||||
lang: 'en'
|
lang: 'en'
|
||||||
},
|
},
|
||||||
@@ -35,8 +35,8 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
link: [
|
link: [
|
||||||
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
|
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
|
||||||
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Fira+Mono&family=Ubuntu+Mono&family=Gentium+Book+Basic&&family=Source+Sans+Pro:wght@300;400;600' },
|
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Ubuntu+Mono&family=Source+Sans+Pro:wght@300;400;600' },
|
||||||
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons' }
|
// { rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons' }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -98,8 +98,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Build Configuration: https://go.nuxtjs.dev/config-build
|
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||||
build: {
|
build: {},
|
||||||
},
|
|
||||||
watchers: {
|
watchers: {
|
||||||
webpack: {
|
webpack: {
|
||||||
aggregateTimeout: 300,
|
aggregateTimeout: 300,
|
||||||
|
|||||||
Generated
+6
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf-client",
|
"name": "audiobookshelf-client",
|
||||||
"version": "1.4.8",
|
"version": "1.4.10",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -7385,6 +7385,11 @@
|
|||||||
"launch-editor": "^2.2.1"
|
"launch-editor": "^2.2.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libarchive.js": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/libarchive.js/-/libarchive.js-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-EkQfRXt9DhWwj6BnEA2TNpOf4jTnzSTUPGgE+iFxcdNqjktY8GitbDeHnx8qZA0/IukNyyBUR3oQKRdYkO+HFg=="
|
||||||
|
},
|
||||||
"lie": {
|
"lie": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf-client",
|
"name": "audiobookshelf-client",
|
||||||
"version": "1.4.9",
|
"version": "1.4.16",
|
||||||
"description": "Audiobook manager and player",
|
"description": "Audiobook manager and player",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
"date-fns": "^2.25.0",
|
"date-fns": "^2.25.0",
|
||||||
"epubjs": "^0.3.88",
|
"epubjs": "^0.3.88",
|
||||||
"hls.js": "^1.0.7",
|
"hls.js": "^1.0.7",
|
||||||
|
"libarchive.js": "^1.3.0",
|
||||||
"nuxt": "^2.15.7",
|
"nuxt": "^2.15.7",
|
||||||
"nuxt-socket-io": "^1.1.18",
|
"nuxt-socket-io": "^1.1.18",
|
||||||
"vue-pdf": "^4.3.0",
|
"vue-pdf": "^4.3.0",
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
logout() {
|
logout() {
|
||||||
this.$axios.$post('/logout').catch((error) => {
|
var rootSocket = this.$root.socket || {}
|
||||||
|
const logoutPayload = {
|
||||||
|
socketId: rootSocket.id
|
||||||
|
}
|
||||||
|
this.$axios.$post('/logout', logoutPayload).catch((error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
if (localStorage.getItem('token')) {
|
if (localStorage.getItem('token')) {
|
||||||
|
|||||||
@@ -10,10 +10,24 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="w-full flex items-center text-sm py-4 bg-primary border-l border-r border-t border-gray-600">
|
<div class="w-full flex items-center text-sm py-4 bg-primary border-l border-r border-t border-gray-600">
|
||||||
<div class="font-book text-center px-4 w-12">New</div>
|
<div class="font-book text-center px-4 w-12">New</div>
|
||||||
<div class="font-book text-center px-4 w-12">Old</div>
|
<div class="font-book text-center px-4 w-24 flex items-center cursor-pointer text-white text-opacity-40 hover:text-opacity-100" @click="sortByCurrent" @mousedown.prevent>
|
||||||
<div class="font-book text-center px-4 w-32">Track Parsed from Filename</div>
|
<span class="text-white">Current</span>
|
||||||
<div class="font-book text-center px-4 w-32">Track From Metadata</div>
|
<span class="material-icons ml-1" :class="currentSort === 'current' ? 'text-white text-opacity-100 text-lg' : 'text-sm'">{{ currentSort === 'current' ? 'expand_more' : 'unfold_more' }}</span>
|
||||||
<div class="font-book truncate px-4 flex-grow">Filename</div>
|
</div>
|
||||||
|
<div class="font-book text-center px-4 w-32 flex items-center cursor-pointer text-white text-opacity-40 hover:text-opacity-100" @click="sortByFilenameTrack" @mousedown.prevent>
|
||||||
|
<span class="text-white">Track From Filename</span>
|
||||||
|
<span class="material-icons ml-1" :class="currentSort === 'track-filename' ? 'text-white text-opacity-100 text-lg' : 'text-sm'">{{ currentSort === 'track-filename' ? 'expand_more' : 'unfold_more' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="font-book text-center px-4 w-32 flex items-center cursor-pointer text-white text-opacity-40 hover:text-opacity-100" @click="sortByMetadataTrack" @mousedown.prevent>
|
||||||
|
<span class="text-white">Track From Metadata</span>
|
||||||
|
<span class="material-icons ml-1" :class="currentSort === 'metadata' ? 'text-white text-opacity-100 text-lg' : 'text-sm'">{{ currentSort === 'metadata' ? 'expand_more' : 'unfold_more' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="font-mono w-20 text-center">CD From Filename</div>
|
||||||
|
<div class="font-book text-center px-4 flex-grow flex items-center cursor-pointer text-white text-opacity-40 hover:text-opacity-100" @click="sortByFilename" @mousedown.prevent>
|
||||||
|
<span class="text-white">Filename</span>
|
||||||
|
<span class="material-icons ml-1" :class="currentSort === 'filename' ? 'text-white text-opacity-100 text-lg' : 'text-sm'">{{ currentSort === 'filename' ? 'expand_more' : 'unfold_more' }}</span>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="font-book truncate px-4 flex-grow">Filename</div> -->
|
||||||
|
|
||||||
<div class="font-mono w-20 text-center">Size</div>
|
<div class="font-mono w-20 text-center">Size</div>
|
||||||
<div class="font-mono w-20 text-center">Duration</div>
|
<div class="font-mono w-20 text-center">Duration</div>
|
||||||
@@ -21,19 +35,22 @@
|
|||||||
<div class="font-mono w-56">Notes</div>
|
<div class="font-mono w-56">Notes</div>
|
||||||
<div class="font-book w-40">Include in Tracklist</div>
|
<div class="font-book w-40">Include in Tracklist</div>
|
||||||
</div>
|
</div>
|
||||||
<draggable v-model="files" v-bind="dragOptions" class="list-group border border-gray-600" draggable=".item" tag="ul" @start="drag = true" @end="drag = false">
|
<draggable v-model="files" v-bind="dragOptions" class="list-group border border-gray-600" draggable=".item" tag="ul" @start="drag = true" @end="drag = false" @update="draggableUpdate">
|
||||||
<transition-group type="transition" :name="!drag ? 'flip-list' : null">
|
<transition-group type="transition" :name="!drag ? 'flip-list' : null">
|
||||||
<li v-for="(audio, index) in files" :key="audio.path" :class="audio.include ? 'item' : 'exclude'" class="w-full list-group-item flex items-center">
|
<li v-for="(audio, index) in files" :key="audio.path" :class="audio.include ? 'item' : 'exclude'" class="w-full list-group-item flex items-center">
|
||||||
<div class="font-book text-center px-4 py-1 w-12">
|
<div class="font-book text-center px-4 py-1 w-12">
|
||||||
{{ audio.include ? index - numExcluded + 1 : -1 }}
|
{{ audio.include ? index - numExcluded + 1 : -1 }}
|
||||||
</div>
|
</div>
|
||||||
<div class="font-book text-center px-4 w-12">{{ audio.index }}</div>
|
<div class="font-book text-center px-4 w-24">{{ audio.index }}</div>
|
||||||
<div class="font-book text-center px-2 w-32">
|
<div class="font-book text-center px-2 w-32">
|
||||||
{{ audio.trackNumFromFilename }}
|
{{ audio.trackNumFromFilename }}
|
||||||
</div>
|
</div>
|
||||||
<div class="font-book text-center w-32">
|
<div class="font-book text-center w-32">
|
||||||
{{ audio.trackNumFromMeta }}
|
{{ audio.trackNumFromMeta }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="font-book truncate px-4 w-20">
|
||||||
|
{{ audio.cdNumFromFilename }}
|
||||||
|
</div>
|
||||||
<div class="font-book truncate px-4 flex-grow">
|
<div class="font-book truncate px-4 flex-grow">
|
||||||
{{ audio.filename }}
|
{{ audio.filename }}
|
||||||
</div>
|
</div>
|
||||||
@@ -56,6 +73,30 @@
|
|||||||
</li>
|
</li>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</draggable>
|
</draggable>
|
||||||
|
|
||||||
|
<div v-if="showExperimentalFeatures" class="p-4">
|
||||||
|
<ui-btn :loading="checkingTrackNumbers" small @click="checkTrackNumbers">Check Track Numbers</ui-btn>
|
||||||
|
<div v-if="trackNumData && trackNumData.length" class="w-full max-w-4xl py-2">
|
||||||
|
<table class="tracksTable">
|
||||||
|
<tr>
|
||||||
|
<th class="text-left">Filename</th>
|
||||||
|
<th class="w-32">Index</th>
|
||||||
|
<th class="w-32"># From Metadata</th>
|
||||||
|
<th class="w-32"># From Filename</th>
|
||||||
|
<th class="w-32"># From Probe</th>
|
||||||
|
<th class="w-32">Raw Tags</th>
|
||||||
|
</tr>
|
||||||
|
<tr v-for="trackData in trackNumData" :key="trackData.filename">
|
||||||
|
<td class="text-xs">{{ trackData.filename }}</td>
|
||||||
|
<td class="text-center">{{ trackData.currentTrackNum }}</td>
|
||||||
|
<td class="text-center">{{ trackData.trackNumFromMeta }}</td>
|
||||||
|
<td class="text-center">{{ trackData.trackNumFromFilename }}</td>
|
||||||
|
<td class="text-center">{{ trackData.scanDataTrackNum }}</td>
|
||||||
|
<td class="text-left text-xs">{{ JSON.stringify(trackData.rawTags || '') }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -95,7 +136,10 @@ export default {
|
|||||||
group: 'description',
|
group: 'description',
|
||||||
ghostClass: 'ghost'
|
ghostClass: 'ghost'
|
||||||
},
|
},
|
||||||
saving: false
|
saving: false,
|
||||||
|
checkingTrackNumbers: false,
|
||||||
|
trackNumData: [],
|
||||||
|
currentSort: 'current'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -172,9 +216,55 @@ export default {
|
|||||||
},
|
},
|
||||||
streamAudiobook() {
|
streamAudiobook() {
|
||||||
return this.$store.state.streamAudiobook
|
return this.$store.state.streamAudiobook
|
||||||
|
},
|
||||||
|
showExperimentalFeatures() {
|
||||||
|
return this.$store.state.showExperimentalFeatures
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
draggableUpdate(e) {
|
||||||
|
this.currentSort = ''
|
||||||
|
},
|
||||||
|
sortByCurrent() {
|
||||||
|
this.files.sort((a, b) => {
|
||||||
|
if (a.index === null) return 1
|
||||||
|
return a.index - b.index
|
||||||
|
})
|
||||||
|
this.currentSort = 'current'
|
||||||
|
},
|
||||||
|
sortByMetadataTrack() {
|
||||||
|
this.files.sort((a, b) => {
|
||||||
|
if (a.trackNumFromMeta === null) return 1
|
||||||
|
return a.trackNumFromMeta - b.trackNumFromMeta
|
||||||
|
})
|
||||||
|
this.currentSort = 'metadata'
|
||||||
|
},
|
||||||
|
sortByFilenameTrack() {
|
||||||
|
this.files.sort((a, b) => {
|
||||||
|
if (a.trackNumFromFilename === null) return 1
|
||||||
|
return a.trackNumFromFilename - b.trackNumFromFilename
|
||||||
|
})
|
||||||
|
this.currentSort = 'track-filename'
|
||||||
|
},
|
||||||
|
sortByFilename() {
|
||||||
|
this.files.sort((a, b) => {
|
||||||
|
return (a.filename || '').toLowerCase().localeCompare((b.filename || '').toLowerCase())
|
||||||
|
})
|
||||||
|
this.currentSort = 'filename'
|
||||||
|
},
|
||||||
|
checkTrackNumbers() {
|
||||||
|
this.checkingTrackNumbers = true
|
||||||
|
this.$axios
|
||||||
|
.$get(`/api/scantracks/${this.audiobookId}`)
|
||||||
|
.then((res) => {
|
||||||
|
this.trackNumData = res
|
||||||
|
this.checkingTrackNumbers = false
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Failed', error)
|
||||||
|
this.checkingTrackNumbers = false
|
||||||
|
})
|
||||||
|
},
|
||||||
includeToggled(audio) {
|
includeToggled(audio) {
|
||||||
var new_index = 0
|
var new_index = 0
|
||||||
if (audio.include) {
|
if (audio.include) {
|
||||||
|
|||||||
@@ -19,16 +19,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="mb-2 mt-0.5 text-gray-100 text-xl">
|
<p class="mb-2 mt-0.5 text-gray-100 text-xl">
|
||||||
by <nuxt-link v-if="author" :to="`/library/${libraryId}/bookshelf?filter=authors.${$encode(author)}`" class="hover:underline">{{ author }}</nuxt-link
|
by <nuxt-link v-if="authorFL" :to="`/library/${libraryId}/bookshelf?filter=authors.${$encode(authorFL)}`" class="hover:underline">{{ authorFL }}</nuxt-link
|
||||||
><span v-else>Unknown</span>
|
><span v-else>Unknown</span>
|
||||||
</p>
|
</p>
|
||||||
<nuxt-link v-if="series" :to="`/library/${libraryId}/bookshelf/series?series=${$encode(series)}`" class="hover:underline font-sans text-gray-300 text-lg leading-7 mb-4"> {{ seriesText }}</nuxt-link>
|
<nuxt-link v-if="series" :to="`/library/${libraryId}/bookshelf/series?series=${$encode(series)}`" class="hover:underline font-sans text-gray-300 text-lg leading-7 mb-4"> {{ seriesText }}</nuxt-link>
|
||||||
|
|
||||||
<!-- <div class="w-min">
|
|
||||||
<ui-tooltip :text="authorTooltipText" direction="bottom">
|
|
||||||
<span class="text-base text-gray-100 leading-8 whitespace-nowrap"><span class="text-white text-opacity-60">By:</span> {{ author }}</span>
|
|
||||||
</ui-tooltip>
|
|
||||||
</div> -->
|
|
||||||
<div v-if="narrator" class="flex py-0.5">
|
<div v-if="narrator" class="flex py-0.5">
|
||||||
<div class="w-32">
|
<div class="w-32">
|
||||||
<span class="text-white text-opacity-60 uppercase text-sm">Narrated By</span>
|
<span class="text-white text-opacity-60 uppercase text-sm">Narrated By</span>
|
||||||
@@ -81,10 +76,6 @@
|
|||||||
<span class="material-icons text-2xl">warning_amber</span>
|
<span class="material-icons text-2xl">warning_amber</span>
|
||||||
<p class="ml-4">Book has no audio tracks but has valid ebook files. The e-reader is experimental and can be turned on in config.</p>
|
<p class="ml-4">Book has no audio tracks but has valid ebook files. The e-reader is experimental and can be turned on in config.</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="showEpubAlert" class="bg-error p-4 rounded-xl flex items-center mt-2">
|
|
||||||
<span class="material-icons text-2xl">warning_amber</span>
|
|
||||||
<p class="ml-4">Book has valid ebook files, but the experimental e-reader currently only supports epub files.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="progressPercent > 0 && progressPercent < 1" class="px-4 py-2 mt-4 bg-primary text-sm font-semibold rounded-md text-gray-200 relative max-w-max" :class="resettingProgress ? 'opacity-25' : ''">
|
<div v-if="progressPercent > 0 && progressPercent < 1" class="px-4 py-2 mt-4 bg-primary text-sm font-semibold rounded-md text-gray-200 relative max-w-max" :class="resettingProgress ? 'opacity-25' : ''">
|
||||||
<p class="leading-6">Your Progress: {{ Math.round(progressPercent * 100) }}%</p>
|
<p class="leading-6">Your Progress: {{ Math.round(progressPercent * 100) }}%</p>
|
||||||
@@ -104,7 +95,7 @@
|
|||||||
{{ isMissing ? 'Missing' : 'Incomplete' }}
|
{{ isMissing ? 'Missing' : 'Incomplete' }}
|
||||||
</ui-btn>
|
</ui-btn>
|
||||||
|
|
||||||
<ui-btn v-if="showExperimentalFeatures && (epubEbook || mobiEbook)" color="info" :padding-x="4" small class="flex items-center h-9 mr-2" @click="openEbook">
|
<ui-btn v-if="showExperimentalFeatures && numEbooks" color="info" :padding-x="4" small class="flex items-center h-9 mr-2" @click="openEbook">
|
||||||
<span class="material-icons -ml-2 pr-2 text-white">auto_stories</span>
|
<span class="material-icons -ml-2 pr-2 text-white">auto_stories</span>
|
||||||
Read
|
Read
|
||||||
</ui-btn>
|
</ui-btn>
|
||||||
@@ -152,8 +143,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <app-reader v-if="showExperimentalFeatures" v-model="showReader" :url="epubUrl" /> -->
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -321,17 +310,11 @@ export default {
|
|||||||
ebooks() {
|
ebooks() {
|
||||||
return this.audiobook.ebooks
|
return this.audiobook.ebooks
|
||||||
},
|
},
|
||||||
showEpubAlert() {
|
|
||||||
return this.ebooks.length && !this.epubEbook && !this.tracks.length
|
|
||||||
},
|
|
||||||
showExperimentalReadAlert() {
|
showExperimentalReadAlert() {
|
||||||
return !this.tracks.length && this.ebooks.length && !this.showExperimentalFeatures
|
return !this.tracks.length && this.ebooks.length && !this.showExperimentalFeatures
|
||||||
},
|
},
|
||||||
epubEbook() {
|
numEbooks() {
|
||||||
return this.ebooks.find((eb) => eb.ext === '.epub')
|
return this.audiobook.numEbooks
|
||||||
},
|
|
||||||
mobiEbook() {
|
|
||||||
return this.ebooks.find((eb) => eb.ext === '.mobi' || eb.ext === '.azw3')
|
|
||||||
},
|
},
|
||||||
userToken() {
|
userToken() {
|
||||||
return this.$store.getters['user/getToken']
|
return this.$store.getters['user/getToken']
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<template>
|
||||||
|
<div id="page-wrapper" class="page p-6 overflow-y-auto relative" :class="streamAudiobook ? 'streaming' : ''">
|
||||||
|
<app-config-side-nav />
|
||||||
|
<div class="w-full max-w-4xl mx-auto">
|
||||||
|
<nuxt-child />
|
||||||
|
</div>
|
||||||
|
<div class="fixed bottom-0 right-0 w-10 h-10" @dblclick="setDeveloperMode"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
asyncData({ store, redirect }) {
|
||||||
|
if (!store.getters['user/getIsRoot']) {
|
||||||
|
redirect('/?error=unauthorized')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
streamAudiobook() {
|
||||||
|
return this.$store.state.streamAudiobook
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setDeveloperMode() {
|
||||||
|
var value = !this.$store.state.developerMode
|
||||||
|
this.$store.commit('setDeveloperMode', value)
|
||||||
|
this.$toast.info(`Developer Mode ${value ? 'Enabled' : 'Disabled'}`)
|
||||||
|
}
|
||||||
|
// saveMetadataComplete(result) {
|
||||||
|
// this.savingMetadata = false
|
||||||
|
// if (!result) return
|
||||||
|
// this.$toast.success(`Metadata saved for ${result.success} audiobooks`)
|
||||||
|
// },
|
||||||
|
// saveMetadataFiles() {
|
||||||
|
// this.savingMetadata = true
|
||||||
|
// this.$root.socket.once('save_metadata_complete', this.saveMetadataComplete)
|
||||||
|
// this.$root.socket.emit('save_metadata')
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-full h-full">
|
||||||
|
<div class="bg-bg rounded-md shadow-lg border border-white border-opacity-5 p-4 mb-8">
|
||||||
|
<div class="flex items-center mb-2">
|
||||||
|
<h1 class="text-xl">Backups</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-base mb-4 text-gray-300">Backups include users, user progress, book details, server settings and covers stored in <span class="font-mono text-gray-100">/metadata/books</span>. <br />Backups <strong>do not</strong> include any files stored in your library folders.</p>
|
||||||
|
|
||||||
|
<div class="flex items-center py-2">
|
||||||
|
<ui-toggle-switch v-model="dailyBackups" small :disabled="updatingServerSettings" @input="updateBackupsSettings" />
|
||||||
|
<ui-tooltip :text="dailyBackupsTooltip">
|
||||||
|
<p class="pl-4 text-lg">Run daily backups <span class="material-icons icon-text">info_outlined</span></p>
|
||||||
|
</ui-tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center py-2">
|
||||||
|
<ui-text-input type="number" v-model="backupsToKeep" no-spinner :disabled="updatingServerSettings" :padding-x="1" text-center class="w-10" @change="updateBackupsSettings" />
|
||||||
|
|
||||||
|
<p class="pl-4 text-lg">Number of backups to keep</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<tables-backups-table />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
updatingServerSettings: false,
|
||||||
|
dailyBackups: true,
|
||||||
|
backupsToKeep: 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
dailyBackupsTooltip() {
|
||||||
|
return 'Runs at 1am every day (your server time). Saved in /metadata/backups.'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateBackupsSettings() {
|
||||||
|
if (isNaN(this.backupsToKeep) || this.backupsToKeep <= 0 || this.backupsToKeep > 99) {
|
||||||
|
this.$toast.error('Invalid number of backups to keep')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var updatePayload = {
|
||||||
|
backupSchedule: this.dailyBackups ? '0 1 * * *' : false,
|
||||||
|
backupsToKeep: Number(this.backupsToKeep)
|
||||||
|
}
|
||||||
|
this.updateServerSettings(updatePayload)
|
||||||
|
},
|
||||||
|
updateServerSettings(payload) {
|
||||||
|
this.updatingServerSettings = true
|
||||||
|
this.$store
|
||||||
|
.dispatch('updateServerSettings', payload)
|
||||||
|
.then((success) => {
|
||||||
|
console.log('Updated Server Settings', success)
|
||||||
|
this.updatingServerSettings = false
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Failed to update server settings', error)
|
||||||
|
this.updatingServerSettings = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
+72
-166
@@ -1,125 +1,77 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="page-wrapper" class="page p-6 overflow-y-auto" :class="streamAudiobook ? 'streaming' : ''">
|
<div>
|
||||||
<div class="w-full max-w-4xl mx-auto">
|
<!-- <div class="h-0.5 bg-primary bg-opacity-50 w-full" /> -->
|
||||||
<tables-users-table />
|
|
||||||
<!-- <div class="h-0.5 bg-primary bg-opacity-50 w-full" /> -->
|
|
||||||
|
|
||||||
<tables-libraries-table />
|
<div class="bg-bg rounded-md shadow-lg border border-white border-opacity-5 p-4 mb-8">
|
||||||
<!-- <div class="h-0.5 bg-primary bg-opacity-50 w-full" /> -->
|
<div class="flex items-center mb-2">
|
||||||
<div class="bg-bg rounded-md shadow-lg border border-white border-opacity-5 p-4 mb-8">
|
<h1 class="text-xl">Settings</h1>
|
||||||
<div class="flex items-center mb-2">
|
|
||||||
<h1 class="text-xl">Settings</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center py-2">
|
|
||||||
<ui-toggle-switch v-model="newServerSettings.scannerParseSubtitle" small :disabled="updatingServerSettings" @input="updateScannerParseSubtitle" />
|
|
||||||
<ui-tooltip :text="parseSubtitleTooltip">
|
|
||||||
<p class="pl-4 text-lg">Scanner parse subtitles <span class="material-icons icon-text">info_outlined</span></p>
|
|
||||||
</ui-tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center py-2">
|
|
||||||
<ui-toggle-switch v-model="newServerSettings.scannerFindCovers" :disabled="updatingServerSettings" @input="updateScannerFindCovers" />
|
|
||||||
<ui-tooltip :text="scannerFindCoversTooltip">
|
|
||||||
<p class="pl-4 text-lg">Scanner find covers <span class="material-icons icon-text">info_outlined</span></p>
|
|
||||||
</ui-tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center py-2">
|
|
||||||
<ui-toggle-switch v-model="storeCoversInAudiobookDir" :disabled="updatingServerSettings" @input="updateCoverStorageDestination" />
|
|
||||||
<ui-tooltip :text="coverDestinationTooltip">
|
|
||||||
<p class="pl-4 text-lg">Store covers with audiobook <span class="material-icons icon-text">info_outlined</span></p>
|
|
||||||
</ui-tooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-0.5 bg-primary bg-opacity-50 w-full" />
|
<div class="flex items-center py-2">
|
||||||
|
<ui-toggle-switch v-model="newServerSettings.scannerParseSubtitle" small :disabled="updatingServerSettings" @input="updateScannerParseSubtitle" />
|
||||||
<div class="bg-bg rounded-md shadow-lg border border-white border-opacity-5 p-4 mb-8">
|
<ui-tooltip :text="parseSubtitleTooltip">
|
||||||
<div class="flex items-center mb-2">
|
<p class="pl-4 text-lg">Scanner parse subtitles <span class="material-icons icon-text">info_outlined</span></p>
|
||||||
<h1 class="text-xl">Backups</h1>
|
</ui-tooltip>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="text-base mb-4 text-gray-300">Backups include users, user progress, book details, server settings and covers stored in <span class="font-mono text-gray-100">/metadata/books</span>. <br />Backups <strong>do not</strong> include any files stored in your library folders.</p>
|
|
||||||
|
|
||||||
<div class="flex items-center py-2">
|
|
||||||
<ui-toggle-switch v-model="dailyBackups" small :disabled="updatingServerSettings" @input="updateBackupsSettings" />
|
|
||||||
<ui-tooltip :text="dailyBackupsTooltip">
|
|
||||||
<p class="pl-4 text-lg">Run daily backups <span class="material-icons icon-text">info_outlined</span></p>
|
|
||||||
</ui-tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center py-2">
|
|
||||||
<ui-text-input type="number" v-model="backupsToKeep" no-spinner :disabled="updatingServerSettings" :padding-x="1" text-center class="w-10" @change="updateBackupsSettings" />
|
|
||||||
|
|
||||||
<p class="pl-4 text-lg">Number of backups to keep</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<tables-backups-table />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-0.5 bg-primary bg-opacity-50 w-full" />
|
<div class="flex items-center py-2">
|
||||||
|
<ui-toggle-switch v-model="newServerSettings.scannerFindCovers" :disabled="updatingServerSettings" @input="updateScannerFindCovers" />
|
||||||
<div class="flex items-center py-4">
|
<ui-tooltip :text="scannerFindCoversTooltip">
|
||||||
<ui-btn color="bg" small :padding-x="4" :loading="isResettingAudiobooks" @click="resetAudiobooks">Reset All Audiobooks</ui-btn>
|
<p class="pl-4 text-lg">Scanner find covers <span class="material-icons icon-text">info_outlined</span></p>
|
||||||
<div class="flex-grow" />
|
</ui-tooltip>
|
||||||
<ui-btn to="/config/log">View Logger</ui-btn>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-0.5 bg-primary bg-opacity-50 w-full" />
|
<div class="flex items-center py-2">
|
||||||
|
<ui-toggle-switch v-model="storeCoversInAudiobookDir" :disabled="updatingServerSettings" @input="updateCoverStorageDestination" />
|
||||||
<div class="flex items-center py-4">
|
<ui-tooltip :text="coverDestinationTooltip">
|
||||||
<p class="font-mono">v{{ $config.version }}</p>
|
<p class="pl-4 text-lg">Store covers with audiobook <span class="material-icons icon-text">info_outlined</span></p>
|
||||||
<div class="flex-grow" />
|
</ui-tooltip>
|
||||||
<p class="pr-2 text-sm font-book text-yellow-400">Report bugs, request features, provide feedback, and contribute on <a class="underline" href="https://github.com/advplyr/audiobookshelf" target="_blank">github</a>.</p>
|
|
||||||
<a href="https://github.com/advplyr/audiobookshelf" target="_blank" class="text-white hover:text-gray-200 hover:scale-150 hover:rotate-6 transform duration-500">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24">
|
|
||||||
<path
|
|
||||||
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="h-0.5 bg-primary bg-opacity-30 w-full" />
|
|
||||||
|
|
||||||
<div class="py-12 mb-4 opacity-60 hover:opacity-100">
|
|
||||||
<div class="flex items-center">
|
|
||||||
<div>
|
|
||||||
<div class="flex items-center">
|
|
||||||
<ui-toggle-switch v-model="showExperimentalFeatures" />
|
|
||||||
<ui-tooltip :text="experimentalFeaturesTooltip">
|
|
||||||
<p class="pl-4 text-lg">Experimental Features <span class="material-icons icon-text">info_outlined</span></p>
|
|
||||||
</ui-tooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- <div class="flex-grow" /> -->
|
|
||||||
<div>
|
|
||||||
<a href="https://github.com/advplyr/audiobookshelf/discussions/75#discussion-3604812" target="_blank" class="text-blue-500 hover:text-blue-300 underline">Join the discussion</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fixed bottom-0 left-0 w-10 h-10" @dblclick="setDeveloperMode"></div>
|
<div class="h-0.5 bg-primary bg-opacity-30 w-full" />
|
||||||
|
|
||||||
|
<div class="flex items-center py-4">
|
||||||
|
<ui-btn color="bg" small :padding-x="4" :loading="isResettingAudiobooks" @click="resetAudiobooks">Reset All Audiobooks</ui-btn>
|
||||||
|
<div class="flex-grow" />
|
||||||
|
<p class="pr-2 text-sm font-book text-yellow-400">Report bugs, request features, provide feedback, and contribute on <a class="underline" href="https://github.com/advplyr/audiobookshelf" target="_blank">github</a>.</p>
|
||||||
|
<a href="https://github.com/advplyr/audiobookshelf" target="_blank" class="text-white hover:text-gray-200 hover:scale-150 hover:rotate-6 transform duration-500">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24">
|
||||||
|
<path
|
||||||
|
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="h-0.5 bg-primary bg-opacity-30 w-full" />
|
||||||
|
|
||||||
|
<div class="py-12 mb-4 opacity-60 hover:opacity-100">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<ui-toggle-switch v-model="showExperimentalFeatures" />
|
||||||
|
<ui-tooltip :text="experimentalFeaturesTooltip">
|
||||||
|
<p class="pl-4 text-lg">Experimental Features <span class="material-icons icon-text">info_outlined</span></p>
|
||||||
|
</ui-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="https://github.com/advplyr/audiobookshelf/discussions/75#discussion-3604812" target="_blank" class="text-blue-500 hover:text-blue-300 underline">Join the discussion</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
asyncData({ store, redirect }) {
|
|
||||||
if (!store.getters['user/getIsRoot']) {
|
|
||||||
redirect('/?error=unauthorized')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
storeCoversInAudiobookDir: false,
|
|
||||||
isResettingAudiobooks: false,
|
isResettingAudiobooks: false,
|
||||||
newServerSettings: {},
|
storeCoversInAudiobookDir: false,
|
||||||
updatingServerSettings: false,
|
updatingServerSettings: false,
|
||||||
dailyBackups: true,
|
newServerSettings: {}
|
||||||
backupsToKeep: 2
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -131,6 +83,15 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
saveMetadataTooltip() {
|
||||||
|
return 'This will write a "metadata.nfo" file in all of your audiobook directories.'
|
||||||
|
},
|
||||||
|
experimentalFeaturesTooltip() {
|
||||||
|
return 'Features in development that could use your feedback and help testing.'
|
||||||
|
},
|
||||||
|
serverSettings() {
|
||||||
|
return this.$store.state.serverSettings
|
||||||
|
},
|
||||||
parseSubtitleTooltip() {
|
parseSubtitleTooltip() {
|
||||||
return 'Extract subtitles from audiobook directory names.<br>Subtitle must be seperated by " - "<br>i.e. "Book Title - A Subtitle Here" has the subtitle "A Subtitle Here"'
|
return 'Extract subtitles from audiobook directory names.<br>Subtitle must be seperated by " - "<br>i.e. "Book Title - A Subtitle Here" has the subtitle "A Subtitle Here"'
|
||||||
},
|
},
|
||||||
@@ -140,30 +101,6 @@ export default {
|
|||||||
scannerFindCoversTooltip() {
|
scannerFindCoversTooltip() {
|
||||||
return 'If your audiobook does not have an embedded cover or a cover image inside the folder, the scanner will attempt to find a cover.<br>Note: This will extend scan time'
|
return 'If your audiobook does not have an embedded cover or a cover image inside the folder, the scanner will attempt to find a cover.<br>Note: This will extend scan time'
|
||||||
},
|
},
|
||||||
saveMetadataTooltip() {
|
|
||||||
return 'This will write a "metadata.nfo" file in all of your audiobook directories.'
|
|
||||||
},
|
|
||||||
experimentalFeaturesTooltip() {
|
|
||||||
return 'Features in development that could use your feedback and help testing.'
|
|
||||||
},
|
|
||||||
dailyBackupsTooltip() {
|
|
||||||
return 'Runs at 1am every day (your server time). Saved in /metadata/backups.'
|
|
||||||
},
|
|
||||||
backupsToKeepTooltip() {
|
|
||||||
return ''
|
|
||||||
},
|
|
||||||
serverSettings() {
|
|
||||||
return this.$store.state.serverSettings
|
|
||||||
},
|
|
||||||
streamAudiobook() {
|
|
||||||
return this.$store.state.streamAudiobook
|
|
||||||
},
|
|
||||||
isScanning() {
|
|
||||||
return this.$store.state.isScanning
|
|
||||||
},
|
|
||||||
isScanningCovers() {
|
|
||||||
return this.$store.state.isScanningCovers
|
|
||||||
},
|
|
||||||
showExperimentalFeatures: {
|
showExperimentalFeatures: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.state.showExperimentalFeatures
|
return this.$store.state.showExperimentalFeatures
|
||||||
@@ -174,17 +111,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateBackupsSettings() {
|
|
||||||
if (isNaN(this.backupsToKeep) || this.backupsToKeep <= 0 || this.backupsToKeep > 99) {
|
|
||||||
this.$toast.error('Invalid number of backups to keep')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var updatePayload = {
|
|
||||||
backupSchedule: this.dailyBackups ? '0 1 * * *' : false,
|
|
||||||
backupsToKeep: Number(this.backupsToKeep)
|
|
||||||
}
|
|
||||||
this.updateServerSettings(updatePayload)
|
|
||||||
},
|
|
||||||
updateScannerFindCovers(val) {
|
updateScannerFindCovers(val) {
|
||||||
this.updateServerSettings({
|
this.updateServerSettings({
|
||||||
scannerFindCovers: !!val
|
scannerFindCovers: !!val
|
||||||
@@ -214,23 +140,13 @@ export default {
|
|||||||
this.updatingServerSettings = false
|
this.updatingServerSettings = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setDeveloperMode() {
|
initServerSettings() {
|
||||||
var value = !this.$store.state.developerMode
|
this.newServerSettings = this.serverSettings ? { ...this.serverSettings } : {}
|
||||||
this.$store.commit('setDeveloperMode', value)
|
|
||||||
this.$toast.info(`Developer Mode ${value ? 'Enabled' : 'Disabled'}`)
|
this.storeCoversInAudiobookDir = this.newServerSettings.coverDestination === this.$constants.CoverDestination.AUDIOBOOK
|
||||||
},
|
this.storeCoversInAudiobookDir = this.newServerSettings.coverDestination === this.$constants.CoverDestination.AUDIOBOOK
|
||||||
scan() {
|
this.backupsToKeep = this.newServerSettings.backupsToKeep || 2
|
||||||
this.$root.socket.emit('scan', this.$store.state.libraries.currentLibraryId)
|
this.dailyBackups = !!this.newServerSettings.backupSchedule
|
||||||
},
|
|
||||||
saveMetadataComplete(result) {
|
|
||||||
this.savingMetadata = false
|
|
||||||
if (!result) return
|
|
||||||
this.$toast.success(`Metadata saved for ${result.success} audiobooks`)
|
|
||||||
},
|
|
||||||
saveMetadataFiles() {
|
|
||||||
this.savingMetadata = true
|
|
||||||
this.$root.socket.once('save_metadata_complete', this.saveMetadataComplete)
|
|
||||||
this.$root.socket.emit('save_metadata')
|
|
||||||
},
|
},
|
||||||
resetAudiobooks() {
|
resetAudiobooks() {
|
||||||
if (confirm('WARNING! This action will remove all audiobooks from the database including any updates or matches you have made. This does not do anything to your actual files. Shall we continue?')) {
|
if (confirm('WARNING! This action will remove all audiobooks from the database including any updates or matches you have made. This does not do anything to your actual files. Shall we continue?')) {
|
||||||
@@ -248,20 +164,10 @@ export default {
|
|||||||
this.$toast.error('Failed to reset audiobooks - manually remove the /config/audiobooks folder')
|
this.$toast.error('Failed to reset audiobooks - manually remove the /config/audiobooks folder')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
|
||||||
init() {
|
|
||||||
this.newServerSettings = this.serverSettings ? { ...this.serverSettings } : {}
|
|
||||||
this.initServerSettings()
|
|
||||||
},
|
|
||||||
initServerSettings() {
|
|
||||||
this.storeCoversInAudiobookDir = this.newServerSettings.coverDestination === this.$constants.CoverDestination.AUDIOBOOK
|
|
||||||
this.storeCoversInAudiobookDir = this.newServerSettings.coverDestination === this.$constants.CoverDestination.AUDIOBOOK
|
|
||||||
this.backupsToKeep = this.newServerSettings.backupsToKeep || 2
|
|
||||||
this.dailyBackups = !!this.newServerSettings.backupSchedule
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init()
|
this.initServerSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<tables-libraries-table />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-full h-full">
|
||||||
|
<div class="bg-bg rounded-md shadow-lg border border-white border-opacity-5 p-4 mb-8">
|
||||||
|
<nuxt-link to="/config/users" class="text-white text-opacity-70 hover:text-opacity-100 hover:bg-white hover:bg-opacity-5 cursor-pointer rounded-full">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="h-10 w-10 flex items-center justify-center">
|
||||||
|
<span class="material-icons text-2xl">arrow_back</span>
|
||||||
|
</div>
|
||||||
|
<p class="pl-1">All Users</p>
|
||||||
|
</div>
|
||||||
|
</nuxt-link>
|
||||||
|
<div class="flex items-center mb-2 mt-4">
|
||||||
|
<widgets-online-indicator :value="!!userOnline" />
|
||||||
|
<h1 class="text-xl pl-2">{{ username }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="w-full h-px bg-white bg-opacity-10 my-2" />
|
||||||
|
<div class="py-2">
|
||||||
|
<h1 class="text-lg mb-2 text-white text-opacity-90">Reading Progress</h1>
|
||||||
|
<table v-if="userAudiobooks.length" class="userAudiobooksTable">
|
||||||
|
<tr class="bg-primary bg-opacity-40">
|
||||||
|
<th class="w-16 text-left">Book</th>
|
||||||
|
<th class="text-left"></th>
|
||||||
|
<th class="w-32">Progress</th>
|
||||||
|
<th class="w-40">Started At</th>
|
||||||
|
<th class="w-40">Last Update</th>
|
||||||
|
</tr>
|
||||||
|
<tr v-for="ab in userAudiobooks" :key="ab.audiobookId" :class="!ab.isRead ? '' : 'isRead'">
|
||||||
|
<td>
|
||||||
|
<cards-book-cover :width="50" :audiobook="ab" />
|
||||||
|
</td>
|
||||||
|
<td class="font-book">
|
||||||
|
<p>{{ ab.book ? ab.book.title : ab.audiobookTitle || 'Unknown' }}</p>
|
||||||
|
<p v-if="ab.book && ab.book.author" class="text-white text-opacity-50 text-sm font-sans">by {{ ab.book.author }}</p>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">{{ Math.floor(ab.progress * 100) }}%</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<ui-tooltip v-if="ab.startedAt" direction="top" :text="$formatDate(ab.startedAt, 'MMMM do, yyyy HH:mm')">
|
||||||
|
<p class="text-sm">{{ $dateDistanceFromNow(ab.startedAt) }}</p>
|
||||||
|
</ui-tooltip>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<ui-tooltip v-if="ab.lastUpdate" direction="top" :text="$formatDate(ab.lastUpdate, 'MMMM do, yyyy HH:mm')">
|
||||||
|
<p class="text-sm">{{ $dateDistanceFromNow(ab.lastUpdate) }}</p>
|
||||||
|
</ui-tooltip>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p v-else class="text-white text-opacity-50">Nothing read yet...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
async asyncData({ params, redirect, app }) {
|
||||||
|
var user = await app.$axios.$get(`/api/user/${params.id}`).catch((error) => {
|
||||||
|
console.error('Failed to get user', error)
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
if (!user) return redirect('/config/users')
|
||||||
|
return {
|
||||||
|
user
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
username() {
|
||||||
|
return this.user.username
|
||||||
|
},
|
||||||
|
userOnline() {
|
||||||
|
return this.$store.getters['users/getIsUserOnline'](this.user.id)
|
||||||
|
},
|
||||||
|
userAudiobooks() {
|
||||||
|
return Object.values(this.user.audiobooks || {}).sort((a, b) => b.lastUpdate - a.lastUpdate)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.userAudiobooksTable {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #474747;
|
||||||
|
}
|
||||||
|
.userAudiobooksTable tr:nth-child(even) {
|
||||||
|
background-color: #2e2e2e;
|
||||||
|
}
|
||||||
|
.userAudiobooksTable tr:not(:first-child) {
|
||||||
|
background-color: #373838;
|
||||||
|
}
|
||||||
|
.userAudiobooksTable tr:hover:not(:first-child) {
|
||||||
|
background-color: #474747;
|
||||||
|
}
|
||||||
|
.userAudiobooksTable tr.isRead {
|
||||||
|
background-color: rgba(76, 175, 80, 0.1);
|
||||||
|
}
|
||||||
|
.userAudiobooksTable td {
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
.userAudiobooksTable th {
|
||||||
|
padding: 4px 8px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<tables-users-table />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {},
|
||||||
|
mounted() {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -19,27 +19,37 @@ export default {
|
|||||||
return redirect('/oops?message=Library not found')
|
return redirect('/oops?message=Library not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set filter by
|
||||||
if (query.filter) {
|
if (query.filter) {
|
||||||
store.dispatch('user/updateUserSettings', { filterBy: query.filter })
|
store.dispatch('user/updateUserSettings', { filterBy: query.filter })
|
||||||
}
|
}
|
||||||
var searchResults = []
|
|
||||||
|
// Search page
|
||||||
|
var searchResults = {}
|
||||||
|
var audiobookSearchResults = []
|
||||||
var searchQuery = null
|
var searchQuery = null
|
||||||
if (params.id === 'search' && query.query) {
|
if (params.id === 'search' && query.query) {
|
||||||
searchQuery = query.query
|
searchQuery = query.query
|
||||||
searchResults = await app.$axios.$get(`/api/library/${libraryId}/audiobooks?q=${query.query}`).catch((error) => {
|
|
||||||
|
searchResults = await app.$axios.$get(`/api/library/${libraryId}/search?q=${searchQuery}`).catch((error) => {
|
||||||
console.error('Search error', error)
|
console.error('Search error', error)
|
||||||
return []
|
return {}
|
||||||
})
|
})
|
||||||
|
audiobookSearchResults = searchResults.audiobooks || []
|
||||||
store.commit('audiobooks/setSearchResults', searchResults)
|
store.commit('audiobooks/setSearchResults', searchResults)
|
||||||
if (searchResults.length) searchResults.forEach((ab) => store.commit('audiobooks/addUpdate', ab))
|
if (audiobookSearchResults.length) audiobookSearchResults.forEach((ab) => store.commit('audiobooks/addUpdate', ab.audiobook))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Series page
|
||||||
var selectedSeries = query.series ? app.$decode(query.series) : null
|
var selectedSeries = query.series ? app.$decode(query.series) : null
|
||||||
store.commit('audiobooks/setSelectedSeries', selectedSeries)
|
store.commit('audiobooks/setSelectedSeries', selectedSeries)
|
||||||
|
|
||||||
var libraryPage = params.id || ''
|
var libraryPage = params.id || ''
|
||||||
store.commit('audiobooks/setLibraryPage', libraryPage)
|
store.commit('audiobooks/setLibraryPage', libraryPage)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: libraryPage,
|
id: libraryPage,
|
||||||
|
libraryId,
|
||||||
searchQuery,
|
searchQuery,
|
||||||
searchResults,
|
searchResults,
|
||||||
selectedSeries
|
selectedSeries
|
||||||
@@ -65,9 +75,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async newQuery() {
|
async newQuery() {
|
||||||
var query = this.$route.query.query
|
var query = this.$route.query.query
|
||||||
this.searchResults = await this.$axios.$get(`/api/audiobooks?q=${query}`).catch((error) => {
|
this.searchResults = await this.$axios.$get(`/api/library/${this.libraryId}/search?q=${query}`).catch((error) => {
|
||||||
console.error('Search error', error)
|
console.error('Search error', error)
|
||||||
return []
|
return {}
|
||||||
})
|
})
|
||||||
this.searchQuery = query
|
this.searchQuery = query
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-2
@@ -48,6 +48,24 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setUser(user) {
|
||||||
|
// If user is not able to access main library, then set current library
|
||||||
|
// var userLibrariesAccessible = this.$store.getters['user/getLibrariesAccessible']
|
||||||
|
var userCanAccessAll = user.permissions ? !!user.permissions.accessAllLibraries : false
|
||||||
|
if (!userCanAccessAll) {
|
||||||
|
var accessibleLibraries = user.librariesAccessible || []
|
||||||
|
console.log('Setting user without all library access', accessibleLibraries)
|
||||||
|
if (accessibleLibraries.length && !accessibleLibraries.includes('main')) {
|
||||||
|
console.log('Setting current library', accessibleLibraries[0])
|
||||||
|
this.$store.commit('libraries/setCurrentLibrary', accessibleLibraries[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (userLibrariesAccessible.length && !userLibrariesAccessible.includes('main')) {
|
||||||
|
// this.$store.commit('libraries/setCurrentLibrary', userLibrariesAccessible[0])
|
||||||
|
// }
|
||||||
|
|
||||||
|
this.$store.commit('user/setUser', user)
|
||||||
|
},
|
||||||
async submitForm() {
|
async submitForm() {
|
||||||
this.error = null
|
this.error = null
|
||||||
this.processing = true
|
this.processing = true
|
||||||
@@ -65,7 +83,7 @@ export default {
|
|||||||
if (authRes && authRes.error) {
|
if (authRes && authRes.error) {
|
||||||
this.error = authRes.error
|
this.error = authRes.error
|
||||||
} else if (authRes) {
|
} else if (authRes) {
|
||||||
this.$store.commit('user/setUser', authRes.user)
|
this.setUser(authRes.user)
|
||||||
}
|
}
|
||||||
this.processing = false
|
this.processing = false
|
||||||
},
|
},
|
||||||
@@ -83,7 +101,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.$store.commit('user/setUser', res.user)
|
this.setUser(res.user)
|
||||||
this.processing = false
|
this.processing = false
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
export default function ({ $axios, store }) {
|
export default function ({ $axios, store }) {
|
||||||
$axios.onRequest(config => {
|
$axios.onRequest(config => {
|
||||||
|
if (!config.url) {
|
||||||
|
console.error('Axios request invalid config', config)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (config.url.startsWith('http:') || config.url.startsWith('https:')) {
|
if (config.url.startsWith('http:') || config.url.startsWith('https:')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,18 @@ const Constants = {
|
|||||||
CoverDestination
|
CoverDestination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const KeyNames = {
|
||||||
|
27: 'Escape',
|
||||||
|
32: 'Space',
|
||||||
|
37: 'ArrowLeft',
|
||||||
|
38: 'ArrowUp',
|
||||||
|
39: 'ArrowRight',
|
||||||
|
40: 'ArrowDown',
|
||||||
|
76: 'KeyL',
|
||||||
|
77: 'KeyM'
|
||||||
|
}
|
||||||
|
|
||||||
export default ({ app }, inject) => {
|
export default ({ app }, inject) => {
|
||||||
inject('constants', Constants)
|
inject('constants', Constants)
|
||||||
|
inject('keynames', KeyNames)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { formatDistance, format } from 'date-fns'
|
import { formatDistance, format } from 'date-fns'
|
||||||
|
|
||||||
|
Vue.prototype.$eventBus = new Vue()
|
||||||
|
|
||||||
Vue.prototype.$isDev = process.env.NODE_ENV !== 'production'
|
Vue.prototype.$isDev = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
Vue.prototype.$dateDistanceFromNow = (unixms) => {
|
Vue.prototype.$dateDistanceFromNow = (unixms) => {
|
||||||
@@ -127,6 +129,19 @@ Vue.prototype.$sanitizeFilename = (input, replacement = '') => {
|
|||||||
return sanitized
|
return sanitized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function xmlToJson(xml) {
|
||||||
|
const json = {};
|
||||||
|
for (const res of xml.matchAll(/(?:<(\w*)(?:\s[^>]*)*>)((?:(?!<\1).)*)(?:<\/\1>)|<(\w*)(?:\s*)*\/>/gm)) {
|
||||||
|
const key = res[1] || res[3];
|
||||||
|
const value = res[2] && xmlToJson(res[2]);
|
||||||
|
json[key] = ((value && Object.keys(value).length) ? value : res[2]) || null;
|
||||||
|
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
Vue.prototype.$xmlToJson = xmlToJson
|
||||||
|
|
||||||
const encode = (text) => encodeURIComponent(Buffer.from(text).toString('base64'))
|
const encode = (text) => encodeURIComponent(Buffer.from(text).toString('base64'))
|
||||||
Vue.prototype.$encode = encode
|
Vue.prototype.$encode = encode
|
||||||
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
|
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -14,7 +14,8 @@ export const state = () => ({
|
|||||||
keywordFilter: null,
|
keywordFilter: null,
|
||||||
selectedSeries: null,
|
selectedSeries: null,
|
||||||
libraryPage: null,
|
libraryPage: null,
|
||||||
searchResults: []
|
searchResults: {},
|
||||||
|
searchResultAudiobooks: []
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
@@ -25,7 +26,7 @@ export const getters = {
|
|||||||
if (!state.libraryPage) {
|
if (!state.libraryPage) {
|
||||||
return getters.getFiltered()
|
return getters.getFiltered()
|
||||||
} else if (state.libraryPage === 'search') {
|
} else if (state.libraryPage === 'search') {
|
||||||
return state.searchResults
|
return state.searchResultAudiobooks
|
||||||
} else if (state.libraryPage === 'series') {
|
} else if (state.libraryPage === 'series') {
|
||||||
var series = getters.getSeriesGroups()
|
var series = getters.getSeriesGroups()
|
||||||
if (state.selectedSeries) {
|
if (state.selectedSeries) {
|
||||||
@@ -53,7 +54,7 @@ export const getters = {
|
|||||||
if (filter === 'No Series') filtered = filtered.filter(ab => ab.book && !ab.book.series)
|
if (filter === 'No Series') filtered = filtered.filter(ab => ab.book && !ab.book.series)
|
||||||
else filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
else filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
||||||
}
|
}
|
||||||
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.author === filter)
|
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.authorFL === filter)
|
||||||
else if (group === 'narrators') filtered = filtered.filter(ab => ab.book && ab.book.narrator === filter)
|
else if (group === 'narrators') filtered = filtered.filter(ab => ab.book && ab.book.narrator === filter)
|
||||||
else if (group === 'progress') {
|
else if (group === 'progress') {
|
||||||
filtered = filtered.filter(ab => {
|
filtered = filtered.filter(ab => {
|
||||||
@@ -121,7 +122,7 @@ export const getters = {
|
|||||||
return seriesArray
|
return seriesArray
|
||||||
},
|
},
|
||||||
getUniqueAuthors: (state) => {
|
getUniqueAuthors: (state) => {
|
||||||
var _authors = state.audiobooks.filter(ab => !!(ab.book && ab.book.author)).map(ab => ab.book.author)
|
var _authors = state.audiobooks.filter(ab => !!(ab.book && ab.book.authorFL)).map(ab => ab.book.authorFL)
|
||||||
return [...new Set(_authors)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
return [...new Set(_authors)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
||||||
},
|
},
|
||||||
getUniqueNarrators: (state) => {
|
getUniqueNarrators: (state) => {
|
||||||
@@ -222,6 +223,7 @@ export const mutations = {
|
|||||||
},
|
},
|
||||||
setSearchResults(state, val) {
|
setSearchResults(state, val) {
|
||||||
state.searchResults = val
|
state.searchResults = val
|
||||||
|
state.searchResultAudiobooks = val && val.audiobooks ? val.audiobooks.map(ab => ab.audiobook) : []
|
||||||
},
|
},
|
||||||
set(state, audiobooks) {
|
set(state, audiobooks) {
|
||||||
// GENRES
|
// GENRES
|
||||||
|
|||||||
@@ -18,14 +18,18 @@ export const state = () => ({
|
|||||||
routeHistory: [],
|
routeHistory: [],
|
||||||
showExperimentalFeatures: false,
|
showExperimentalFeatures: false,
|
||||||
backups: [],
|
backups: [],
|
||||||
bookshelfBookIds: []
|
bookshelfBookIds: [],
|
||||||
|
openModal: null
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
getIsAudiobookSelected: state => audiobookId => {
|
getIsAudiobookSelected: state => audiobookId => {
|
||||||
return !!state.selectedAudiobooks.includes(audiobookId)
|
return !!state.selectedAudiobooks.includes(audiobookId)
|
||||||
},
|
},
|
||||||
getNumAudiobooksSelected: state => state.selectedAudiobooks.length
|
getNumAudiobooksSelected: state => state.selectedAudiobooks.length,
|
||||||
|
getAudiobookIdStreaming: state => {
|
||||||
|
return state.streamAudiobook ? state.streamAudiobook.id : null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
@@ -155,5 +159,8 @@ export const mutations = {
|
|||||||
},
|
},
|
||||||
setBackups(state, val) {
|
setBackups(state, val) {
|
||||||
state.backups = val.sort((a, b) => b.createdAt - a.createdAt)
|
state.backups = val.sort((a, b) => b.createdAt - a.createdAt)
|
||||||
|
},
|
||||||
|
setOpenModal(state, val) {
|
||||||
|
state.openModal = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ export const state = () => ({
|
|||||||
lastLoad: 0,
|
lastLoad: 0,
|
||||||
listeners: [],
|
listeners: [],
|
||||||
currentLibraryId: 'main',
|
currentLibraryId: 'main',
|
||||||
showModal: false,
|
|
||||||
folders: [],
|
folders: [],
|
||||||
folderLastUpdate: 0
|
folderLastUpdate: 0
|
||||||
})
|
})
|
||||||
@@ -42,12 +41,18 @@ export const actions = {
|
|||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetch({ state, commit, rootState }, libraryId) {
|
fetch({ state, commit, rootState, rootGetters }, libraryId) {
|
||||||
if (!rootState.user || !rootState.user.user) {
|
if (!rootState.user || !rootState.user.user) {
|
||||||
console.error('libraries/fetch - User not set')
|
console.error('libraries/fetch - User not set')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var canUserAccessLibrary = rootGetters['user/getCanAccessLibrary'](libraryId)
|
||||||
|
if (!canUserAccessLibrary) {
|
||||||
|
console.warn('Access not allowed to library')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var library = state.libraries.find(lib => lib.id === libraryId)
|
var library = state.libraries.find(lib => lib.id === libraryId)
|
||||||
if (library) {
|
if (library) {
|
||||||
commit('setCurrentLibrary', libraryId)
|
commit('setCurrentLibrary', libraryId)
|
||||||
@@ -102,9 +107,6 @@ export const mutations = {
|
|||||||
setFoldersLastUpdate(state) {
|
setFoldersLastUpdate(state) {
|
||||||
state.folderLastUpdate = Date.now()
|
state.folderLastUpdate = Date.now()
|
||||||
},
|
},
|
||||||
setShowModal(state, val) {
|
|
||||||
state.showModal = val
|
|
||||||
},
|
|
||||||
setLastLoad(state) {
|
setLastLoad(state) {
|
||||||
state.lastLoad = Date.now()
|
state.lastLoad = Date.now()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -33,6 +33,19 @@ export const getters = {
|
|||||||
},
|
},
|
||||||
getUserCanUpload: (state) => {
|
getUserCanUpload: (state) => {
|
||||||
return state.user && state.user.permissions ? !!state.user.permissions.upload : false
|
return state.user && state.user.permissions ? !!state.user.permissions.upload : false
|
||||||
|
},
|
||||||
|
getUserCanAccessAllLibraries: (state) => {
|
||||||
|
return state.user && state.user.permissions ? !!state.user.permissions.accessAllLibraries : false
|
||||||
|
},
|
||||||
|
getLibrariesAccessible: (state, getters) => {
|
||||||
|
if (!state.user) return []
|
||||||
|
if (getters.getUserCanAccessAllLibraries) return []
|
||||||
|
return state.user.librariesAccessible || []
|
||||||
|
},
|
||||||
|
getCanAccessLibrary: (state, getters) => (libraryId) => {
|
||||||
|
if (!state.user) return false
|
||||||
|
if (getters.getUserCanAccessAllLibraries) return true
|
||||||
|
return getters.getLibrariesAccessible.includes(libraryId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +73,7 @@ export const actions = {
|
|||||||
export const mutations = {
|
export const mutations = {
|
||||||
setUser(state, user) {
|
setUser(state, user) {
|
||||||
state.user = user
|
state.user = user
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
if (user.token) localStorage.setItem('token', user.token)
|
if (user.token) localStorage.setItem('token', user.token)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ export const state = () => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
|
getIsUserOnline: state => id => {
|
||||||
|
return state.users.find(u => u.id === id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
@@ -12,6 +14,9 @@ export const actions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
|
resetUsers(state) {
|
||||||
|
state.users = []
|
||||||
|
},
|
||||||
updateUser(state, user) {
|
updateUser(state, user) {
|
||||||
var index = state.users.findIndex(u => u.id === user.id)
|
var index = state.users.findIndex(u => u.id === user.id)
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
|||||||
Generated
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf",
|
"name": "audiobookshelf",
|
||||||
"version": "1.4.3",
|
"version": "1.4.13",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1222,9 +1222,9 @@
|
|||||||
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
|
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
|
||||||
},
|
},
|
||||||
"njodb": {
|
"njodb": {
|
||||||
"version": "0.4.20",
|
"version": "0.4.21",
|
||||||
"resolved": "https://registry.npmjs.org/njodb/-/njodb-0.4.20.tgz",
|
"resolved": "https://registry.npmjs.org/njodb/-/njodb-0.4.21.tgz",
|
||||||
"integrity": "sha512-y/V9yTSa6fXlfkD453o8engmbFvMabpogSYt53sNft48oqzO5tk4OTl564Zf2IN8JtJDp4ShnZE4hIXePqfvhg==",
|
"integrity": "sha512-3qLMzwIZUgT1yq2PCzJlT6FFK/zfLHz71QnFeE9ec4KKJH9abY4SXnmHVaWP7wVq+lY77wW1F+EeKG9gm8j6WA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"proper-lockfile": "^4.1.2"
|
"proper-lockfile": "^4.1.2"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf",
|
"name": "audiobookshelf",
|
||||||
"version": "1.4.9",
|
"version": "1.4.16",
|
||||||
"description": "Self-hosted audiobook server for managing and playing audiobooks",
|
"description": "Self-hosted audiobook server for managing and playing audiobooks",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"ip": "^1.1.5",
|
"ip": "^1.1.5",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"libgen": "^2.1.0",
|
"libgen": "^2.1.0",
|
||||||
"njodb": "^0.4.20",
|
"njodb": "^0.4.21",
|
||||||
"node-cron": "^3.0.0",
|
"node-cron": "^3.0.0",
|
||||||
"node-dir": "^0.1.17",
|
"node-dir": "^0.1.17",
|
||||||
"node-stream-zip": "^1.15.0",
|
"node-stream-zip": "^1.15.0",
|
||||||
|
|||||||
@@ -117,6 +117,39 @@ cd audiobookshelf
|
|||||||
npm run prod -- -p [PORT] --audiobooks [AUDIOBOOKS_PATH] --config [CONFIG_PATH] --metadata [METADATA_PATH]
|
npm run prod -- -p [PORT] --audiobooks [AUDIOBOOKS_PATH] --config [CONFIG_PATH] --metadata [METADATA_PATH]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### nginx Reverse Proxy
|
||||||
|
|
||||||
|
Add this to the site config file on your nginx server after you have changed the relevant parts in the <> brackets, and inserted the path to you certificates.
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
server
|
||||||
|
{
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name <sub>.<domain>.<tld>;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/audiobookshelf.access.log;
|
||||||
|
error_log /var/log/nginx/audiobookshelf.error.log;
|
||||||
|
|
||||||
|
ssl_certificate /path/to/certificate;
|
||||||
|
ssl_certificate_key /path/to/key;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
|
proxy_pass http://<URL_to_forward_to>;
|
||||||
|
proxy_redirect http:// https://;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Feel free to help out
|
Feel free to help out
|
||||||
|
|||||||
+117
-16
@@ -1,10 +1,13 @@
|
|||||||
const express = require('express')
|
const express = require('express')
|
||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
|
|
||||||
const Logger = require('./Logger')
|
const Logger = require('./Logger')
|
||||||
const User = require('./objects/User')
|
|
||||||
const { isObject } = require('./utils/index')
|
const { isObject } = require('./utils/index')
|
||||||
|
const audioFileScanner = require('./utils/audioFileScanner')
|
||||||
|
|
||||||
const Library = require('./objects/Library')
|
const Library = require('./objects/Library')
|
||||||
|
const User = require('./objects/User')
|
||||||
|
|
||||||
class ApiController {
|
class ApiController {
|
||||||
constructor(MetadataPath, db, scanner, auth, streamManager, rssFeeds, downloadManager, coverController, backupManager, watcher, emitter, clientEmitter) {
|
constructor(MetadataPath, db, scanner, auth, streamManager, rssFeeds, downloadManager, coverController, backupManager, watcher, emitter, clientEmitter) {
|
||||||
@@ -60,6 +63,7 @@ class ApiController {
|
|||||||
this.router.patch('/user/settings', this.userUpdateSettings.bind(this))
|
this.router.patch('/user/settings', this.userUpdateSettings.bind(this))
|
||||||
this.router.get('/users', this.getUsers.bind(this))
|
this.router.get('/users', this.getUsers.bind(this))
|
||||||
this.router.post('/user', this.createUser.bind(this))
|
this.router.post('/user', this.createUser.bind(this))
|
||||||
|
this.router.get('/user/:id', this.getUser.bind(this))
|
||||||
this.router.patch('/user/:id', this.updateUser.bind(this))
|
this.router.patch('/user/:id', this.updateUser.bind(this))
|
||||||
this.router.delete('/user/:id', this.deleteUser.bind(this))
|
this.router.delete('/user/:id', this.deleteUser.bind(this))
|
||||||
|
|
||||||
@@ -77,6 +81,8 @@ class ApiController {
|
|||||||
this.router.get('/download/:id', this.download.bind(this))
|
this.router.get('/download/:id', this.download.bind(this))
|
||||||
|
|
||||||
this.router.get('/filesystem', this.getFileSystemPaths.bind(this))
|
this.router.get('/filesystem', this.getFileSystemPaths.bind(this))
|
||||||
|
|
||||||
|
this.router.get('/scantracks/:id', this.scanAudioTrackNums.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
find(req, res) {
|
find(req, res) {
|
||||||
@@ -143,15 +149,18 @@ class ApiController {
|
|||||||
var bookMatches = []
|
var bookMatches = []
|
||||||
var authorMatches = {}
|
var authorMatches = {}
|
||||||
var seriesMatches = {}
|
var seriesMatches = {}
|
||||||
|
var tagMatches = {}
|
||||||
|
|
||||||
var audiobooksInLibrary = this.db.audiobooks.filter(ab => ab.libraryId === library.id)
|
var audiobooksInLibrary = this.db.audiobooks.filter(ab => ab.libraryId === library.id)
|
||||||
audiobooksInLibrary.forEach((ab) => {
|
audiobooksInLibrary.forEach((ab) => {
|
||||||
var queryResult = ab.searchQuery(req.query.q)
|
var queryResult = ab.searchQuery(req.query.q)
|
||||||
if (queryResult.book) {
|
if (queryResult.book) {
|
||||||
bookMatches.push({
|
var bookMatchObj = {
|
||||||
audiobook: ab,
|
audiobook: ab,
|
||||||
matchKey: queryResult.book
|
matchKey: queryResult.book,
|
||||||
})
|
matchText: queryResult.bookMatchText
|
||||||
|
}
|
||||||
|
bookMatches.push(bookMatchObj)
|
||||||
}
|
}
|
||||||
if (queryResult.author && !authorMatches[queryResult.author]) {
|
if (queryResult.author && !authorMatches[queryResult.author]) {
|
||||||
authorMatches[queryResult.author] = {
|
authorMatches[queryResult.author] = {
|
||||||
@@ -168,10 +177,23 @@ class ApiController {
|
|||||||
seriesMatches[queryResult.series].audiobooks.push(ab)
|
seriesMatches[queryResult.series].audiobooks.push(ab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (queryResult.tags && queryResult.tags.length) {
|
||||||
|
queryResult.tags.forEach((tag) => {
|
||||||
|
if (!tagMatches[tag]) {
|
||||||
|
tagMatches[tag] = {
|
||||||
|
tag,
|
||||||
|
audiobooks: [ab]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tagMatches[tag].audiobooks.push(ab)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
audiobooks: bookMatches.slice(0, maxResults),
|
audiobooks: bookMatches.slice(0, maxResults),
|
||||||
|
tags: Object.values(tagMatches).slice(0, maxResults),
|
||||||
authors: Object.values(authorMatches).slice(0, maxResults),
|
authors: Object.values(authorMatches).slice(0, maxResults),
|
||||||
series: Object.values(seriesMatches).slice(0, maxResults)
|
series: Object.values(seriesMatches).slice(0, maxResults)
|
||||||
})
|
})
|
||||||
@@ -293,8 +315,17 @@ class ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAudiobook(req, res) {
|
getAudiobook(req, res) {
|
||||||
|
if (!req.user) {
|
||||||
|
return res.sendStatus(403)
|
||||||
|
}
|
||||||
var audiobook = this.db.audiobooks.find(a => a.id === req.params.id)
|
var audiobook = this.db.audiobooks.find(a => a.id === req.params.id)
|
||||||
if (!audiobook) return res.sendStatus(404)
|
if (!audiobook) return res.sendStatus(404)
|
||||||
|
|
||||||
|
// Check user can access this audiobooks library
|
||||||
|
if (!req.user.checkCanAccessLibrary(audiobook.libraryId)) {
|
||||||
|
return res.sendStatus(403)
|
||||||
|
}
|
||||||
|
|
||||||
res.json(audiobook.toJSONExpanded())
|
res.json(audiobook.toJSONExpanded())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,20 +532,23 @@ class ApiController {
|
|||||||
res.sendStatus(200)
|
res.sendStatus(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
getUsers(req, res) {
|
|
||||||
if (req.user.type !== 'root') return res.sendStatus(403)
|
|
||||||
return res.json(this.db.users.map(u => u.toJSONForBrowser()))
|
|
||||||
}
|
|
||||||
|
|
||||||
async resetUserAudiobookProgress(req, res) {
|
async resetUserAudiobookProgress(req, res) {
|
||||||
req.user.resetAudiobookProgress(req.params.id)
|
var audiobook = this.db.audiobooks.find(ab => ab.id === req.params.id)
|
||||||
|
if (!audiobook) {
|
||||||
|
return res.status(404).send('Audiobook not found')
|
||||||
|
}
|
||||||
|
req.user.resetAudiobookProgress(audiobook)
|
||||||
await this.db.updateEntity('user', req.user)
|
await this.db.updateEntity('user', req.user)
|
||||||
this.clientEmitter(req.user.id, 'user_updated', req.user.toJSONForBrowser())
|
this.clientEmitter(req.user.id, 'user_updated', req.user.toJSONForBrowser())
|
||||||
res.sendStatus(200)
|
res.sendStatus(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateUserAudiobookProgress(req, res) {
|
async updateUserAudiobookProgress(req, res) {
|
||||||
var wasUpdated = req.user.updateAudiobookProgress(req.params.id, req.body)
|
var audiobook = this.db.audiobooks.find(ab => ab.id === req.params.id)
|
||||||
|
if (!audiobook) {
|
||||||
|
return res.status(404).send('Audiobook not found')
|
||||||
|
}
|
||||||
|
var wasUpdated = req.user.updateAudiobookProgress(audiobook, req.body)
|
||||||
if (wasUpdated) {
|
if (wasUpdated) {
|
||||||
await this.db.updateEntity('user', req.user)
|
await this.db.updateEntity('user', req.user)
|
||||||
this.clientEmitter(req.user.id, 'user_updated', req.user.toJSONForBrowser())
|
this.clientEmitter(req.user.id, 'user_updated', req.user.toJSONForBrowser())
|
||||||
@@ -530,8 +564,11 @@ class ApiController {
|
|||||||
|
|
||||||
var shouldUpdate = false
|
var shouldUpdate = false
|
||||||
abProgresses.forEach((progress) => {
|
abProgresses.forEach((progress) => {
|
||||||
var wasUpdated = req.user.updateAudiobookProgress(progress.audiobookId, progress)
|
var audiobook = this.db.audiobooks.find(ab => ab.id === progress.audiobookId)
|
||||||
if (wasUpdated) shouldUpdate = true
|
if (audiobook) {
|
||||||
|
var wasUpdated = req.user.updateAudiobookProgress(audiobook, progress)
|
||||||
|
if (wasUpdated) shouldUpdate = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (shouldUpdate) {
|
if (shouldUpdate) {
|
||||||
@@ -570,12 +607,43 @@ class ApiController {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userJsonWithBookProgressDetails(user) {
|
||||||
|
var json = user.toJSONForBrowser()
|
||||||
|
|
||||||
|
// User audiobook progress attach book details
|
||||||
|
if (json.audiobooks && Object.keys(json.audiobooks).length) {
|
||||||
|
for (const audiobookId in json.audiobooks) {
|
||||||
|
var audiobook = this.db.audiobooks.find(ab => ab.id === audiobookId)
|
||||||
|
if (!audiobook) {
|
||||||
|
Logger.error('[ApiController] Audiobook not found for users progress ' + audiobookId)
|
||||||
|
} else {
|
||||||
|
json.audiobooks[audiobookId].book = audiobook.book.toJSON()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return json
|
||||||
|
}
|
||||||
|
|
||||||
|
getUsers(req, res) {
|
||||||
|
if (req.user.type !== 'root') return res.sendStatus(403)
|
||||||
|
var users = this.db.users.map(u => this.userJsonWithBookProgressDetails(u))
|
||||||
|
res.json(users)
|
||||||
|
}
|
||||||
|
|
||||||
async createUser(req, res) {
|
async createUser(req, res) {
|
||||||
if (!req.user.isRoot) {
|
if (!req.user.isRoot) {
|
||||||
Logger.warn('Non-root user attempted to create user', req.user)
|
Logger.warn('Non-root user attempted to create user', req.user)
|
||||||
return res.sendStatus(403)
|
return res.sendStatus(403)
|
||||||
}
|
}
|
||||||
var account = req.body
|
var account = req.body
|
||||||
|
|
||||||
|
var username = account.username
|
||||||
|
var usernameExists = this.db.users.find(u => u.username.toLowerCase() === username.toLowerCase())
|
||||||
|
if (usernameExists) {
|
||||||
|
return res.status(500).send('Username already taken')
|
||||||
|
}
|
||||||
|
|
||||||
account.id = (Math.trunc(Math.random() * 1000) + Date.now()).toString(36)
|
account.id = (Math.trunc(Math.random() * 1000) + Date.now()).toString(36)
|
||||||
account.pash = await this.auth.hashPass(account.password)
|
account.pash = await this.auth.hashPass(account.password)
|
||||||
delete account.password
|
delete account.password
|
||||||
@@ -589,12 +657,24 @@ class ApiController {
|
|||||||
user: newUser.toJSONForBrowser()
|
user: newUser.toJSONForBrowser()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
res.json({
|
return res.status(500).send('Failed to save new user')
|
||||||
error: 'Failed to save new user'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getUser(req, res) {
|
||||||
|
if (!req.user.isRoot) {
|
||||||
|
Logger.error('User other than root attempting to get user', req.user)
|
||||||
|
return res.sendStatus(403)
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = this.db.users.find(u => u.id === req.params.id)
|
||||||
|
if (!user) {
|
||||||
|
return res.sendStatus(404)
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json(this.userJsonWithBookProgressDetails(user))
|
||||||
|
}
|
||||||
|
|
||||||
async updateUser(req, res) {
|
async updateUser(req, res) {
|
||||||
if (!req.user.isRoot) {
|
if (!req.user.isRoot) {
|
||||||
Logger.error('User other than root attempting to update user', req.user)
|
Logger.error('User other than root attempting to update user', req.user)
|
||||||
@@ -607,6 +687,14 @@ class ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var account = req.body
|
var account = req.body
|
||||||
|
|
||||||
|
if (account.username !== undefined && account.username !== user.username) {
|
||||||
|
var usernameExists = this.db.users.find(u => u.username.toLowerCase() === account.username.toLowerCase())
|
||||||
|
if (usernameExists) {
|
||||||
|
return res.status(500).send('Username already taken')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Updating password
|
// Updating password
|
||||||
if (account.password) {
|
if (account.password) {
|
||||||
account.pash = await this.auth.hashPass(account.password)
|
account.pash = await this.auth.hashPass(account.password)
|
||||||
@@ -783,5 +871,18 @@ class ApiController {
|
|||||||
var dirs = await this.getDirectories(global.appRoot, '/', excludedDirs)
|
var dirs = await this.getDirectories(global.appRoot, '/', excludedDirs)
|
||||||
res.json(dirs)
|
res.json(dirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async scanAudioTrackNums(req, res) {
|
||||||
|
if (!req.user || !req.user.isRoot) {
|
||||||
|
return res.sendStatus(403)
|
||||||
|
}
|
||||||
|
var audiobook = this.db.audiobooks.find(ab => ab.id === req.params.id)
|
||||||
|
if (!audiobook) {
|
||||||
|
return res.status(404).send('Audiobook not found')
|
||||||
|
}
|
||||||
|
|
||||||
|
var scandata = await audioFileScanner.scanTrackNumbers(audiobook)
|
||||||
|
res.json(scandata)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
module.exports = ApiController
|
module.exports = ApiController
|
||||||
+2
-2
@@ -97,11 +97,11 @@ class Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async login(req, res) {
|
async login(req, res) {
|
||||||
var username = req.body.username
|
var username = (req.body.username || '').toLowerCase()
|
||||||
var password = req.body.password || ''
|
var password = req.body.password || ''
|
||||||
Logger.debug('Check Auth', username, !!password)
|
Logger.debug('Check Auth', username, !!password)
|
||||||
|
|
||||||
var user = this.users.find(u => u.username === username)
|
var user = this.users.find(u => u.username.toLowerCase() === username)
|
||||||
|
|
||||||
if (!user || !user.isActive) {
|
if (!user || !user.isActive) {
|
||||||
Logger.debug(`[Auth] Failed login attempt ${req.rateLimit.current} of ${req.rateLimit.limit}`)
|
Logger.debug(`[Auth] Failed login attempt ${req.rateLimit.current} of ${req.rateLimit.limit}`)
|
||||||
|
|||||||
+5
-34
@@ -82,10 +82,14 @@ class Db {
|
|||||||
await this.load()
|
await this.load()
|
||||||
|
|
||||||
// Insert Defaults
|
// Insert Defaults
|
||||||
if (!this.users.find(u => u.type === 'root')) {
|
var rootUser = this.users.find(u => u.type === 'root')
|
||||||
|
if (!rootUser) {
|
||||||
var token = await jwt.sign({ userId: 'root' }, process.env.TOKEN_SECRET)
|
var token = await jwt.sign({ userId: 'root' }, process.env.TOKEN_SECRET)
|
||||||
Logger.debug('Generated default token', token)
|
Logger.debug('Generated default token', token)
|
||||||
|
Logger.info('[Db] Root user created')
|
||||||
await this.insertEntity('user', this.getDefaultUser(token))
|
await this.insertEntity('user', this.getDefaultUser(token))
|
||||||
|
} else {
|
||||||
|
Logger.info(`[Db] Root user exists, pw: ${rootUser.hasPw}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.libraries.length) {
|
if (!this.libraries.length) {
|
||||||
@@ -123,19 +127,6 @@ class Db {
|
|||||||
await Promise.all([p1, p2, p3, p4])
|
await Promise.all([p1, p2, p3, p4])
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertAudiobook(audiobook) {
|
|
||||||
// return this.insertAudiobooks([audiobook])
|
|
||||||
// }
|
|
||||||
|
|
||||||
// insertAudiobooks(audiobooks) {
|
|
||||||
// return this.audiobooksDb.insert(audiobooks).then((results) => {
|
|
||||||
// Logger.debug(`[DB] Inserted ${results.inserted} audiobooks`)
|
|
||||||
// this.audiobooks = this.audiobooks.concat(audiobooks)
|
|
||||||
// }).catch((error) => {
|
|
||||||
// Logger.error(`[DB] Insert audiobooks Failed ${error}`)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
updateAudiobook(audiobook) {
|
updateAudiobook(audiobook) {
|
||||||
return this.audiobooksDb.update((record) => record.id === audiobook.id, () => audiobook).then((results) => {
|
return this.audiobooksDb.update((record) => record.id === audiobook.id, () => audiobook).then((results) => {
|
||||||
Logger.debug(`[DB] Audiobook updated ${results.updated}`)
|
Logger.debug(`[DB] Audiobook updated ${results.updated}`)
|
||||||
@@ -146,26 +137,6 @@ class Db {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertUser(user) {
|
|
||||||
// return this.usersDb.insert([user]).then((results) => {
|
|
||||||
// Logger.debug(`[DB] Inserted user ${results.inserted}`)
|
|
||||||
// this.users.push(user)
|
|
||||||
// return true
|
|
||||||
// }).catch((error) => {
|
|
||||||
// Logger.error(`[DB] Insert user Failed ${error}`)
|
|
||||||
// return false
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
// insertSettings(settings) {
|
|
||||||
// return this.settingsDb.insert([settings]).then((results) => {
|
|
||||||
// Logger.debug(`[DB] Inserted ${results.inserted} settings`)
|
|
||||||
// this.settings = this.settings.concat(settings)
|
|
||||||
// }).catch((error) => {
|
|
||||||
// Logger.error(`[DB] Insert settings Failed ${error}`)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
updateUserStream(userId, streamId) {
|
updateUserStream(userId, streamId) {
|
||||||
return this.usersDb.update((record) => record.id === userId, (user) => {
|
return this.usersDb.update((record) => record.id === userId, (user) => {
|
||||||
user.stream = streamId
|
user.stream = streamId
|
||||||
|
|||||||
+9
-94
@@ -109,7 +109,7 @@ class Scanner {
|
|||||||
titleDistance: 2,
|
titleDistance: 2,
|
||||||
authorDistance: 2
|
authorDistance: 2
|
||||||
}
|
}
|
||||||
var results = await this.bookFinder.findCovers('openlibrary', audiobook.title, audiobook.author, options)
|
var results = await this.bookFinder.findCovers('openlibrary', audiobook.title, audiobook.authorFL, options)
|
||||||
if (results.length) {
|
if (results.length) {
|
||||||
Logger.debug(`[Scanner] Found best cover for "${audiobook.title}"`)
|
Logger.debug(`[Scanner] Found best cover for "${audiobook.title}"`)
|
||||||
|
|
||||||
@@ -199,6 +199,14 @@ class Scanner {
|
|||||||
if (forceAudioFileScan) {
|
if (forceAudioFileScan) {
|
||||||
Logger.info(`[Scanner] Rescanning ${existingAudiobook.audioFiles.length} audio files for "${existingAudiobook.title}"`)
|
Logger.info(`[Scanner] Rescanning ${existingAudiobook.audioFiles.length} audio files for "${existingAudiobook.title}"`)
|
||||||
var numAudioFilesUpdated = await audioFileScanner.rescanAudioFiles(existingAudiobook)
|
var numAudioFilesUpdated = await audioFileScanner.rescanAudioFiles(existingAudiobook)
|
||||||
|
|
||||||
|
// Set book details from metadata pulled from audio files
|
||||||
|
var bookMetadataUpdated = existingAudiobook.setDetailsFromFileMetadata()
|
||||||
|
if (bookMetadataUpdated) {
|
||||||
|
Logger.debug(`[Scanner] Book Metadata Updated for "${existingAudiobook.title}"`)
|
||||||
|
hasUpdatedAudioFiles = true
|
||||||
|
}
|
||||||
|
|
||||||
if (numAudioFilesUpdated > 0) {
|
if (numAudioFilesUpdated > 0) {
|
||||||
Logger.info(`[Scanner] Rescan complete, ${numAudioFilesUpdated} audio files were updated for "${existingAudiobook.title}"`)
|
Logger.info(`[Scanner] Rescan complete, ${numAudioFilesUpdated} audio files were updated for "${existingAudiobook.title}"`)
|
||||||
hasUpdatedAudioFiles = true
|
hasUpdatedAudioFiles = true
|
||||||
@@ -580,49 +588,6 @@ class Scanner {
|
|||||||
return this.scanAudiobookData(audiobookData, forceAudioFileScan)
|
return this.scanAudiobookData(audiobookData, forceAudioFileScan)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Files were modified in this directory, check it out
|
|
||||||
// async checkDir(dir) {
|
|
||||||
// var exists = await fs.pathExists(dir)
|
|
||||||
// if (!exists) {
|
|
||||||
// // Audiobook was deleted, TODO: Should confirm this better
|
|
||||||
// var audiobook = this.db.audiobooks.find(ab => ab.fullPath === dir)
|
|
||||||
// if (audiobook) {
|
|
||||||
// var audiobookJSON = audiobook.toJSONMinified()
|
|
||||||
// await this.db.removeEntity('audiobook', audiobook.id)
|
|
||||||
// this.emitter('audiobook_removed', audiobookJSON)
|
|
||||||
// return ScanResult.REMOVED
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Path inside audiobook was deleted, scan audiobook
|
|
||||||
// audiobook = this.db.audiobooks.find(ab => dir.startsWith(ab.fullPath))
|
|
||||||
// if (audiobook) {
|
|
||||||
// Logger.info(`[Scanner] Path inside audiobook "${audiobook.title}" was deleted: ${dir}`)
|
|
||||||
// return this.scanAudiobook(audiobook.fullPath)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Logger.warn('[Scanner] Path was deleted but no audiobook found', dir)
|
|
||||||
// return ScanResult.NOTHING
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Check if this is a subdirectory of an audiobook
|
|
||||||
// var audiobook = this.db.audiobooks.find((ab) => dir.startsWith(ab.fullPath))
|
|
||||||
// if (audiobook) {
|
|
||||||
// Logger.debug(`[Scanner] Check Dir audiobook "${audiobook.title}" found: ${dir}`)
|
|
||||||
// return this.scanAudiobook(audiobook.fullPath)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Check if an audiobook is a subdirectory of this dir
|
|
||||||
// audiobook = this.db.audiobooks.find(ab => ab.fullPath.startsWith(dir))
|
|
||||||
// if (audiobook) {
|
|
||||||
// Logger.warn(`[Scanner] Files were added/updated in a root directory of an existing audiobook, ignore files: ${dir}`)
|
|
||||||
// return ScanResult.NOTHING
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Must be a new audiobook
|
|
||||||
// Logger.debug(`[Scanner] Check Dir must be a new audiobook: ${dir}`)
|
|
||||||
// return this.scanAudiobook(dir)
|
|
||||||
// }
|
|
||||||
|
|
||||||
async scanFolderUpdates(libraryId, folderId, fileUpdateBookGroup) {
|
async scanFolderUpdates(libraryId, folderId, fileUpdateBookGroup) {
|
||||||
var library = this.db.libraries.find(lib => lib.id === libraryId)
|
var library = this.db.libraries.find(lib => lib.id === libraryId)
|
||||||
if (!library) {
|
if (!library) {
|
||||||
@@ -730,56 +695,6 @@ class Scanner {
|
|||||||
return libraryScanResults
|
return libraryScanResults
|
||||||
}
|
}
|
||||||
|
|
||||||
// async scanCovers() {
|
|
||||||
// var audiobooksNeedingCover = this.audiobooks.filter(ab => !ab.cover && ab.author)
|
|
||||||
// var found = 0
|
|
||||||
// var notFound = 0
|
|
||||||
// var failed = 0
|
|
||||||
|
|
||||||
// for (let i = 0; i < audiobooksNeedingCover.length; i++) {
|
|
||||||
// var audiobook = audiobooksNeedingCover[i]
|
|
||||||
// var options = {
|
|
||||||
// titleDistance: 2,
|
|
||||||
// authorDistance: 2
|
|
||||||
// }
|
|
||||||
// var results = await this.bookFinder.findCovers('openlibrary', audiobook.title, audiobook.author, options)
|
|
||||||
// if (results.length) {
|
|
||||||
// Logger.debug(`[Scanner] Found best cover for "${audiobook.title}"`)
|
|
||||||
// var coverUrl = results[0]
|
|
||||||
// var result = await this.coverController.downloadCoverFromUrl(audiobook, coverUrl)
|
|
||||||
// if (result.error) {
|
|
||||||
// failed++
|
|
||||||
// } else {
|
|
||||||
// found++
|
|
||||||
// await this.db.updateAudiobook(audiobook)
|
|
||||||
// this.emitter('audiobook_updated', audiobook.toJSONMinified())
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// notFound++
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var progress = Math.round(100 * (i + 1) / audiobooksNeedingCover.length)
|
|
||||||
// this.emitter('scan_progress', {
|
|
||||||
// scanType: 'covers',
|
|
||||||
// progress: {
|
|
||||||
// total: audiobooksNeedingCover.length,
|
|
||||||
// done: i + 1,
|
|
||||||
// progress
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// if (this.cancelScan) {
|
|
||||||
// this.cancelScan = false
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return {
|
|
||||||
// found,
|
|
||||||
// notFound,
|
|
||||||
// failed
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
async saveMetadata(audiobookId) {
|
async saveMetadata(audiobookId) {
|
||||||
if (audiobookId) {
|
if (audiobookId) {
|
||||||
var audiobook = this.db.audiobooks.find(ab => ab.id === audiobookId)
|
var audiobook = this.db.audiobooks.find(ab => ab.id === audiobookId)
|
||||||
|
|||||||
+44
-13
@@ -46,7 +46,7 @@ class Server {
|
|||||||
this.watcher = new Watcher(this.AudiobookPath)
|
this.watcher = new Watcher(this.AudiobookPath)
|
||||||
this.coverController = new CoverController(this.db, this.MetadataPath, this.AudiobookPath)
|
this.coverController = new CoverController(this.db, this.MetadataPath, this.AudiobookPath)
|
||||||
this.scanner = new Scanner(this.AudiobookPath, this.MetadataPath, this.db, this.coverController, this.emitter.bind(this))
|
this.scanner = new Scanner(this.AudiobookPath, this.MetadataPath, this.db, this.coverController, this.emitter.bind(this))
|
||||||
this.streamManager = new StreamManager(this.db, this.MetadataPath)
|
this.streamManager = new StreamManager(this.db, this.MetadataPath, this.emitter.bind(this))
|
||||||
this.rssFeeds = new RssFeeds(this.Port, this.db)
|
this.rssFeeds = new RssFeeds(this.Port, this.db)
|
||||||
this.downloadManager = new DownloadManager(this.db, this.MetadataPath, this.AudiobookPath, this.emitter.bind(this))
|
this.downloadManager = new DownloadManager(this.db, this.MetadataPath, this.AudiobookPath, this.emitter.bind(this))
|
||||||
this.apiController = new ApiController(this.MetadataPath, this.db, this.scanner, this.auth, this.streamManager, this.rssFeeds, this.downloadManager, this.coverController, this.backupManager, this.watcher, this.emitter.bind(this), this.clientEmitter.bind(this))
|
this.apiController = new ApiController(this.MetadataPath, this.db, this.scanner, this.auth, this.streamManager, this.rssFeeds, this.downloadManager, this.coverController, this.backupManager, this.watcher, this.emitter.bind(this), this.clientEmitter.bind(this))
|
||||||
@@ -57,8 +57,6 @@ class Server {
|
|||||||
this.io = null
|
this.io = null
|
||||||
|
|
||||||
this.clients = {}
|
this.clients = {}
|
||||||
|
|
||||||
this.isScanningCovers = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get audiobooks() {
|
get audiobooks() {
|
||||||
@@ -70,6 +68,11 @@ class Server {
|
|||||||
get serverSettings() {
|
get serverSettings() {
|
||||||
return this.db.serverSettings
|
return this.db.serverSettings
|
||||||
}
|
}
|
||||||
|
get usersOnline() {
|
||||||
|
return Object.values(this.clients).filter(c => c.user).map(client => {
|
||||||
|
return client.user.toJSONForPublic(this.streamManager.streams)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
getClientsForUser(userId) {
|
getClientsForUser(userId) {
|
||||||
return Object.values(this.clients).filter(c => c.user && c.user.id === userId)
|
return Object.values(this.clients).filter(c => c.user && c.user.id === userId)
|
||||||
@@ -83,6 +86,7 @@ class Server {
|
|||||||
clientEmitter(userId, ev, data) {
|
clientEmitter(userId, ev, data) {
|
||||||
var clients = this.getClientsForUser(userId)
|
var clients = this.getClientsForUser(userId)
|
||||||
if (!clients.length) {
|
if (!clients.length) {
|
||||||
|
console.log('clients', clients)
|
||||||
return Logger.error(`[Server] clientEmitter - no clients found for user ${userId}`)
|
return Logger.error(`[Server] clientEmitter - no clients found for user ${userId}`)
|
||||||
}
|
}
|
||||||
clients.forEach((client) => {
|
clients.forEach((client) => {
|
||||||
@@ -193,7 +197,7 @@ class Server {
|
|||||||
var loginRateLimiter = this.getLoginRateLimiter()
|
var loginRateLimiter = this.getLoginRateLimiter()
|
||||||
app.post('/login', loginRateLimiter, (req, res) => this.auth.login(req, res))
|
app.post('/login', loginRateLimiter, (req, res) => this.auth.login(req, res))
|
||||||
|
|
||||||
app.post('/logout', this.logout.bind(this))
|
app.post('/logout', this.authMiddleware.bind(this), this.logout.bind(this))
|
||||||
|
|
||||||
app.get('/ping', (req, res) => {
|
app.get('/ping', (req, res) => {
|
||||||
Logger.info('Recieved ping')
|
Logger.info('Recieved ping')
|
||||||
@@ -203,10 +207,6 @@ class Server {
|
|||||||
// Used in development to set-up streams without authentication
|
// Used in development to set-up streams without authentication
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
app.use('/test-hls', this.hlsController.router)
|
app.use('/test-hls', this.hlsController.router)
|
||||||
app.get('/test-stream/:id', async (req, res) => {
|
|
||||||
var uri = await this.streamManager.openTestStream(this.MetadataPath, req.params.id)
|
|
||||||
res.send(uri)
|
|
||||||
})
|
|
||||||
app.get('/catalog.json', (req, res) => {
|
app.get('/catalog.json', (req, res) => {
|
||||||
Logger.error('Catalog request made', req.headers)
|
Logger.error('Catalog request made', req.headers)
|
||||||
res.json()
|
res.json()
|
||||||
@@ -269,15 +269,16 @@ class Server {
|
|||||||
|
|
||||||
var _client = this.clients[socket.id]
|
var _client = this.clients[socket.id]
|
||||||
if (!_client) {
|
if (!_client) {
|
||||||
Logger.warn('[SOCKET] Socket disconnect, no client ' + socket.id)
|
Logger.warn('[Server] Socket disconnect, no client ' + socket.id)
|
||||||
} else if (!_client.user) {
|
} else if (!_client.user) {
|
||||||
Logger.info('[SOCKET] Unauth socket disconnected ' + socket.id)
|
Logger.info('[Server] Unauth socket disconnected ' + socket.id)
|
||||||
delete this.clients[socket.id]
|
delete this.clients[socket.id]
|
||||||
} else {
|
} else {
|
||||||
socket.broadcast.emit('user_offline', _client.user.toJSONForPublic(this.streamManager.streams))
|
Logger.debug('[Server] User Offline ' + _client.user.username)
|
||||||
|
this.io.emit('user_offline', _client.user.toJSONForPublic(this.streamManager.streams))
|
||||||
|
|
||||||
const disconnectTime = Date.now() - _client.connected_at
|
const disconnectTime = Date.now() - _client.connected_at
|
||||||
Logger.info(`[SOCKET] Socket ${socket.id} disconnected from client "${_client.user.username}" after ${disconnectTime}ms`)
|
Logger.info(`[Server] Socket ${socket.id} disconnected from client "${_client.user.username}" after ${disconnectTime}ms`)
|
||||||
delete this.clients[socket.id]
|
delete this.clients[socket.id]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -426,6 +427,27 @@ class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logout(req, res) {
|
logout(req, res) {
|
||||||
|
var { socketId } = req.body
|
||||||
|
Logger.info(`[Server] User ${req.user ? req.user.username : 'Unknown'} is logging out with socket ${socketId}`)
|
||||||
|
|
||||||
|
// Strip user and client from client and client socket
|
||||||
|
if (socketId && this.clients[socketId]) {
|
||||||
|
var client = this.clients[socketId]
|
||||||
|
var clientSocket = client.socket
|
||||||
|
Logger.debug(`[Server] Found user client ${clientSocket.id}, Has user: ${!!client.user}, Socket has client: ${!!clientSocket.sheepClient}`)
|
||||||
|
|
||||||
|
if (client.user) {
|
||||||
|
Logger.debug('[Server] User Offline ' + client.user.username)
|
||||||
|
this.io.emit('user_offline', client.user.toJSONForPublic(null))
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this.clients[socketId].user
|
||||||
|
delete this.clients[socketId].stream
|
||||||
|
if (clientSocket && clientSocket.sheepClient) delete this.clients[socketId].socket.sheepClient
|
||||||
|
} else if (socketId) {
|
||||||
|
Logger.warn(`[Server] No client for socket ${socketId}`)
|
||||||
|
}
|
||||||
|
|
||||||
res.sendStatus(200)
|
res.sendStatus(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +466,11 @@ class Server {
|
|||||||
return socket.emit('invalid_token')
|
return socket.emit('invalid_token')
|
||||||
}
|
}
|
||||||
var client = this.clients[socket.id]
|
var client = this.clients[socket.id]
|
||||||
|
|
||||||
|
if (client.user !== undefined) {
|
||||||
|
Logger.debug(`[Server] Authenticating socket client already has user`, client.user)
|
||||||
|
}
|
||||||
|
|
||||||
client.user = user
|
client.user = user
|
||||||
|
|
||||||
if (!client.user.toJSONForBrowser) {
|
if (!client.user.toJSONForBrowser) {
|
||||||
@@ -462,7 +489,8 @@ class Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.broadcast.emit('user_online', client.user.toJSONForPublic(this.streamManager.streams))
|
Logger.debug(`[Server] User Online ${client.user.username}`)
|
||||||
|
this.io.emit('user_online', client.user.toJSONForPublic(this.streamManager.streams))
|
||||||
|
|
||||||
user.lastSeen = Date.now()
|
user.lastSeen = Date.now()
|
||||||
await this.db.updateEntity('user', user)
|
await this.db.updateEntity('user', user)
|
||||||
@@ -477,6 +505,9 @@ class Server {
|
|||||||
librariesScanning: this.scanner.librariesScanning,
|
librariesScanning: this.scanner.librariesScanning,
|
||||||
backups: (this.backupManager.backups || []).map(b => b.toJSON())
|
backups: (this.backupManager.backups || []).map(b => b.toJSON())
|
||||||
}
|
}
|
||||||
|
if (user.type === 'root') {
|
||||||
|
initialPayload.usersOnline = this.usersOnline
|
||||||
|
}
|
||||||
client.socket.emit('init', initialPayload)
|
client.socket.emit('init', initialPayload)
|
||||||
|
|
||||||
// Setup log listener for root user
|
// Setup log listener for root user
|
||||||
|
|||||||
+5
-20
@@ -5,9 +5,11 @@ const fs = require('fs-extra')
|
|||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
|
|
||||||
class StreamManager {
|
class StreamManager {
|
||||||
constructor(db, MetadataPath) {
|
constructor(db, MetadataPath, emitter) {
|
||||||
this.db = db
|
this.db = db
|
||||||
|
|
||||||
|
this.emitter = emitter
|
||||||
|
|
||||||
this.MetadataPath = MetadataPath
|
this.MetadataPath = MetadataPath
|
||||||
this.streams = []
|
this.streams = []
|
||||||
this.StreamsPath = Path.join(this.MetadataPath, 'streams')
|
this.StreamsPath = Path.join(this.MetadataPath, 'streams')
|
||||||
@@ -112,7 +114,7 @@ class StreamManager {
|
|||||||
var stream = await this.openStream(client, audiobook)
|
var stream = await this.openStream(client, audiobook)
|
||||||
this.db.updateUserStream(client.user.id, stream.id)
|
this.db.updateUserStream(client.user.id, stream.id)
|
||||||
|
|
||||||
socket.broadcast.emit('user_stream_update', client.user.toJSONForPublic(this.streams))
|
this.emitter('user_stream_update', client.user.toJSONForPublic(this.streams))
|
||||||
}
|
}
|
||||||
|
|
||||||
async closeStreamRequest(socket) {
|
async closeStreamRequest(socket) {
|
||||||
@@ -129,24 +131,7 @@ class StreamManager {
|
|||||||
client.stream = null
|
client.stream = null
|
||||||
this.db.updateUserStream(client.user.id, null)
|
this.db.updateUserStream(client.user.id, null)
|
||||||
|
|
||||||
socket.broadcast.emit('user_stream_update', client.user.toJSONForPublic(this.streams))
|
this.emitter('user_stream_update', client.user.toJSONForPublic(this.streams))
|
||||||
}
|
|
||||||
|
|
||||||
async openTestStream(StreamsPath, audiobookId) {
|
|
||||||
Logger.info('Open Stream Test Request', audiobookId)
|
|
||||||
// var audiobook = this.audiobooks.find(ab => ab.id === audiobookId)
|
|
||||||
// var stream = new StreamTest(StreamsPath, audiobook)
|
|
||||||
|
|
||||||
// stream.on('closed', () => {
|
|
||||||
// console.log('Stream closed')
|
|
||||||
// })
|
|
||||||
|
|
||||||
// var playlistUri = await stream.generatePlaylist()
|
|
||||||
// stream.start()
|
|
||||||
|
|
||||||
// Logger.info('Stream Playlist', playlistUri)
|
|
||||||
// Logger.info('Test Stream Opened for audiobook', audiobook.title, 'with streamId', stream.id)
|
|
||||||
// return playlistUri
|
|
||||||
}
|
}
|
||||||
|
|
||||||
streamUpdate(socket, { currentTime, streamId }) {
|
streamUpdate(socket, { currentTime, streamId }) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class AudioFile {
|
|||||||
|
|
||||||
this.trackNumFromMeta = null
|
this.trackNumFromMeta = null
|
||||||
this.trackNumFromFilename = null
|
this.trackNumFromFilename = null
|
||||||
|
this.cdNumFromFilename = null
|
||||||
|
|
||||||
this.format = null
|
this.format = null
|
||||||
this.duration = null
|
this.duration = null
|
||||||
@@ -39,6 +40,16 @@ class AudioFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort number takes cd num into account
|
||||||
|
// get sortNumber() {
|
||||||
|
// if (this.manuallyVerified) return this.index
|
||||||
|
// var num = this.index
|
||||||
|
// if (this.cdNumFromFilename && !isNaN(this.cdNumFromFilename)) {
|
||||||
|
// num += (Number(this.cdNumFromFilename) * 1000)
|
||||||
|
// }
|
||||||
|
// return num
|
||||||
|
// }
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
index: this.index,
|
index: this.index,
|
||||||
@@ -50,6 +61,7 @@ class AudioFile {
|
|||||||
addedAt: this.addedAt,
|
addedAt: this.addedAt,
|
||||||
trackNumFromMeta: this.trackNumFromMeta,
|
trackNumFromMeta: this.trackNumFromMeta,
|
||||||
trackNumFromFilename: this.trackNumFromFilename,
|
trackNumFromFilename: this.trackNumFromFilename,
|
||||||
|
cdNumFromFilename: this.cdNumFromFilename,
|
||||||
manuallyVerified: !!this.manuallyVerified,
|
manuallyVerified: !!this.manuallyVerified,
|
||||||
invalid: !!this.invalid,
|
invalid: !!this.invalid,
|
||||||
exclude: !!this.exclude,
|
exclude: !!this.exclude,
|
||||||
@@ -84,6 +96,7 @@ class AudioFile {
|
|||||||
|
|
||||||
this.trackNumFromMeta = data.trackNumFromMeta || null
|
this.trackNumFromMeta = data.trackNumFromMeta || null
|
||||||
this.trackNumFromFilename = data.trackNumFromFilename || null
|
this.trackNumFromFilename = data.trackNumFromFilename || null
|
||||||
|
this.cdNumFromFilename = data.cdNumFromFilename || null
|
||||||
|
|
||||||
this.format = data.format
|
this.format = data.format
|
||||||
this.duration = data.duration
|
this.duration = data.duration
|
||||||
@@ -117,6 +130,7 @@ class AudioFile {
|
|||||||
|
|
||||||
this.trackNumFromMeta = data.trackNumFromMeta || null
|
this.trackNumFromMeta = data.trackNumFromMeta || null
|
||||||
this.trackNumFromFilename = data.trackNumFromFilename || null
|
this.trackNumFromFilename = data.trackNumFromFilename || null
|
||||||
|
this.cdNumFromFilename = data.cdNumFromFilename || null
|
||||||
|
|
||||||
this.manuallyVerified = !!data.manuallyVerified
|
this.manuallyVerified = !!data.manuallyVerified
|
||||||
this.invalid = !!data.invalid
|
this.invalid = !!data.invalid
|
||||||
@@ -178,7 +192,10 @@ class AudioFile {
|
|||||||
channels: data.channels,
|
channels: data.channels,
|
||||||
channelLayout: data.channel_layout,
|
channelLayout: data.channel_layout,
|
||||||
chapters: data.chapters || [],
|
chapters: data.chapters || [],
|
||||||
embeddedCoverArt: data.embedded_cover_art || null
|
embeddedCoverArt: data.embedded_cover_art || null,
|
||||||
|
trackNumFromMeta: data.trackNumFromMeta,
|
||||||
|
trackNumFromFilename: data.trackNumFromFilename,
|
||||||
|
cdNumFromFilename: data.cdNumFromFilename
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasUpdates = false
|
var hasUpdates = false
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ class AudioFileMetadata {
|
|||||||
this.tagArtist = null
|
this.tagArtist = null
|
||||||
this.tagGenre = null
|
this.tagGenre = null
|
||||||
this.tagTitle = null
|
this.tagTitle = null
|
||||||
|
this.tagSeries = null
|
||||||
|
this.tagSeriesPart = null
|
||||||
this.tagTrack = null
|
this.tagTrack = null
|
||||||
this.tagSubtitle = null
|
this.tagSubtitle = null
|
||||||
this.tagAlbumArtist = null
|
this.tagAlbumArtist = null
|
||||||
@@ -36,6 +38,8 @@ class AudioFileMetadata {
|
|||||||
this.tagArtist = metadata.tagArtist || null
|
this.tagArtist = metadata.tagArtist || null
|
||||||
this.tagGenre = metadata.tagGenre || null
|
this.tagGenre = metadata.tagGenre || null
|
||||||
this.tagTitle = metadata.tagTitle || null
|
this.tagTitle = metadata.tagTitle || null
|
||||||
|
this.tagSeries = metadata.tagSeries || null
|
||||||
|
this.tagSeriesPart = metadata.tagSeriesPart || null
|
||||||
this.tagTrack = metadata.tagTrack || null
|
this.tagTrack = metadata.tagTrack || null
|
||||||
this.tagSubtitle = metadata.tagSubtitle || null
|
this.tagSubtitle = metadata.tagSubtitle || null
|
||||||
this.tagAlbumArtist = metadata.tagAlbumArtist || null
|
this.tagAlbumArtist = metadata.tagAlbumArtist || null
|
||||||
@@ -54,6 +58,8 @@ class AudioFileMetadata {
|
|||||||
this.tagArtist = payload.file_tag_artist || null
|
this.tagArtist = payload.file_tag_artist || null
|
||||||
this.tagGenre = payload.file_tag_genre || null
|
this.tagGenre = payload.file_tag_genre || null
|
||||||
this.tagTitle = payload.file_tag_title || null
|
this.tagTitle = payload.file_tag_title || null
|
||||||
|
this.tagSeries = payload.file_tag_series || null
|
||||||
|
this.tagSeriesPart = payload.file_tag_seriespart || null
|
||||||
this.tagTrack = payload.file_tag_track || null
|
this.tagTrack = payload.file_tag_track || null
|
||||||
this.tagSubtitle = payload.file_tag_subtitle || null
|
this.tagSubtitle = payload.file_tag_subtitle || null
|
||||||
this.tagAlbumArtist = payload.file_tag_albumartist || null
|
this.tagAlbumArtist = payload.file_tag_albumartist || null
|
||||||
@@ -72,6 +78,8 @@ class AudioFileMetadata {
|
|||||||
tagArtist: payload.file_tag_artist || null,
|
tagArtist: payload.file_tag_artist || null,
|
||||||
tagGenre: payload.file_tag_genre || null,
|
tagGenre: payload.file_tag_genre || null,
|
||||||
tagTitle: payload.file_tag_title || null,
|
tagTitle: payload.file_tag_title || null,
|
||||||
|
tagSeries: payload.file_tag_series || null,
|
||||||
|
tagSeriesPart: payload.file_tag_seriespart || null,
|
||||||
tagTrack: payload.file_tag_track || null,
|
tagTrack: payload.file_tag_track || null,
|
||||||
tagSubtitle: payload.file_tag_subtitle || null,
|
tagSubtitle: payload.file_tag_subtitle || null,
|
||||||
tagAlbumArtist: payload.file_tag_albumartist || null,
|
tagAlbumArtist: payload.file_tag_albumartist || null,
|
||||||
|
|||||||
+15
-16
@@ -127,18 +127,6 @@ class Audiobook {
|
|||||||
return this.otherFiles.filter(file => file.filetype === 'ebook')
|
return this.otherFiles.filter(file => file.filetype === 'ebook')
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasEpub() {
|
|
||||||
return this.ebooks.find(file => file.ext === '.epub')
|
|
||||||
}
|
|
||||||
|
|
||||||
get hasMobi() {
|
|
||||||
return this.ebooks.find(file => file.ext === '.mobi' || file.ext === '.azw3')
|
|
||||||
}
|
|
||||||
|
|
||||||
get hasPdf() {
|
|
||||||
return this.ebooks.find(file => file.ext === '.pdf')
|
|
||||||
}
|
|
||||||
|
|
||||||
get hasMissingIno() {
|
get hasMissingIno() {
|
||||||
return !this.ino || this._audioFiles.find(abf => !abf.ino) || this._otherFiles.find(f => !f.ino) || this._tracks.find(t => !t.ino)
|
return !this.ino || this._audioFiles.find(abf => !abf.ino) || this._otherFiles.find(f => !f.ino) || this._tracks.find(t => !t.ino)
|
||||||
}
|
}
|
||||||
@@ -210,7 +198,7 @@ class Audiobook {
|
|||||||
hasInvalidParts: this.invalidParts ? this.invalidParts.length : 0,
|
hasInvalidParts: this.invalidParts ? this.invalidParts.length : 0,
|
||||||
// numEbooks: this.ebooks.length,
|
// numEbooks: this.ebooks.length,
|
||||||
ebooks: this.ebooks.map(ebook => ebook.toJSON()),
|
ebooks: this.ebooks.map(ebook => ebook.toJSON()),
|
||||||
numEbooks: (this.hasEpub || this.hasMobi || this.hasPdf) ? 1 : 0, // Only supporting epubs in the reader currently
|
numEbooks: this.ebooks.length,
|
||||||
numTracks: this.tracks.length,
|
numTracks: this.tracks.length,
|
||||||
chapters: this.chapters || [],
|
chapters: this.chapters || [],
|
||||||
isMissing: !!this.isMissing,
|
isMissing: !!this.isMissing,
|
||||||
@@ -237,7 +225,7 @@ class Audiobook {
|
|||||||
audioFiles: this._audioFiles.map(audioFile => audioFile.toJSON()),
|
audioFiles: this._audioFiles.map(audioFile => audioFile.toJSON()),
|
||||||
otherFiles: this._otherFiles.map(otherFile => otherFile.toJSON()),
|
otherFiles: this._otherFiles.map(otherFile => otherFile.toJSON()),
|
||||||
ebooks: this.ebooks.map(ebook => ebook.toJSON()),
|
ebooks: this.ebooks.map(ebook => ebook.toJSON()),
|
||||||
numEbooks: (this.hasEpub || this.hasMobi || this.hasPdf) ? 1 : 0,
|
numEbooks: this.ebooks.length,
|
||||||
numTracks: this.tracks.length,
|
numTracks: this.tracks.length,
|
||||||
tags: this.tags,
|
tags: this.tags,
|
||||||
book: this.bookToJSON(),
|
book: this.bookToJSON(),
|
||||||
@@ -650,11 +638,22 @@ class Audiobook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isSearchMatch(search) {
|
isSearchMatch(search) {
|
||||||
return this.book.isSearchMatch(search.toLowerCase().trim())
|
var tagMatch = this.tags.filter(tag => {
|
||||||
|
return tag.toLowerCase().includes(search.toLowerCase().trim())
|
||||||
|
})
|
||||||
|
return this.book.isSearchMatch(search.toLowerCase().trim()) || tagMatch.length
|
||||||
}
|
}
|
||||||
|
|
||||||
searchQuery(search) {
|
searchQuery(search) {
|
||||||
return this.book.getQueryMatches(search.toLowerCase().trim())
|
var matches = this.book.getQueryMatches(search.toLowerCase().trim())
|
||||||
|
matches.tags = this.tags.filter(tag => {
|
||||||
|
return tag.toLowerCase().includes(search.toLowerCase().trim())
|
||||||
|
})
|
||||||
|
if (!matches.book && matches.tags.length) {
|
||||||
|
matches.book = 'tags'
|
||||||
|
matches.bookMatchText = matches.tags.join(', ')
|
||||||
|
}
|
||||||
|
return matches
|
||||||
}
|
}
|
||||||
|
|
||||||
getAudioFileByIno(ino) {
|
getAudioFileByIno(ino) {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class AudiobookProgress {
|
class AudiobookProgress {
|
||||||
constructor(progress) {
|
constructor(progress) {
|
||||||
this.audiobookId = null
|
this.audiobookId = null
|
||||||
this.audiobookTitle = null
|
|
||||||
|
this.id = null
|
||||||
this.totalDuration = null // seconds
|
this.totalDuration = null // seconds
|
||||||
this.progress = null // 0 to 1
|
this.progress = null // 0 to 1
|
||||||
this.currentTime = null // seconds
|
this.currentTime = null // seconds
|
||||||
@@ -18,7 +19,6 @@ class AudiobookProgress {
|
|||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
audiobookId: this.audiobookId,
|
audiobookId: this.audiobookId,
|
||||||
audiobookTitle: this.audiobookTitle,
|
|
||||||
totalDuration: this.totalDuration,
|
totalDuration: this.totalDuration,
|
||||||
progress: this.progress,
|
progress: this.progress,
|
||||||
currentTime: this.currentTime,
|
currentTime: this.currentTime,
|
||||||
@@ -31,7 +31,6 @@ class AudiobookProgress {
|
|||||||
|
|
||||||
construct(progress) {
|
construct(progress) {
|
||||||
this.audiobookId = progress.audiobookId
|
this.audiobookId = progress.audiobookId
|
||||||
this.audiobookTitle = progress.audiobookTitle || null
|
|
||||||
this.totalDuration = progress.totalDuration
|
this.totalDuration = progress.totalDuration
|
||||||
this.progress = progress.progress
|
this.progress = progress.progress
|
||||||
this.currentTime = progress.currentTime
|
this.currentTime = progress.currentTime
|
||||||
@@ -43,7 +42,6 @@ class AudiobookProgress {
|
|||||||
|
|
||||||
updateFromStream(stream) {
|
updateFromStream(stream) {
|
||||||
this.audiobookId = stream.audiobookId
|
this.audiobookId = stream.audiobookId
|
||||||
this.audiobookTitle = stream.audiobookTitle
|
|
||||||
this.totalDuration = stream.totalDuration
|
this.totalDuration = stream.totalDuration
|
||||||
this.progress = stream.clientProgress
|
this.progress = stream.clientProgress
|
||||||
this.currentTime = stream.clientCurrentTime
|
this.currentTime = stream.clientCurrentTime
|
||||||
@@ -89,6 +87,9 @@ class AudiobookProgress {
|
|||||||
if (!this.startedAt) {
|
if (!this.startedAt) {
|
||||||
this.startedAt = Date.now()
|
this.startedAt = Date.now()
|
||||||
}
|
}
|
||||||
|
if (hasUpdates) {
|
||||||
|
this.lastUpdate = Date.now()
|
||||||
|
}
|
||||||
return hasUpdates
|
return hasUpdates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-8
@@ -35,11 +35,11 @@ class Book {
|
|||||||
get _title() { return this.title || '' }
|
get _title() { return this.title || '' }
|
||||||
get _subtitle() { return this.subtitle || '' }
|
get _subtitle() { return this.subtitle || '' }
|
||||||
get _narrator() { return this.narrator || '' }
|
get _narrator() { return this.narrator || '' }
|
||||||
get _author() { return this.author || '' }
|
get _author() { return this.authorFL || '' }
|
||||||
get _series() { return this.series || '' }
|
get _series() { return this.series || '' }
|
||||||
|
|
||||||
get shouldSearchForCover() {
|
get shouldSearchForCover() {
|
||||||
if (this.author !== this.lastCoverSearchAuthor || this.title !== this.lastCoverSearchTitle || !this.lastCoverSearch) return true
|
if (this.authorFL !== this.lastCoverSearchAuthor || this.title !== this.lastCoverSearchTitle || !this.lastCoverSearch) return true
|
||||||
var timeSinceLastSearch = Date.now() - this.lastCoverSearch
|
var timeSinceLastSearch = Date.now() - this.lastCoverSearch
|
||||||
return timeSinceLastSearch > 1000 * 60 * 60 * 24 * 7 // every 7 days do another lookup
|
return timeSinceLastSearch > 1000 * 60 * 60 * 24 * 7 // every 7 days do another lookup
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ class Book {
|
|||||||
|
|
||||||
updateLastCoverSearch(coverWasFound) {
|
updateLastCoverSearch(coverWasFound) {
|
||||||
this.lastCoverSearch = coverWasFound ? null : Date.now()
|
this.lastCoverSearch = coverWasFound ? null : Date.now()
|
||||||
this.lastCoverSearchAuthor = coverWasFound ? null : this.author
|
this.lastCoverSearchAuthor = coverWasFound ? null : this.authorFL
|
||||||
this.lastCoverSearchTitle = coverWasFound ? null : this.title
|
this.lastCoverSearchTitle = coverWasFound ? null : this.title
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,16 +220,32 @@ class Book {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getQueryMatches(search) {
|
getQueryMatches(search) {
|
||||||
var titleMatch = this._title.toLowerCase().includes(search) || this._subtitle.toLowerCase().includes(search)
|
var titleMatch = this._title.toLowerCase().includes(search)
|
||||||
|
var subtitleMatch = this._subtitle.toLowerCase().includes(search)
|
||||||
var authorMatch = this._author.toLowerCase().includes(search)
|
var authorMatch = this._author.toLowerCase().includes(search)
|
||||||
var seriesMatch = this._series.toLowerCase().includes(search)
|
var seriesMatch = this._series.toLowerCase().includes(search)
|
||||||
|
|
||||||
|
var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorMatch ? 'authorFL' : seriesMatch ? 'series' : false
|
||||||
|
var bookMatchText = bookMatchKey ? this[bookMatchKey] : ''
|
||||||
return {
|
return {
|
||||||
book: titleMatch ? 'title' : authorMatch ? 'author' : seriesMatch ? 'series' : false,
|
book: bookMatchKey,
|
||||||
|
bookMatchText,
|
||||||
author: authorMatch ? this._author : false,
|
author: authorMatch ? this._author : false,
|
||||||
series: seriesMatch ? this._series : false
|
series: seriesMatch ? this._series : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseGenresTag(genreTag) {
|
||||||
|
if (!genreTag || !genreTag.length) return []
|
||||||
|
var separators = ['/', '//', ';']
|
||||||
|
for (let i = 0; i < separators.length; i++) {
|
||||||
|
if (genreTag.includes(separators[i])) {
|
||||||
|
return genreTag.split(separators[i]).map(genre => genre.trim()).filter(g => !!g)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [genreTag]
|
||||||
|
}
|
||||||
|
|
||||||
setDetailsFromFileMetadata(audioFileMetadata) {
|
setDetailsFromFileMetadata(audioFileMetadata) {
|
||||||
const MetadataMapArray = [
|
const MetadataMapArray = [
|
||||||
{
|
{
|
||||||
@@ -255,14 +271,33 @@ class Book {
|
|||||||
{
|
{
|
||||||
tag: 'tagArtist',
|
tag: 'tagArtist',
|
||||||
key: 'author'
|
key: 'author'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tag: 'tagGenre',
|
||||||
|
key: 'genres'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tag: 'tagSeries',
|
||||||
|
key: 'series'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tag: 'tagSeriesPart',
|
||||||
|
key: 'volumeNumber'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
var updatePayload = {}
|
var updatePayload = {}
|
||||||
|
// Metadata is only mapped to the book if it is empty
|
||||||
MetadataMapArray.forEach((mapping) => {
|
MetadataMapArray.forEach((mapping) => {
|
||||||
if (!this[mapping.key] && audioFileMetadata[mapping.tag]) {
|
if (audioFileMetadata[mapping.tag]) {
|
||||||
updatePayload[mapping.key] = audioFileMetadata[mapping.tag]
|
// Genres can contain multiple
|
||||||
Logger.debug(`[Book] Mapping metadata to key ${mapping.tag} => ${mapping.key}: ${updatePayload[mapping.key]}`)
|
if (mapping.key === 'genres' && (!this[mapping.key].length || !this[mapping.key])) {
|
||||||
|
updatePayload[mapping.key] = this.parseGenresTag(audioFileMetadata[mapping.tag])
|
||||||
|
Logger.debug(`[Book] Mapping metadata to key ${mapping.tag} => ${mapping.key}: ${updatePayload[mapping.key].join(',')}`)
|
||||||
|
} else if (!this[mapping.key]) {
|
||||||
|
updatePayload[mapping.key] = audioFileMetadata[mapping.tag]
|
||||||
|
Logger.debug(`[Book] Mapping metadata to key ${mapping.tag} => ${mapping.key}: ${updatePayload[mapping.key]}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class Stream extends EventEmitter {
|
|||||||
const hlsOptions = [
|
const hlsOptions = [
|
||||||
'-f hls',
|
'-f hls',
|
||||||
"-copyts",
|
"-copyts",
|
||||||
"-avoid_negative_ts disabled",
|
"-avoid_negative_ts make_non_negative",
|
||||||
"-max_delay 5000000",
|
"-max_delay 5000000",
|
||||||
"-max_muxing_queue_size 2048",
|
"-max_muxing_queue_size 2048",
|
||||||
`-hls_time 6`,
|
`-hls_time 6`,
|
||||||
@@ -273,7 +273,8 @@ class Stream extends EventEmitter {
|
|||||||
]
|
]
|
||||||
if (this.hlsSegmentType === 'fmp4') {
|
if (this.hlsSegmentType === 'fmp4') {
|
||||||
hlsOptions.push('-strict -2')
|
hlsOptions.push('-strict -2')
|
||||||
var fmp4InitFilename = Path.join(this.streamPath, 'init.mp4')
|
// var fmp4InitFilename = Path.join(this.streamPath, 'init.mp4')
|
||||||
|
var fmp4InitFilename = 'init.mp4'
|
||||||
hlsOptions.push(`-hls_fmp4_init_filename ${fmp4InitFilename}`)
|
hlsOptions.push(`-hls_fmp4_init_filename ${fmp4InitFilename}`)
|
||||||
}
|
}
|
||||||
this.ffmpeg.addOption(hlsOptions)
|
this.ffmpeg.addOption(hlsOptions)
|
||||||
|
|||||||
+48
-11
@@ -16,6 +16,7 @@ class User {
|
|||||||
|
|
||||||
this.settings = {}
|
this.settings = {}
|
||||||
this.permissions = {}
|
this.permissions = {}
|
||||||
|
this.librariesAccessible = [] // Library IDs (Empty if ALL libraries)
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
this.construct(user)
|
this.construct(user)
|
||||||
@@ -37,9 +38,18 @@ class User {
|
|||||||
get canUpload() {
|
get canUpload() {
|
||||||
return !!this.permissions.upload && this.isActive
|
return !!this.permissions.upload && this.isActive
|
||||||
}
|
}
|
||||||
|
get canAccessAllLibraries() {
|
||||||
|
return !!this.permissions.accessAllLibraries && this.isActive
|
||||||
|
}
|
||||||
|
get hasPw() {
|
||||||
|
return !!this.pash && !!this.pash.length
|
||||||
|
}
|
||||||
|
|
||||||
getDefaultUserSettings() {
|
getDefaultUserSettings() {
|
||||||
return {
|
return {
|
||||||
|
mobileOrderBy: 'recent',
|
||||||
|
mobileOrderDesc: true,
|
||||||
|
mobileFilterBy: 'all',
|
||||||
orderBy: 'book.title',
|
orderBy: 'book.title',
|
||||||
orderDesc: false,
|
orderDesc: false,
|
||||||
filterBy: 'all',
|
filterBy: 'all',
|
||||||
@@ -53,7 +63,8 @@ class User {
|
|||||||
download: true,
|
download: true,
|
||||||
update: true,
|
update: true,
|
||||||
delete: this.type === 'root',
|
delete: this.type === 'root',
|
||||||
upload: this.type === 'root' || this.type === 'admin'
|
upload: this.type === 'root' || this.type === 'admin',
|
||||||
|
accessAllLibraries: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +93,8 @@ class User {
|
|||||||
lastSeen: this.lastSeen,
|
lastSeen: this.lastSeen,
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
settings: this.settings,
|
settings: this.settings,
|
||||||
permissions: this.permissions
|
permissions: this.permissions,
|
||||||
|
librariesAccessible: [...this.librariesAccessible]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,10 +111,12 @@ class User {
|
|||||||
lastSeen: this.lastSeen,
|
lastSeen: this.lastSeen,
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
settings: this.settings,
|
settings: this.settings,
|
||||||
permissions: this.permissions
|
permissions: this.permissions,
|
||||||
|
librariesAccessible: [...this.librariesAccessible]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Data broadcasted
|
||||||
toJSONForPublic(streams) {
|
toJSONForPublic(streams) {
|
||||||
var stream = this.stream && streams ? streams.find(s => s.id === this.stream) : null
|
var stream = this.stream && streams ? streams.find(s => s.id === this.stream) : null
|
||||||
return {
|
return {
|
||||||
@@ -138,6 +152,11 @@ class User {
|
|||||||
this.permissions = user.permissions || this.getDefaultUserPermissions()
|
this.permissions = user.permissions || this.getDefaultUserPermissions()
|
||||||
// Upload permission added v1.1.13, make sure root user has upload permissions
|
// Upload permission added v1.1.13, make sure root user has upload permissions
|
||||||
if (this.type === 'root' && !this.permissions.upload) this.permissions.upload = true
|
if (this.type === 'root' && !this.permissions.upload) this.permissions.upload = true
|
||||||
|
|
||||||
|
// Library restriction permissions added v1.4.14, defaults to all libraries
|
||||||
|
if (this.permissions.accessAllLibraries === undefined) this.permissions.accessAllLibraries = true
|
||||||
|
|
||||||
|
this.librariesAccessible = (user.librariesAccessible || []).map(l => l)
|
||||||
}
|
}
|
||||||
|
|
||||||
update(payload) {
|
update(payload) {
|
||||||
@@ -163,6 +182,18 @@ class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Update accessible libraries
|
||||||
|
if (payload.librariesAccessible !== undefined) {
|
||||||
|
if (payload.librariesAccessible.length) {
|
||||||
|
if (payload.librariesAccessible.join(',') !== this.librariesAccessible.join(',')) {
|
||||||
|
hasUpdates = true
|
||||||
|
this.librariesAccessible = [...payload.librariesAccessible]
|
||||||
|
}
|
||||||
|
} else if (this.librariesAccessible.length > 0) {
|
||||||
|
hasUpdates = true
|
||||||
|
this.librariesAccessible = []
|
||||||
|
}
|
||||||
|
}
|
||||||
return hasUpdates
|
return hasUpdates
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,13 +205,13 @@ class User {
|
|||||||
this.audiobooks[stream.audiobookId].updateFromStream(stream)
|
this.audiobooks[stream.audiobookId].updateFromStream(stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAudiobookProgress(audiobookId, updatePayload) {
|
updateAudiobookProgress(audiobook, updatePayload) {
|
||||||
if (!this.audiobooks) this.audiobooks = {}
|
if (!this.audiobooks) this.audiobooks = {}
|
||||||
if (!this.audiobooks[audiobookId]) {
|
if (!this.audiobooks[audiobook.id]) {
|
||||||
this.audiobooks[audiobookId] = new AudiobookProgress()
|
this.audiobooks[audiobook.id] = new AudiobookProgress()
|
||||||
this.audiobooks[audiobookId].audiobookId = audiobookId
|
this.audiobooks[audiobook.id].audiobookId = audiobook.id
|
||||||
}
|
}
|
||||||
return this.audiobooks[audiobookId].update(updatePayload)
|
return this.audiobooks[audiobook.id].update(updatePayload)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns Boolean If update was made
|
// Returns Boolean If update was made
|
||||||
@@ -209,11 +240,11 @@ class User {
|
|||||||
return madeUpdates
|
return madeUpdates
|
||||||
}
|
}
|
||||||
|
|
||||||
resetAudiobookProgress(audiobookId) {
|
resetAudiobookProgress(audiobook) {
|
||||||
if (!this.audiobooks || !this.audiobooks[audiobookId]) {
|
if (!this.audiobooks || !this.audiobooks[audiobook.id]) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return this.updateAudiobookProgress(audiobookId, {
|
return this.updateAudiobookProgress(audiobook, {
|
||||||
progress: 0,
|
progress: 0,
|
||||||
currentTime: 0,
|
currentTime: 0,
|
||||||
isRead: false,
|
isRead: false,
|
||||||
@@ -230,5 +261,11 @@ class User {
|
|||||||
delete this.audiobooks[audiobookId]
|
delete this.audiobooks[audiobookId]
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCanAccessLibrary(libraryId) {
|
||||||
|
if (this.permissions.accessAllLibraries) return true
|
||||||
|
if (!this.librariesAccessible) return false
|
||||||
|
return this.librariesAccessible.includes(libraryId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
module.exports = User
|
module.exports = User
|
||||||
@@ -11,9 +11,9 @@ function getDefaultAudioStream(audioStreams) {
|
|||||||
return defaultStream
|
return defaultStream
|
||||||
}
|
}
|
||||||
|
|
||||||
async function scan(path) {
|
async function scan(path, verbose = false) {
|
||||||
Logger.debug(`Scanning path "${path}"`)
|
Logger.debug(`Scanning path "${path}"`)
|
||||||
var probeData = await prober(path)
|
var probeData = await prober(path, verbose)
|
||||||
if (!probeData || !probeData.audio_streams || !probeData.audio_streams.length) {
|
if (!probeData || !probeData.audio_streams || !probeData.audio_streams.length) {
|
||||||
return {
|
return {
|
||||||
error: 'Invalid audio file'
|
error: 'Invalid audio file'
|
||||||
@@ -62,6 +62,10 @@ async function scan(path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose && probeData.rawTags) {
|
||||||
|
finalData.rawTags = probeData.rawTags
|
||||||
|
}
|
||||||
|
|
||||||
return finalData
|
return finalData
|
||||||
}
|
}
|
||||||
module.exports.scan = scan
|
module.exports.scan = scan
|
||||||
@@ -85,7 +89,10 @@ function getTrackNumberFromFilename(title, author, series, publishYear, filename
|
|||||||
if (publishYear) partbasename = partbasename.replace(publishYear)
|
if (publishYear) partbasename = partbasename.replace(publishYear)
|
||||||
|
|
||||||
// Remove eg. "disc 1" from path
|
// Remove eg. "disc 1" from path
|
||||||
partbasename = partbasename.replace(/ disc \d\d? /i, '')
|
partbasename = partbasename.replace(/\bdisc \d\d?\b/i, '')
|
||||||
|
|
||||||
|
// Remove "cd01" or "cd 01" from path
|
||||||
|
partbasename = partbasename.replace(/\bcd ?\d\d?\b/i, '')
|
||||||
|
|
||||||
var numbersinpath = partbasename.match(/\d{1,4}/g)
|
var numbersinpath = partbasename.match(/\d{1,4}/g)
|
||||||
if (!numbersinpath) return null
|
if (!numbersinpath) return null
|
||||||
@@ -94,6 +101,27 @@ function getTrackNumberFromFilename(title, author, series, publishYear, filename
|
|||||||
return number
|
return number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCdNumberFromFilename(title, author, series, publishYear, filename) {
|
||||||
|
var partbasename = Path.basename(filename, Path.extname(filename))
|
||||||
|
|
||||||
|
// Remove title, author, series, and publishYear from filename if there
|
||||||
|
if (title) partbasename = partbasename.replace(title, '')
|
||||||
|
if (author) partbasename = partbasename.replace(author, '')
|
||||||
|
if (series) partbasename = partbasename.replace(series, '')
|
||||||
|
if (publishYear) partbasename = partbasename.replace(publishYear)
|
||||||
|
|
||||||
|
var cdNumber = null
|
||||||
|
|
||||||
|
var cdmatch = partbasename.match(/\b(disc|cd) ?(\d\d?)\b/i)
|
||||||
|
if (cdmatch && cdmatch.length > 2 && cdmatch[2]) {
|
||||||
|
if (!isNaN(cdmatch[2])) {
|
||||||
|
cdNumber = Number(cdmatch[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cdNumber
|
||||||
|
}
|
||||||
|
|
||||||
async function scanAudioFiles(audiobook, newAudioFiles) {
|
async function scanAudioFiles(audiobook, newAudioFiles) {
|
||||||
if (!newAudioFiles || !newAudioFiles.length) {
|
if (!newAudioFiles || !newAudioFiles.length) {
|
||||||
Logger.error('[AudioFileScanner] Scan Audio Files no new files', audiobook.title)
|
Logger.error('[AudioFileScanner] Scan Audio Files no new files', audiobook.title)
|
||||||
@@ -111,7 +139,6 @@ async function scanAudioFiles(audiobook, newAudioFiles) {
|
|||||||
var scanData = await scan(audioFile.fullPath)
|
var scanData = await scan(audioFile.fullPath)
|
||||||
if (!scanData || scanData.error) {
|
if (!scanData || scanData.error) {
|
||||||
Logger.error('[AudioFileScanner] Scan failed for', audioFile.path)
|
Logger.error('[AudioFileScanner] Scan failed for', audioFile.path)
|
||||||
// audiobook.invalidAudioFiles.push(parts[i])
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +147,14 @@ async function scanAudioFiles(audiobook, newAudioFiles) {
|
|||||||
|
|
||||||
var trackNumFromFilename = getTrackNumberFromFilename(book.title, book.author, book.series, book.publishYear, audioFile.filename)
|
var trackNumFromFilename = getTrackNumberFromFilename(book.title, book.author, book.series, book.publishYear, audioFile.filename)
|
||||||
|
|
||||||
|
var cdNumFromFilename = getCdNumberFromFilename(book.title, book.author, book.series, book.publishYear, audioFile.filename)
|
||||||
|
|
||||||
|
// IF CD num was found but no track num - USE cd num as track num
|
||||||
|
if (!trackNumFromFilename && cdNumFromFilename) {
|
||||||
|
trackNumFromFilename = cdNumFromFilename
|
||||||
|
cdNumFromFilename = null
|
||||||
|
}
|
||||||
|
|
||||||
var audioFileObj = {
|
var audioFileObj = {
|
||||||
ino: audioFile.ino,
|
ino: audioFile.ino,
|
||||||
filename: audioFile.filename,
|
filename: audioFile.filename,
|
||||||
@@ -128,7 +163,8 @@ async function scanAudioFiles(audiobook, newAudioFiles) {
|
|||||||
ext: audioFile.ext,
|
ext: audioFile.ext,
|
||||||
...scanData,
|
...scanData,
|
||||||
trackNumFromMeta,
|
trackNumFromMeta,
|
||||||
trackNumFromFilename
|
trackNumFromFilename,
|
||||||
|
cdNumFromFilename
|
||||||
}
|
}
|
||||||
var audioFile = audiobook.addAudioFile(audioFileObj)
|
var audioFile = audiobook.addAudioFile(audioFileObj)
|
||||||
|
|
||||||
@@ -169,6 +205,7 @@ async function scanAudioFiles(audiobook, newAudioFiles) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tracks.sort((a, b) => a.index - b.index)
|
tracks.sort((a, b) => a.index - b.index)
|
||||||
|
|
||||||
audiobook.audioFiles.sort((a, b) => {
|
audiobook.audioFiles.sort((a, b) => {
|
||||||
var aNum = isNumber(a.trackNumFromMeta) ? a.trackNumFromMeta : isNumber(a.trackNumFromFilename) ? a.trackNumFromFilename : 0
|
var aNum = isNumber(a.trackNumFromMeta) ? a.trackNumFromMeta : isNumber(a.trackNumFromFilename) ? a.trackNumFromFilename : 0
|
||||||
var bNum = isNumber(b.trackNumFromMeta) ? b.trackNumFromMeta : isNumber(b.trackNumFromFilename) ? b.trackNumFromFilename : 0
|
var bNum = isNumber(b.trackNumFromMeta) ? b.trackNumFromMeta : isNumber(b.trackNumFromFilename) ? b.trackNumFromFilename : 0
|
||||||
@@ -206,7 +243,27 @@ async function rescanAudioFiles(audiobook) {
|
|||||||
// audiobook.invalidAudioFiles.push(parts[i])
|
// audiobook.invalidAudioFiles.push(parts[i])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var hasUpdates = audioFile.updateMetadata(scanData)
|
|
||||||
|
var trackNumFromMeta = getTrackNumberFromMeta(scanData)
|
||||||
|
var book = audiobook.book || {}
|
||||||
|
|
||||||
|
var trackNumFromFilename = getTrackNumberFromFilename(book.title, book.author, book.series, book.publishYear, audioFile.filename)
|
||||||
|
|
||||||
|
var cdNumFromFilename = getCdNumberFromFilename(book.title, book.author, book.series, book.publishYear, audioFile.filename)
|
||||||
|
|
||||||
|
// IF CD num was found but no track num - USE cd num as track num
|
||||||
|
if (!trackNumFromFilename && cdNumFromFilename) {
|
||||||
|
trackNumFromFilename = cdNumFromFilename
|
||||||
|
cdNumFromFilename = null
|
||||||
|
}
|
||||||
|
|
||||||
|
var metadataUpdate = {
|
||||||
|
...scanData,
|
||||||
|
trackNumFromMeta,
|
||||||
|
trackNumFromFilename,
|
||||||
|
cdNumFromFilename
|
||||||
|
}
|
||||||
|
var hasUpdates = audioFile.updateMetadata(metadataUpdate)
|
||||||
if (hasUpdates) {
|
if (hasUpdates) {
|
||||||
// Sync audio track with audio file
|
// Sync audio track with audio file
|
||||||
var matchingAudioTrack = audiobook.tracks.find(t => t.ino === audioFile.ino)
|
var matchingAudioTrack = audiobook.tracks.find(t => t.ino === audioFile.ino)
|
||||||
@@ -233,4 +290,28 @@ async function rescanAudioFiles(audiobook) {
|
|||||||
|
|
||||||
return updates
|
return updates
|
||||||
}
|
}
|
||||||
module.exports.rescanAudioFiles = rescanAudioFiles
|
module.exports.rescanAudioFiles = rescanAudioFiles
|
||||||
|
|
||||||
|
async function scanTrackNumbers(audiobook) {
|
||||||
|
var tracks = audiobook.tracks || []
|
||||||
|
var scannedTrackNumData = []
|
||||||
|
for (let i = 0; i < tracks.length; i++) {
|
||||||
|
var track = tracks[i]
|
||||||
|
var scanData = await scan(track.fullPath, true)
|
||||||
|
|
||||||
|
var trackNumFromMeta = getTrackNumberFromMeta(scanData)
|
||||||
|
var book = audiobook.book || {}
|
||||||
|
var trackNumFromFilename = getTrackNumberFromFilename(book.title, book.author, book.series, book.publishYear, track.filename)
|
||||||
|
Logger.info(`[AudioFileScanner] Track # for "${track.filename}", Metadata: "${trackNumFromMeta}", Filename: "${trackNumFromFilename}", Current: "${track.index}"`)
|
||||||
|
scannedTrackNumData.push({
|
||||||
|
filename: track.filename,
|
||||||
|
currentTrackNum: track.index,
|
||||||
|
trackNumFromFilename,
|
||||||
|
trackNumFromMeta,
|
||||||
|
scanDataTrackNum: scanData.file_tag_track,
|
||||||
|
rawTags: scanData.rawTags || null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return scannedTrackNumData
|
||||||
|
}
|
||||||
|
module.exports.scanTrackNumbers = scanTrackNumbers
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const globals = {
|
const globals = {
|
||||||
SupportedImageTypes: ['png', 'jpg', 'jpeg', 'webp'],
|
SupportedImageTypes: ['png', 'jpg', 'jpeg', 'webp'],
|
||||||
SupportedAudioTypes: ['m4b', 'mp3', 'm4a', 'flac', 'opus', 'mp4'],
|
SupportedAudioTypes: ['m4b', 'mp3', 'm4a', 'flac', 'opus', 'mp4'],
|
||||||
SupportedEbookTypes: ['epub', 'pdf', 'mobi', 'azw3']
|
SupportedEbookTypes: ['epub', 'pdf', 'mobi', 'azw3', 'cbr', 'cbz']
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = globals
|
module.exports = globals
|
||||||
|
|||||||
@@ -29,26 +29,6 @@ const levenshteinDistance = (str1, str2, caseSensitive = false) => {
|
|||||||
}
|
}
|
||||||
module.exports.levenshteinDistance = levenshteinDistance
|
module.exports.levenshteinDistance = levenshteinDistance
|
||||||
|
|
||||||
const cleanString = (str) => {
|
|
||||||
if (!str) return ''
|
|
||||||
|
|
||||||
// Now supporting all utf-8 characters, can remove this method in future
|
|
||||||
|
|
||||||
// replace accented characters: https://stackoverflow.com/a/49901740/7431543
|
|
||||||
// str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
|
|
||||||
|
|
||||||
// const availableChars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
|
||||||
// const cleanChar = (char) => availableChars.indexOf(char) < 0 ? '?' : char
|
|
||||||
|
|
||||||
// var cleaned = ''
|
|
||||||
// for (let i = 0; i < str.length; i++) {
|
|
||||||
// cleaned += cleanChar(str[i])
|
|
||||||
// }
|
|
||||||
|
|
||||||
return cleaned.trim()
|
|
||||||
}
|
|
||||||
module.exports.cleanString = cleanString
|
|
||||||
|
|
||||||
module.exports.isObject = (val) => {
|
module.exports.isObject = (val) => {
|
||||||
return val !== null && typeof val === 'object'
|
return val !== null && typeof val === 'object'
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-13
@@ -135,11 +135,13 @@ function parseChapters(chapters) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTags(format) {
|
function parseTags(format, verbose) {
|
||||||
if (!format.tags) {
|
if (!format.tags) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
// Logger.debug('Tags', format.tags)
|
if (verbose) {
|
||||||
|
Logger.debug('Tags', format.tags)
|
||||||
|
}
|
||||||
const tags = {
|
const tags = {
|
||||||
file_tag_encoder: tryGrabTags(format, 'encoder', 'tsse', 'tss'),
|
file_tag_encoder: tryGrabTags(format, 'encoder', 'tsse', 'tss'),
|
||||||
file_tag_encodedby: tryGrabTags(format, 'encoded_by', 'tenc', 'ten'),
|
file_tag_encodedby: tryGrabTags(format, 'encoded_by', 'tenc', 'ten'),
|
||||||
@@ -155,6 +157,8 @@ function parseTags(format) {
|
|||||||
file_tag_comment: tryGrabTags(format, 'comment', 'comm', 'com'),
|
file_tag_comment: tryGrabTags(format, 'comment', 'comm', 'com'),
|
||||||
file_tag_description: tryGrabTags(format, 'description', 'desc'),
|
file_tag_description: tryGrabTags(format, 'description', 'desc'),
|
||||||
file_tag_genre: tryGrabTags(format, 'genre', 'tcon', 'tco'),
|
file_tag_genre: tryGrabTags(format, 'genre', 'tcon', 'tco'),
|
||||||
|
file_tag_series: tryGrabTag(format, 'series'),
|
||||||
|
file_tag_seriespart: tryGrabTag(format, 'series-part'),
|
||||||
|
|
||||||
// Not sure if these are actually used yet or not
|
// Not sure if these are actually used yet or not
|
||||||
file_tag_creation_time: tryGrabTag(format, 'creation_time'),
|
file_tag_creation_time: tryGrabTag(format, 'creation_time'),
|
||||||
@@ -163,10 +167,8 @@ function parseTags(format) {
|
|||||||
file_tag_releasetime: tryGrabTags(format, 'releasetime', 'tdrl'),
|
file_tag_releasetime: tryGrabTags(format, 'releasetime', 'tdrl'),
|
||||||
file_tag_movementname: tryGrabTags(format, 'movementname', 'mvnm'),
|
file_tag_movementname: tryGrabTags(format, 'movementname', 'mvnm'),
|
||||||
file_tag_movement: tryGrabTags(format, 'movement', 'mvin'),
|
file_tag_movement: tryGrabTags(format, 'movement', 'mvin'),
|
||||||
file_tag_series: tryGrabTag(format, 'series'),
|
|
||||||
file_tag_seriespart: tryGrabTag(format, 'series-part'),
|
|
||||||
file_tag_genre1: tryGrabTags(format, 'tmp_genre1', 'genre1'),
|
file_tag_genre1: tryGrabTags(format, 'tmp_genre1', 'genre1'),
|
||||||
file_tag_genre2: tryGrabTags(format, 'tmp_genre2', 'genre2')
|
file_tag_genre2: tryGrabTags(format, 'tmp_genre2', 'genre2'),
|
||||||
}
|
}
|
||||||
for (const key in tags) {
|
for (const key in tags) {
|
||||||
if (!tags[key]) {
|
if (!tags[key]) {
|
||||||
@@ -175,14 +177,15 @@ function parseTags(format) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var keysToLookOutFor = ['file_tag_genre1', 'file_tag_genre2', 'file_tag_series', 'file_tag_seriespart', 'file_tag_movement', 'file_tag_movementname', 'file_tag_wwwaudiofile', 'file_tag_contentgroup', 'file_tag_releasetime']
|
var keysToLookOutFor = ['file_tag_genre1', 'file_tag_genre2', 'file_tag_series', 'file_tag_seriespart', 'file_tag_movement', 'file_tag_movementname', 'file_tag_wwwaudiofile', 'file_tag_contentgroup', 'file_tag_releasetime']
|
||||||
var success = keysToLookOutFor.find(key => !!tags[key])
|
keysToLookOutFor.forEach((key) => {
|
||||||
if (success) {
|
if (tags[key]) {
|
||||||
Logger.debug('Notable!', success)
|
Logger.debug(`Notable! ${key} => ${tags[key]}`)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseProbeData(data) {
|
function parseProbeData(data, verbose = false) {
|
||||||
try {
|
try {
|
||||||
var { format, streams, chapters } = data
|
var { format, streams, chapters } = data
|
||||||
var { format_long_name, duration, size, bit_rate } = format
|
var { format_long_name, duration, size, bit_rate } = format
|
||||||
@@ -191,7 +194,7 @@ function parseProbeData(data) {
|
|||||||
var sizeMb = sizeBytes !== null ? Number((sizeBytes / (1024 * 1024)).toFixed(2)) : null
|
var sizeMb = sizeBytes !== null ? Number((sizeBytes / (1024 * 1024)).toFixed(2)) : null
|
||||||
|
|
||||||
// Logger.debug('Parsing Data for', Path.basename(format.filename))
|
// Logger.debug('Parsing Data for', Path.basename(format.filename))
|
||||||
var tags = parseTags(format)
|
var tags = parseTags(format, verbose)
|
||||||
var cleanedData = {
|
var cleanedData = {
|
||||||
format: format_long_name,
|
format: format_long_name,
|
||||||
duration: !isNaN(duration) ? Number(duration) : null,
|
duration: !isNaN(duration) ? Number(duration) : null,
|
||||||
@@ -200,6 +203,9 @@ function parseProbeData(data) {
|
|||||||
bit_rate: !isNaN(bit_rate) ? Number(bit_rate) : null,
|
bit_rate: !isNaN(bit_rate) ? Number(bit_rate) : null,
|
||||||
...tags
|
...tags
|
||||||
}
|
}
|
||||||
|
if (verbose && format.tags) {
|
||||||
|
cleanedData.rawTags = format.tags
|
||||||
|
}
|
||||||
|
|
||||||
const cleaned_streams = streams.map(s => parseMediaStreamInfo(s, streams, cleanedData.bit_rate))
|
const cleaned_streams = streams.map(s => parseMediaStreamInfo(s, streams, cleanedData.bit_rate))
|
||||||
cleanedData.video_stream = cleaned_streams.find(s => s.type === 'video')
|
cleanedData.video_stream = cleaned_streams.find(s => s.type === 'video')
|
||||||
@@ -223,14 +229,14 @@ function parseProbeData(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function probe(filepath) {
|
function probe(filepath, verbose = false) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
Ffmpeg.ffprobe(filepath, ['-show_chapters'], (err, raw) => {
|
Ffmpeg.ffprobe(filepath, ['-show_chapters'], (err, raw) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
resolve(null)
|
resolve(null)
|
||||||
} else {
|
} else {
|
||||||
resolve(parseProbeData(raw))
|
resolve(parseProbeData(raw, verbose))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+10
-3
@@ -206,9 +206,16 @@ function getAudiobookDataFromDir(folderPath, dir, parseSubtitle = false) {
|
|||||||
|
|
||||||
|
|
||||||
var publishYear = null
|
var publishYear = null
|
||||||
// If Title is of format 1999 - Title, then use 1999 as publish year
|
// OLD regex (not matching parentheses)
|
||||||
var publishYearMatch = title.match(/^([0-9]{4}) - (.+)/)
|
// var publishYearMatch = title.match(/^([0-9]{4}) - (.+)/)
|
||||||
if (publishYearMatch && publishYearMatch.length > 2) {
|
|
||||||
|
// If Title is of format 1999 OR (1999) - Title, then use 1999 as publish year
|
||||||
|
var publishYearMatch = title.match(/^(\(?[0-9]{4}\)?) - (.+)/)
|
||||||
|
if (publishYearMatch && publishYearMatch.length > 2 && publishYearMatch[1]) {
|
||||||
|
// Strip parentheses
|
||||||
|
if (publishYearMatch[1].startsWith('(') && publishYearMatch[1].endsWith(')')) {
|
||||||
|
publishYearMatch[1] = publishYearMatch[1].slice(1, -1)
|
||||||
|
}
|
||||||
if (!isNaN(publishYearMatch[1])) {
|
if (!isNaN(publishYearMatch[1])) {
|
||||||
publishYear = publishYearMatch[1]
|
publishYear = publishYearMatch[1]
|
||||||
title = publishYearMatch[2]
|
title = publishYearMatch[2]
|
||||||
|
|||||||
Reference in New Issue
Block a user