mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-08 00:54:33 +01:00
Fix URL encoding, fix download m4b cover art
This commit is contained in:
parent
19dcb6173e
commit
75aede914f
@ -69,7 +69,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...track,
|
...track,
|
||||||
relativePath: trackPath.replace(audiobookPath, '')
|
relativePath: trackPath.replace(audiobookPath, '').replace(/%/g, '%25').replace(/#/g, '%23')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -75,7 +75,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...track,
|
...track,
|
||||||
relativePath: trackPath.replace(audiobookPath, '')
|
relativePath: trackPath.replace(audiobookPath, '').replace(/%/g, '%25').replace(/#/g, '%23')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -163,6 +163,7 @@ export default {
|
|||||||
if (!download || !download.audiobookId) {
|
if (!download || !download.audiobookId) {
|
||||||
return console.error('Invalid download object', download)
|
return console.error('Invalid download object', download)
|
||||||
}
|
}
|
||||||
|
|
||||||
var audiobook = this.$store.getters['audiobooks/getAudiobook'](download.audiobookId)
|
var audiobook = this.$store.getters['audiobooks/getAudiobook'](download.audiobookId)
|
||||||
if (!audiobook) {
|
if (!audiobook) {
|
||||||
return console.error('Audiobook not found for download', download)
|
return console.error('Audiobook not found for download', download)
|
||||||
|
@ -113,6 +113,7 @@ export default {
|
|||||||
console.error('No audiobook...', params.id)
|
console.error('No audiobook...', params.id)
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
}
|
}
|
||||||
|
store.commit('audiobooks/addUpdate', audiobook)
|
||||||
return {
|
return {
|
||||||
audiobook
|
audiobook
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { sort } from '@/assets/fastSort'
|
import { sort } from '@/assets/fastSort'
|
||||||
import { decode } from '@/plugins/init.client'
|
import { decode } from '@/plugins/init.client'
|
||||||
import Path from 'path'
|
|
||||||
|
|
||||||
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']
|
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']
|
||||||
|
|
||||||
@ -138,15 +137,20 @@ export const getters = {
|
|||||||
var bookLastUpdate = book.lastUpdate || Date.now()
|
var bookLastUpdate = book.lastUpdate || Date.now()
|
||||||
var userToken = rootGetters['user/getToken']
|
var userToken = rootGetters['user/getToken']
|
||||||
|
|
||||||
|
cover = cover.replace(/\\/g, '/')
|
||||||
|
|
||||||
// Map old covers to new format /s/book/{bookid}/*
|
// Map old covers to new format /s/book/{bookid}/*
|
||||||
if (cover.startsWith('\\local')) {
|
if (cover.startsWith('/local')) {
|
||||||
cover = cover.replace('local', `s\\book\\${bookItem.id}`)
|
cover = cover.replace('local', `s/book/${bookItem.id}`)
|
||||||
if (cover.includes(bookItem.path + '\\')) { // Remove book path
|
if (cover.includes(bookItem.path + '/')) { // Remove book path
|
||||||
cover = cover.replace(bookItem.path + '\\', '')
|
cover = cover.replace(bookItem.path + '/', '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = new URL(cover, document.baseURI)
|
// Easier to replace these special characters then to encodeUriComponent of the filename
|
||||||
|
var encodedCover = cover.replace(/%/g, '%25').replace(/#/g, '%23')
|
||||||
|
|
||||||
|
var url = new URL(encodedCover, document.baseURI)
|
||||||
return url.href + `?token=${userToken}&ts=${bookLastUpdate}`
|
return url.href + `?token=${userToken}&ts=${bookLastUpdate}`
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
@ -243,6 +247,7 @@ export const mutations = {
|
|||||||
},
|
},
|
||||||
addUpdate(state, audiobook) {
|
addUpdate(state, audiobook) {
|
||||||
if (audiobook.libraryId !== state.loadedLibraryId) {
|
if (audiobook.libraryId !== state.loadedLibraryId) {
|
||||||
|
console.warn('Invalid library', audiobook)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,8 +240,8 @@ class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shouldIncludeCover) {
|
if (shouldIncludeCover) {
|
||||||
var _cover = audiobook.book.cover
|
var _cover = audiobook.book.coverFullPath
|
||||||
if (_cover.startsWith(Path.sep + 'local')) {
|
if (!_cover && audiobook.book.cover && audiobook.book.cover.startsWith(Path.sep + 'local')) {
|
||||||
_cover = Path.join(this.AudiobookPath, _cover.replace(Path.sep + 'local', ''))
|
_cover = Path.join(this.AudiobookPath, _cover.replace(Path.sep + 'local', ''))
|
||||||
Logger.debug('Local cover url', _cover)
|
Logger.debug('Local cover url', _cover)
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,7 @@ class Server {
|
|||||||
var folder = library.folders.find(fol => fol.id === req.params.folder)
|
var folder = library.folders.find(fol => fol.id === req.params.folder)
|
||||||
if (!folder) return res.status(404).send('Folder not found')
|
if (!folder) return res.status(404).send('Folder not found')
|
||||||
|
|
||||||
var remainingPath = decodeURIComponent(req.params['0'])
|
var remainingPath = req.params['0']
|
||||||
|
|
||||||
var fullPath = Path.join(folder.fullPath, remainingPath)
|
var fullPath = Path.join(folder.fullPath, remainingPath)
|
||||||
res.sendFile(fullPath)
|
res.sendFile(fullPath)
|
||||||
})
|
})
|
||||||
@ -151,8 +150,7 @@ class Server {
|
|||||||
var audiobook = this.audiobooks.find(ab => ab.id === req.params.id)
|
var audiobook = this.audiobooks.find(ab => ab.id === req.params.id)
|
||||||
if (!audiobook) return res.status(404).send('Book not found with id ' + req.params.id)
|
if (!audiobook) return res.status(404).send('Book not found with id ' + req.params.id)
|
||||||
|
|
||||||
var remainingPath = decodeURIComponent(req.params['0'])
|
var remainingPath = req.params['0']
|
||||||
|
|
||||||
var fullPath = Path.join(audiobook.fullPath, remainingPath)
|
var fullPath = Path.join(audiobook.fullPath, remainingPath)
|
||||||
res.sendFile(fullPath)
|
res.sendFile(fullPath)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user