mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-26 13:51:16 +02:00
added podcast support
This commit is contained in:
parent
7e4d0daf82
commit
4b91a7e3f9
@ -364,7 +364,11 @@ export default {
|
||||
const containsAudio = item.files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1)))
|
||||
|
||||
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) => {
|
||||
if (data.exists) {
|
||||
if (data.libraryItemTitle) {
|
||||
|
@ -44,9 +44,8 @@ class MiscController {
|
||||
}
|
||||
|
||||
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.
|
||||
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
|
||||
if (!libraryId || !folderId || typeof libraryId !== 'string' || typeof folderId !== 'string' || !title || typeof title !== 'string') {
|
||||
return res.status(400).send('Invalid request body')
|
||||
@ -82,10 +81,10 @@ class MiscController {
|
||||
const outputDirectory = Path.join(...[folder.path, ...cleanedOutputDirectoryParts])
|
||||
|
||||
if (allowOverwrite === undefined || allowOverwrite === null || !allowOverwrite) {
|
||||
const containsBook = allowAdditionalFiles || 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 containsBook = files.some(file => globals.SupportedEbookTypes.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}`)
|
||||
return res.status(400).send('Uploaded file already exists')
|
||||
}
|
||||
|
@ -630,10 +630,6 @@ module.exports.validatePathExists = async function validatePathExists(
|
||||
if (hasRestrictedFiles) {
|
||||
return { exists: true };
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
exists: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user