mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-13 13:49:40 +00:00
added podcast support
This commit is contained in:
parent
7e4d0daf82
commit
4b91a7e3f9
3 changed files with 9 additions and 10 deletions
|
|
@ -364,7 +364,11 @@ export default {
|
||||||
const containsAudio = item.files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1)))
|
const containsAudio = item.files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1)))
|
||||||
|
|
||||||
const exists = await this.$axios
|
const exists = await this.$axios
|
||||||
.$post(`/api/filesystem/pathexists`, { directory: item.directory, folderPath: this.selectedFolder.fullPath, filenames: item.files.map((f) => f.name), allowBookFiles: !containsBook, allowAudioFiles: !containsAudio })
|
.$post(`/api/filesystem/pathexists`, { directory: item.directory, folderPath: this.selectedFolder.fullPath, filenames: item.files.map((f) => f.name),
|
||||||
|
...(this.selectedLibrary.mediaType === 'podcast'
|
||||||
|
? { allowBookFiles: !containsBook, allowAudioFiles: true }
|
||||||
|
: { allowBookFiles: !containsBook, allowAudioFiles: !containsAudio })
|
||||||
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.exists) {
|
if (data.exists) {
|
||||||
if (data.libraryItemTitle) {
|
if (data.libraryItemTitle) {
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,8 @@ class MiscController {
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = Object.values(req.files)
|
const files = Object.values(req.files)
|
||||||
// If allowAdditionalFiles is true, the upload endpoint allows adding items even if the type of file already exists in the library.
|
|
||||||
// If allowOverwrite is true, it will allow overwriting existing files.
|
// If allowOverwrite is true, it will allow overwriting existing files.
|
||||||
let { title, author, series, folder: folderId, library: libraryId, allowAdditionalFiles, allowOverwrite } = req.body
|
let { title, author, series, folder: folderId, library: libraryId, allowOverwrite } = req.body
|
||||||
// Validate request body
|
// Validate request body
|
||||||
if (!libraryId || !folderId || typeof libraryId !== 'string' || typeof folderId !== 'string' || !title || typeof title !== 'string') {
|
if (!libraryId || !folderId || typeof libraryId !== 'string' || typeof folderId !== 'string' || !title || typeof title !== 'string') {
|
||||||
return res.status(400).send('Invalid request body')
|
return res.status(400).send('Invalid request body')
|
||||||
|
|
@ -82,10 +81,10 @@ class MiscController {
|
||||||
const outputDirectory = Path.join(...[folder.path, ...cleanedOutputDirectoryParts])
|
const outputDirectory = Path.join(...[folder.path, ...cleanedOutputDirectoryParts])
|
||||||
|
|
||||||
if (allowOverwrite === undefined || allowOverwrite === null || !allowOverwrite) {
|
if (allowOverwrite === undefined || allowOverwrite === null || !allowOverwrite) {
|
||||||
const containsBook = allowAdditionalFiles || files.some(file => globals.SupportedEbookTypes.includes(Path.extname(file.name).toLowerCase().slice(1)))
|
const containsBook = files.some(file => globals.SupportedEbookTypes.includes(Path.extname(file.name).toLowerCase().slice(1)))
|
||||||
const containsAudio = allowAdditionalFiles || files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1)))
|
const containsAudio = files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1)))
|
||||||
|
|
||||||
if ((await validatePathExists(folder, outputDirectory, files.map((f) => f.name), !containsBook, !containsAudio, true)).exists) {
|
if ((await validatePathExists(folder, outputDirectory, files.map((f) => f.name), !containsBook, library.mediaType === 'podcast' || !containsAudio, true)).exists) {
|
||||||
Logger.error(`Upload path already exists: ${outputDirectory}`)
|
Logger.error(`Upload path already exists: ${outputDirectory}`)
|
||||||
return res.status(400).send('Uploaded file already exists')
|
return res.status(400).send('Uploaded file already exists')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -630,10 +630,6 @@ module.exports.validatePathExists = async function validatePathExists(
|
||||||
if (hasRestrictedFiles) {
|
if (hasRestrictedFiles) {
|
||||||
return { exists: true };
|
return { exists: true };
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
exists: true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue