mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Parse and update author name on each update
This commit is contained in:
parent
6e8270c5ea
commit
0c1a29adbf
@ -115,6 +115,9 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async submitForm() {
|
||||
if (this.isProcessing) {
|
||||
return
|
||||
}
|
||||
this.isProcessing = true
|
||||
const updatePayload = {
|
||||
book: this.details,
|
||||
|
@ -10,6 +10,10 @@ export default {
|
||||
text: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
direction: {
|
||||
type: String,
|
||||
default: 'right'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -21,11 +25,17 @@ export default {
|
||||
methods: {
|
||||
createTooltip() {
|
||||
var boxChow = this.$refs.box.getBoundingClientRect()
|
||||
var top = boxChow.top
|
||||
var left = boxChow.left + boxChow.width + 4
|
||||
|
||||
var top = 0
|
||||
var left = 0
|
||||
if (this.direction === 'right') {
|
||||
top = boxChow.top
|
||||
left = boxChow.left + boxChow.width + 4
|
||||
} else if (this.direction === 'bottom') {
|
||||
top = boxChow.top + boxChow.height + 4
|
||||
left = boxChow.left
|
||||
}
|
||||
var tooltip = document.createElement('div')
|
||||
tooltip.className = 'absolute px-2 bg-black bg-opacity-60 py-1 text-white pointer-events-none text-xs'
|
||||
tooltip.className = 'absolute px-2 bg-black bg-opacity-90 py-1 text-white pointer-events-none text-xs rounded shadow-lg'
|
||||
tooltip.style.top = top + 'px'
|
||||
tooltip.style.left = left + 'px'
|
||||
tooltip.style.zIndex = 100
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "audiobookshelf-client",
|
||||
"version": "0.9.74-beta",
|
||||
"version": "0.9.75-beta",
|
||||
"description": "Audiobook manager and player",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -13,7 +13,9 @@
|
||||
<div class="mb-2">
|
||||
<h1 class="text-2xl font-book leading-7">{{ title }}</h1>
|
||||
<h3 v-if="series" class="font-book text-gray-300 text-lg leading-7">{{ seriesText }}</h3>
|
||||
<p class="text-sm text-gray-100 leading-7">by {{ author }}</p>
|
||||
<ui-tooltip :text="authorTooltipText" direction="bottom">
|
||||
<p class="text-sm text-gray-100 leading-7">by {{ author }}</p>
|
||||
</ui-tooltip>
|
||||
</div>
|
||||
<div class="flex-grow" />
|
||||
</div>
|
||||
@ -137,6 +139,16 @@ export default {
|
||||
author() {
|
||||
return this.book.author || 'Unknown'
|
||||
},
|
||||
authorFL() {
|
||||
return this.book.authorFL
|
||||
},
|
||||
authorLF() {
|
||||
return this.book.authorLF
|
||||
},
|
||||
authorTooltipText() {
|
||||
var txt = ['FL: ' + this.authorFL || 'Not Set', 'LF: ' + this.authorLF || 'Not Set']
|
||||
return txt.join('\n')
|
||||
},
|
||||
series() {
|
||||
return this.book.series || null
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "audiobookshelf",
|
||||
"version": "0.9.74-beta",
|
||||
"version": "0.9.75-beta",
|
||||
"description": "Self-hosted audiobook server for managing and playing audiobooks.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -310,10 +310,6 @@ class Audiobook {
|
||||
return hasUpdates
|
||||
}
|
||||
|
||||
syncAuthorNames(audiobookData) {
|
||||
return this.book.syncAuthorNames(audiobookData.authorFL, audiobookData.authorLF)
|
||||
}
|
||||
|
||||
isSearchMatch(search) {
|
||||
return this.book.isSearchMatch(search.toLowerCase().trim())
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
const Path = require('path')
|
||||
const Logger = require('./Logger')
|
||||
const parseAuthors = require('./utils/parseAuthors')
|
||||
class Book {
|
||||
constructor(book = null) {
|
||||
this.olid = null
|
||||
@ -55,12 +57,29 @@ class Book {
|
||||
}
|
||||
}
|
||||
|
||||
setParseAuthor(author) {
|
||||
if (!author) {
|
||||
var hasUpdated = this.authorFL || this.authorLF
|
||||
this.authorFL = null
|
||||
this.authorLF = null
|
||||
return hasUpdated
|
||||
}
|
||||
try {
|
||||
var { authorLF, authorFL } = parseAuthors(author)
|
||||
var hasUpdated = authorLF !== this.authorLF || authorFL !== this.authorFL
|
||||
this.authorFL = authorFL || null
|
||||
this.authorLF = authorLF || null
|
||||
return hasUpdated
|
||||
} catch (err) {
|
||||
Logger.error('[Book] Parse authors failed', err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
setData(data) {
|
||||
this.olid = data.olid || null
|
||||
this.title = data.title || null
|
||||
this.author = data.author || null
|
||||
this.authorLF = data.authorLF || null
|
||||
this.authorFL = data.authorFL || null
|
||||
this.series = data.series || null
|
||||
this.volumeNumber = data.volumeNumber || null
|
||||
this.publishYear = data.publishYear || null
|
||||
@ -68,6 +87,10 @@ class Book {
|
||||
this.cover = data.cover || null
|
||||
this.genres = data.genres || []
|
||||
|
||||
if (data.author) {
|
||||
this.setParseAuthor(this.author)
|
||||
}
|
||||
|
||||
// Use first image file as cover
|
||||
if (data.otherFiles && data.otherFiles.length) {
|
||||
var imageFile = data.otherFiles.find(f => f.filetype === 'image')
|
||||
@ -90,6 +113,14 @@ class Book {
|
||||
this.genres = payload['genres']
|
||||
hasUpdates = true
|
||||
}
|
||||
} else if (key === 'author') {
|
||||
if (this.author !== payload.author) {
|
||||
this.author = payload.author || null
|
||||
hasUpdates = true
|
||||
}
|
||||
if (this.setParseAuthor(this.author)) {
|
||||
hasUpdates = true
|
||||
}
|
||||
} else if (this[key] !== undefined && payload[key] !== this[key]) {
|
||||
this[key] = payload[key]
|
||||
hasUpdates = true
|
||||
@ -98,19 +129,6 @@ class Book {
|
||||
return hasUpdates
|
||||
}
|
||||
|
||||
syncAuthorNames(authorFL, authorLF) {
|
||||
var hasUpdates = false
|
||||
if (authorFL !== this.authorFL) {
|
||||
this.authorFL = authorFL
|
||||
hasUpdates = true
|
||||
}
|
||||
if (authorLF !== this.authorLF) {
|
||||
this.authorLF = authorLF
|
||||
hasUpdates = true
|
||||
}
|
||||
return hasUpdates
|
||||
}
|
||||
|
||||
isSearchMatch(search) {
|
||||
return this._title.toLowerCase().includes(search) || this._author.toLowerCase().includes(search) || this._series.toLowerCase().includes(search)
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
const Path = require('path')
|
||||
const Logger = require('./Logger')
|
||||
const BookFinder = require('./BookFinder')
|
||||
const Audiobook = require('./Audiobook')
|
||||
@ -120,11 +119,6 @@ class Scanner {
|
||||
hasUpdates = true
|
||||
}
|
||||
|
||||
if (audiobookData.author && existingAudiobook.syncAuthorNames(audiobookData)) {
|
||||
Logger.info(`[Scanner] "${existingAudiobook.title}" author names updated, "${existingAudiobook.authorLF}"`)
|
||||
hasUpdates = true
|
||||
}
|
||||
|
||||
if (hasUpdates) {
|
||||
Logger.info(`[Scanner] "${existingAudiobook.title}" was updated - saving`)
|
||||
existingAudiobook.lastUpdate = Date.now()
|
||||
|
@ -1,7 +1,6 @@
|
||||
const Path = require('path')
|
||||
const dir = require('node-dir')
|
||||
const Logger = require('../Logger')
|
||||
const parseAuthors = require('./parseAuthors')
|
||||
const { cleanString } = require('./index')
|
||||
|
||||
const AUDIOBOOK_PARTS_FORMATS = ['m4b', 'mp3']
|
||||
@ -75,14 +74,6 @@ async function getAllAudiobookFiles(abRootPath) {
|
||||
parts: [],
|
||||
otherFiles: []
|
||||
}
|
||||
if (author) {
|
||||
var parsedAuthors = parseAuthors(author)
|
||||
if (parsedAuthors) {
|
||||
var { authorLF, authorFL } = parsedAuthors
|
||||
audiobooks[path].authorLF = authorLF || null
|
||||
audiobooks[path].authorFL = authorFL || null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var filetype = getFileType(pathformat.ext)
|
||||
|
Loading…
Reference in New Issue
Block a user