Clean and parse author name from directory, sort by author last name, scan for covers

This commit is contained in:
Mark Cooper 2021-08-24 20:24:40 -05:00
parent 9300a0bfb6
commit e230cb47e8
28 changed files with 783 additions and 59 deletions

View file

@ -1,4 +1,5 @@
import { sort } from '@/assets/fastSort'
import { cleanFilterString } from '@/plugins/init.client'
const STANDARD_GENRES = ['adventure', 'autobiography', 'biography', 'childrens', 'comedy', 'crime', 'dystopian', 'fantasy', 'fiction', 'health', 'history', 'horror', 'mystery', 'new_adult', 'nonfiction', 'philosophy', 'politics', 'religion', 'romance', 'sci-fi', 'self-help', 'short_story', 'technology', 'thriller', 'true_crime', 'western', 'young_adult']
@ -16,13 +17,14 @@ export const getters = {
var settings = rootState.user.settings || {}
var filterBy = settings.filterBy || ''
var searchGroups = ['genres', 'tags', 'series']
var searchGroups = ['genres', 'tags', 'series', 'authors']
var group = searchGroups.find(_group => filterBy.startsWith(_group + '.'))
if (group) {
var filter = filterBy.replace(`${group}.`, '')
if (group === 'genres') filtered = filtered.filter(ab => ab.book && ab.book.genres.includes(filter))
else if (group === 'tags') filtered = filtered.filter(ab => ab.tags.includes(filter))
else if (group === 'series') filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.author === filter)
}
return filtered
},
@ -35,6 +37,10 @@ export const getters = {
// Supports dot notation strings i.e. "book.title"
return settings.orderBy.split('.').reduce((a, b) => a[b], ab)
})
},
getUniqueAuthors: (state) => {
var _authors = state.audiobooks.filter(ab => !!(ab.book && ab.book.author)).map(ab => ab.book.author)
return [...new Set(_authors)]
}
}

View file

@ -5,7 +5,9 @@ export const state = () => ({
selectedAudiobook: null,
playOnLoad: false,
isScanning: false,
isScanningCovers: false,
scanProgress: null,
coverScanProgress: null,
developerMode: false
})
@ -41,9 +43,16 @@ export const mutations = {
setIsScanning(state, isScanning) {
state.isScanning = isScanning
},
setScanProgress(state, progress) {
if (progress > 0) state.isScanning = true
state.scanProgress = progress
setScanProgress(state, scanProgress) {
if (scanProgress && scanProgress.progress > 0) state.isScanning = true
state.scanProgress = scanProgress
},
setIsScanningCovers(state, isScanningCovers) {
state.isScanningCovers = isScanningCovers
},
setCoverScanProgress(state, coverScanProgress) {
if (coverScanProgress && coverScanProgress.progress > 0) state.isScanningCovers = true
state.coverScanProgress = coverScanProgress
},
setDeveloperMode(state, val) {
state.developerMode = val