mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Fix:Comic reader for comics that have subfolders containing images #811
This commit is contained in:
parent
40384dd442
commit
ac46548c4d
@ -53,6 +53,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Path from 'path'
|
import Path from 'path'
|
||||||
import { Archive } from 'libarchive.js/main.js'
|
import { Archive } from 'libarchive.js/main.js'
|
||||||
|
import { CompressedFile } from 'libarchive.js/src/compressed-file'
|
||||||
|
|
||||||
Archive.init({
|
Archive.init({
|
||||||
workerUrl: '/libarchive/worker-bundle.js'
|
workerUrl: '/libarchive/worker-bundle.js'
|
||||||
@ -150,7 +151,11 @@ export default {
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
const archive = await Archive.open(buff)
|
const archive = await Archive.open(buff)
|
||||||
this.filesObject = await archive.getFilesObject()
|
const originalFilesObject = await archive.getFilesObject()
|
||||||
|
// to support images in subfolders we need to flatten the object
|
||||||
|
// ref: https://github.com/advplyr/audiobookshelf/issues/811
|
||||||
|
this.filesObject = this.flattenFilesObject(originalFilesObject)
|
||||||
|
console.log('Extracted files object', this.filesObject)
|
||||||
var filenames = Object.keys(this.filesObject)
|
var filenames = Object.keys(this.filesObject)
|
||||||
this.parseFilenames(filenames)
|
this.parseFilenames(filenames)
|
||||||
|
|
||||||
@ -168,6 +173,26 @@ export default {
|
|||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
flattenFilesObject(filesObject) {
|
||||||
|
const flattenObject = (obj, prefix = '') => {
|
||||||
|
var _obj = {}
|
||||||
|
for (const key in obj) {
|
||||||
|
const newKey = prefix ? prefix + '/' + key : key
|
||||||
|
if (obj[key] instanceof CompressedFile) {
|
||||||
|
_obj[newKey] = obj[key]
|
||||||
|
} else if (!key.startsWith('_') && typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
|
||||||
|
_obj = {
|
||||||
|
..._obj,
|
||||||
|
...flattenObject(obj[key], newKey)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_obj[newKey] = obj[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _obj
|
||||||
|
}
|
||||||
|
return flattenObject(filesObject)
|
||||||
|
},
|
||||||
async extractXmlFile(filename) {
|
async extractXmlFile(filename) {
|
||||||
console.log('extracting xml filename', filename)
|
console.log('extracting xml filename', filename)
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user