mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-28 09:38:56 +01:00
Add volume number parsing to scanner
This commit is contained in:
parent
80e2e35dcd
commit
07994d38d5
@ -315,7 +315,6 @@ export default {
|
|||||||
this.bufferTrackWidth = bufferlen
|
this.bufferTrackWidth = bufferlen
|
||||||
},
|
},
|
||||||
timeupdate() {
|
timeupdate() {
|
||||||
// console.log('Time update', this.audioEl.currentTime)
|
|
||||||
if (!this.$refs.playedTrack) {
|
if (!this.$refs.playedTrack) {
|
||||||
console.error('Invalid no played track ref')
|
console.error('Invalid no played track ref')
|
||||||
return
|
return
|
||||||
|
@ -60,10 +60,8 @@ export const mutations = {
|
|||||||
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)
|
||||||
console.log('setUser', user.username)
|
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem('token')
|
localStorage.removeItem('token')
|
||||||
console.warn('setUser cleared')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setSettings(state, settings) {
|
setSettings(state, settings) {
|
||||||
|
@ -151,7 +151,7 @@ class Book {
|
|||||||
// If audiobook directory path was changed, check and update properties set from dirnames
|
// If audiobook directory path was changed, check and update properties set from dirnames
|
||||||
// May be worthwhile checking if these were manually updated and not override manual updates
|
// May be worthwhile checking if these were manually updated and not override manual updates
|
||||||
syncPathsUpdated(audiobookData) {
|
syncPathsUpdated(audiobookData) {
|
||||||
var keysToSync = ['author', 'title', 'series', 'publishYear']
|
var keysToSync = ['author', 'title', 'series', 'publishYear', 'volumeNumber']
|
||||||
var syncPayload = {}
|
var syncPayload = {}
|
||||||
keysToSync.forEach((key) => {
|
keysToSync.forEach((key) => {
|
||||||
if (audiobookData[key]) syncPayload[key] = audiobookData[key]
|
if (audiobookData[key]) syncPayload[key] = audiobookData[key]
|
||||||
|
@ -171,13 +171,11 @@ class Stream extends EventEmitter {
|
|||||||
this.furthestSegmentCreated = lastSegment
|
this.furthestSegmentCreated = lastSegment
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('SORT', [...this.segmentsCreated].slice(0, 200).join(', '), segments.slice(0, 200).join(', '))
|
|
||||||
segments.forEach((seg) => {
|
segments.forEach((seg) => {
|
||||||
if (!current_chunk.length || last_seg_in_chunk + 1 === seg) {
|
if (!current_chunk.length || last_seg_in_chunk + 1 === seg) {
|
||||||
last_seg_in_chunk = seg
|
last_seg_in_chunk = seg
|
||||||
current_chunk.push(seg)
|
current_chunk.push(seg)
|
||||||
} else {
|
} else {
|
||||||
// console.log('Last Seg is not equal to - 1', last_seg_in_chunk, seg)
|
|
||||||
if (current_chunk.length === 1) chunks.push(current_chunk[0])
|
if (current_chunk.length === 1) chunks.push(current_chunk[0])
|
||||||
else chunks.push(`${current_chunk[0]}-${current_chunk[current_chunk.length - 1]}`)
|
else chunks.push(`${current_chunk[0]}-${current_chunk[current_chunk.length - 1]}`)
|
||||||
last_seg_in_chunk = seg
|
last_seg_in_chunk = seg
|
||||||
|
@ -155,10 +155,8 @@ function getAudiobookDataFromDir(abRootPath, dir, parseSubtitle = false) {
|
|||||||
// If there are at least 2 more directories, next furthest will be the series
|
// If there are at least 2 more directories, next furthest will be the series
|
||||||
if (splitDir.length > 1) series = splitDir.pop()
|
if (splitDir.length > 1) series = splitDir.pop()
|
||||||
if (splitDir.length > 0) author = splitDir.pop()
|
if (splitDir.length > 0) author = splitDir.pop()
|
||||||
|
|
||||||
// There could be many more directories, but only the top 3 are used for naming /author/series/title/
|
// There could be many more directories, but only the top 3 are used for naming /author/series/title/
|
||||||
|
|
||||||
|
|
||||||
var publishYear = null
|
var publishYear = null
|
||||||
// If Title is of format 1999 - Title, then use 1999 as publish year
|
// If Title is of format 1999 - Title, then use 1999 as publish year
|
||||||
var publishYearMatch = title.match(/^([0-9]{4}) - (.+)/)
|
var publishYearMatch = title.match(/^([0-9]{4}) - (.+)/)
|
||||||
@ -169,7 +167,37 @@ function getAudiobookDataFromDir(abRootPath, dir, parseSubtitle = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If in a series directory check for volume number match
|
||||||
|
/* ACCEPTS:
|
||||||
|
Book 2 - Title Here - Subtitle Here
|
||||||
|
Title Here - Subtitle Here - Vol 12
|
||||||
|
Title Here - volume 9 - Subtitle Here
|
||||||
|
Vol. 3 Title Here - Subtitle Here
|
||||||
|
1980 - Book 2-Title Here
|
||||||
|
Title Here-Volume 999-Subtitle Here
|
||||||
|
*/
|
||||||
|
var volumeNumber = null
|
||||||
|
if (series) {
|
||||||
|
var volumeMatch = title.match(/(-(?: ?))?\b((?:Book|Vol.?|Volume) \b(\d{1,3}))((?: ?)-)?/i)
|
||||||
|
if (volumeMatch && volumeMatch.length > 3 && volumeMatch[2] && volumeMatch[3]) {
|
||||||
|
volumeNumber = volumeMatch[3]
|
||||||
|
var replaceChunk = volumeMatch[2]
|
||||||
|
|
||||||
|
// "1980 - Book 2-Title Here"
|
||||||
|
// Group 1 would be "- "
|
||||||
|
// Group 3 would be "-"
|
||||||
|
// Only remove the first group
|
||||||
|
if (volumeMatch[1]) {
|
||||||
|
replaceChunk = volumeMatch[1] + replaceChunk
|
||||||
|
} else if (volumeMatch[4]) {
|
||||||
|
replaceChunk += volumeMatch[4]
|
||||||
|
}
|
||||||
|
title = title.replace(replaceChunk, '').trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Subtitle can be parsed from the title if user enabled
|
// Subtitle can be parsed from the title if user enabled
|
||||||
|
// Subtitle is everything after " - "
|
||||||
var subtitle = null
|
var subtitle = null
|
||||||
if (parseSubtitle && title.includes(' - ')) {
|
if (parseSubtitle && title.includes(' - ')) {
|
||||||
var splitOnSubtitle = title.split(' - ')
|
var splitOnSubtitle = title.split(' - ')
|
||||||
@ -182,6 +210,7 @@ function getAudiobookDataFromDir(abRootPath, dir, parseSubtitle = false) {
|
|||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
series,
|
series,
|
||||||
|
volumeNumber,
|
||||||
publishYear,
|
publishYear,
|
||||||
path: dir, // relative audiobook path i.e. /Author Name/Book Name/..
|
path: dir, // relative audiobook path i.e. /Author Name/Book Name/..
|
||||||
fullPath: Path.join(abRootPath, dir) // i.e. /audiobook/Author Name/Book Name/..
|
fullPath: Path.join(abRootPath, dir) // i.e. /audiobook/Author Name/Book Name/..
|
||||||
|
Loading…
Reference in New Issue
Block a user