mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Refactor removing author from title candidate
This commit is contained in:
parent
8f5a6b7c95
commit
ee3d3808ef
@ -158,10 +158,7 @@ class BookFinder {
|
|||||||
|
|
||||||
add(title, position = 0) {
|
add(title, position = 0) {
|
||||||
// if title contains the author, remove it
|
// if title contains the author, remove it
|
||||||
if (this.cleanAuthor) {
|
title = this.#removeAuthorFromTitle(title)
|
||||||
const authorRe = new RegExp(`(^| | by |)${escapeRegExp(this.cleanAuthor)}(?= |$)`, "g")
|
|
||||||
title = cleanAuthorForCompares(title).replace(authorRe, '').trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
const titleTransformers = [
|
const titleTransformers = [
|
||||||
[/([,:;_]| by ).*/g, ''], // Remove subtitle
|
[/([,:;_]| by ).*/g, ''], // Remove subtitle
|
||||||
@ -227,6 +224,17 @@ class BookFinder {
|
|||||||
delete(title) {
|
delete(title) {
|
||||||
return this.candidates.delete(title)
|
return this.candidates.delete(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#removeAuthorFromTitle(title) {
|
||||||
|
if (!this.cleanAuthor) return title
|
||||||
|
const authorRe = new RegExp(`(^| | by |)${escapeRegExp(this.cleanAuthor)}(?= |$)`, "g")
|
||||||
|
const authorCleanedTitle = cleanAuthorForCompares(title)
|
||||||
|
const authorCleanedTitleWithoutAuthor = authorCleanedTitle.replace(authorRe, '')
|
||||||
|
if (authorCleanedTitleWithoutAuthor !== authorCleanedTitle) {
|
||||||
|
return authorCleanedTitleWithoutAuthor.trim()
|
||||||
|
}
|
||||||
|
return title
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static AuthorCandidates = class {
|
static AuthorCandidates = class {
|
||||||
|
Loading…
Reference in New Issue
Block a user