Add:Language and ASIN id3 tag parse, language filter, asin search, asin audible match, add fields to details #305

This commit is contained in:
advplyr 2022-01-09 18:37:16 -06:00
parent afd2b8c98f
commit b284a9bd57
13 changed files with 128 additions and 27 deletions

View file

@ -18,6 +18,8 @@ class AudioFileMetadata {
this.tagEncoder = null
this.tagEncodedBy = null
this.tagIsbn = null
this.tagLanguage = null
this.tagASIN = null
if (metadata) {
this.construct(metadata)
@ -54,6 +56,8 @@ class AudioFileMetadata {
this.tagEncoder = metadata.tagEncoder || null
this.tagEncodedBy = metadata.tagEncodedBy || null
this.tagIsbn = metadata.tagIsbn || null
this.tagLanguage = metadata.tagLanguage || null
this.tagASIN = metadata.tagASIN || null
}
// Data parsed in prober.js
@ -76,6 +80,8 @@ class AudioFileMetadata {
this.tagEncoder = payload.file_tag_encoder || null
this.tagEncodedBy = payload.file_tag_encodedby || null
this.tagIsbn = payload.file_tag_isbn || null
this.tagLanguage = payload.file_tag_language || null
this.tagASIN = payload.file_tag_asin || null
}
updateData(payload) {
@ -97,7 +103,9 @@ class AudioFileMetadata {
tagDescription: payload.file_tag_description || null,
tagEncoder: payload.file_tag_encoder || null,
tagEncodedBy: payload.file_tag_encodedby || null,
tagIsbn: payload.file_tag_isbn || nulll
tagIsbn: payload.file_tag_isbn || null,
tagLanguage: payload.file_tag_language || null,
tagASIN: payload.file_tag_asin || null
}
var hasUpdates = false

View file

@ -18,7 +18,8 @@ class Book {
this.publisher = null
this.description = null
this.isbn = null
this.langauge = null
this.asin = null
this.language = null
this.cover = null
this.coverFullPath = null
this.genres = []
@ -43,7 +44,9 @@ class Book {
get _authorsList() { return this._author.split(', ') }
get _narratorsList() { return this._narrator.split(', ') }
get _genres() { return this.genres || [] }
get _isbn() { return this.isbn || '' }
get _language() { return this.language || '' }
get _isbn() { return this.isbn || '' }
get _asin() { return this.asin || '' }
get shouldSearchForCover() {
if (this.cover) return false
@ -67,6 +70,7 @@ class Book {
this.publisher = book.publisher
this.description = book.description
this.isbn = book.isbn || null
this.asin = book.asin || null
this.language = book.language || null
this.cover = book.cover
this.coverFullPath = book.coverFullPath || null
@ -98,6 +102,7 @@ class Book {
publisher: this.publisher,
description: this.description,
isbn: this.isbn,
asin: this.asin,
language: this.language,
cover: this.cover,
coverFullPath: this.coverFullPath,
@ -156,6 +161,7 @@ class Book {
this.publishYear = data.publishYear || null
this.description = data.description || null
this.isbn = data.isbn || null
this.asin = data.asin || null
this.language = data.language || null
this.cover = data.cover || null
this.coverFullPath = data.coverFullPath || null
@ -283,7 +289,9 @@ class Book {
// ISBN match has to be exact to prevent isbn matches to flood results. Remove dashes since isbn might have those
var isbnMatch = this._isbn.toLowerCase().replace(/-/g, '') === search.replace(/-/g, '')
var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : isbnMatch ? 'isbn' : false
var asinMatch = this._asin.toLowerCase() === search
var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : isbnMatch ? 'isbn' : asinMatch ? 'asin' : false
var bookMatchText = bookMatchKey ? this[bookMatchKey] : ''
return {
@ -352,6 +360,14 @@ class Book {
{
tag: 'tagIsbn',
key: 'isbn'
},
{
tag: 'tagLanguage',
key: 'language'
},
{
tag: 'tagASIN',
key: 'asin'
}
]

View file

@ -127,8 +127,6 @@ class AudioFileScanner {
discsFromMeta.sort((a, b) => a - b)
tracksFromFilename.sort((a, b) => a - b)
tracksFromMeta.sort((a, b) => a - b)
console.log('AB DISCS', audiobook.title, discsFromFilename, discsFromMeta)
console.log('AB TRACKS', audiobook.title, tracksFromFilename, tracksFromMeta)
var discKey = null
if (discsFromMeta.length === audioFiles.length && this.isSequential(discsFromMeta)) {

View file

@ -11,7 +11,7 @@ module.exports = {
getFiltered(audiobooks, filterBy, user) {
var filtered = audiobooks
var searchGroups = ['genres', 'tags', 'series', 'authors', 'progress', 'narrators']
var searchGroups = ['genres', 'tags', 'series', 'authors', 'progress', 'narrators', 'languages']
var group = searchGroups.find(_group => filterBy.startsWith(_group + '.'))
if (group) {
var filterVal = filterBy.replace(`${group}.`, '')
@ -33,6 +33,8 @@ module.exports = {
if (filter === 'In Progress' && (userAudiobook && !userAudiobook.isRead && userAudiobook.progress > 0)) return true
return false
})
} else if (group === 'languages') {
filtered = filtered.filter(ab => ab.book && ab.book.language === filter)
}
} else if (filterBy === 'issues') {
filtered = filtered.filter(ab => {
@ -49,7 +51,8 @@ module.exports = {
genres: [],
tags: [],
series: [],
narrators: []
narrators: [],
languages: []
}
audiobooks.forEach((ab) => {
if (ab.book._authorsList.length) {
@ -73,12 +76,14 @@ module.exports = {
if (narrator && !data.narrators.includes(narrator)) data.narrators.push(narrator)
})
}
if (ab.book._language && !data.languages.includes(ab.book._language)) data.languages.push(ab.book._language)
})
data.authors = naturalSort(data.authors).asc()
data.genres = naturalSort(data.genres).asc()
data.tags = naturalSort(data.tags).asc()
data.series = naturalSort(data.series).asc()
data.narrators = naturalSort(data.narrators).asc()
data.languages = naturalSort(data.languages).asc()
return data
},

View file

@ -165,6 +165,8 @@ function parseTags(format, verbose) {
file_tag_series: tryGrabTag(format, 'series'),
file_tag_seriespart: tryGrabTag(format, 'series-part'),
file_tag_isbn: tryGrabTag(format, 'isbn'),
file_tag_language: tryGrabTab(format, 'language', 'lang'),
file_tag_asin: tryGrabTag(format, 'asin'),
// Not sure if these are actually used yet or not
file_tag_creation_time: tryGrabTag(format, 'creation_time'),