mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-14 15:59:38 +00:00
Fix library check path and set provider, update podcast model and UI
This commit is contained in:
parent
deadc63dbb
commit
43bbfbfee3
8 changed files with 130 additions and 27 deletions
|
|
@ -19,6 +19,24 @@ class LibraryController {
|
|||
return res.status(500).send('Invalid request')
|
||||
}
|
||||
|
||||
// Validate folder paths exist or can be created & resolve rel paths
|
||||
// returns 400 if a folder fails to access
|
||||
newLibraryPayload.folders = newLibraryPayload.folders.map(f => {
|
||||
f.fullPath = Path.resolve(f.fullPath)
|
||||
return f
|
||||
})
|
||||
for (var folder of newLibraryPayload.folders) {
|
||||
var success = await fs.ensureDir(folder.fullPath).then(() => true).catch((error) => {
|
||||
Logger.error(`[LibraryController] Failed to ensure folder dir "${folder.fullPath}"`, error)
|
||||
return false
|
||||
})
|
||||
if (!success) {
|
||||
return res.status(400).send(`Invalid folder directory "${folder.fullPath}"`)
|
||||
} else {
|
||||
await filePerms.setDefault(folder.fullPath)
|
||||
}
|
||||
}
|
||||
|
||||
var library = new Library()
|
||||
newLibraryPayload.displayOrder = this.db.libraries.length + 1
|
||||
library.setData(newLibraryPayload)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ class Library {
|
|||
this.displayOrder = data.displayOrder || 1
|
||||
this.icon = data.icon || 'database'
|
||||
this.mediaType = data.mediaType || 'book'
|
||||
this.provider = data.provider || 'google'
|
||||
this.disableWatcher = !!data.disableWatcher
|
||||
this.createdAt = Date.now()
|
||||
this.lastUpdate = Date.now()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ class PodcastEpisode {
|
|||
this.podcastId = null
|
||||
this.episodeNumber = null
|
||||
|
||||
this.title = null
|
||||
this.description = null
|
||||
this.enclosure = null
|
||||
this.pubDate = null
|
||||
|
||||
this.audioFile = null
|
||||
this.addedAt = null
|
||||
this.updatedAt = null
|
||||
|
|
@ -22,6 +27,10 @@ class PodcastEpisode {
|
|||
this.index = episode.index
|
||||
this.podcastId = episode.podcastId
|
||||
this.episodeNumber = episode.episodeNumber
|
||||
this.title = episode.title
|
||||
this.description = episode.description
|
||||
this.enclosure = episode.enclosure ? { ...episode.enclosure } : null
|
||||
this.pubDate = episode.pubDate
|
||||
this.audioFile = new AudioFile(episode.audioFile)
|
||||
this.addedAt = episode.addedAt
|
||||
this.updatedAt = episode.updatedAt
|
||||
|
|
@ -33,6 +42,10 @@ class PodcastEpisode {
|
|||
index: this.index,
|
||||
podcastId: this.podcastId,
|
||||
episodeNumber: this.episodeNumber,
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
enclosure: this.enclosure ? { ...this.enclosure } : null,
|
||||
pubDate: this.pubDate,
|
||||
audioFile: this.audioFile.toJSON(),
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ class PodcastMetadata {
|
|||
this.releaseDate = null
|
||||
this.genres = []
|
||||
this.feedUrl = null
|
||||
this.feedImageUrl = null
|
||||
this.imageUrl = null
|
||||
this.itunesPageUrl = null
|
||||
this.itunesId = null
|
||||
this.itunesArtistId = null
|
||||
this.explicit = false
|
||||
this.language = null
|
||||
|
||||
if (metadata) {
|
||||
this.construct(metadata)
|
||||
|
|
@ -24,11 +25,12 @@ class PodcastMetadata {
|
|||
this.releaseDate = metadata.releaseDate
|
||||
this.genres = [...metadata.genres]
|
||||
this.feedUrl = metadata.feedUrl
|
||||
this.feedImageUrl = metadata.feedImageUrl
|
||||
this.imageUrl = metadata.imageUrl
|
||||
this.itunesPageUrl = metadata.itunesPageUrl
|
||||
this.itunesId = metadata.itunesId
|
||||
this.itunesArtistId = metadata.itunesArtistId
|
||||
this.explicit = metadata.explicit
|
||||
this.language = metadata.language || null
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
@ -39,11 +41,12 @@ class PodcastMetadata {
|
|||
releaseDate: this.releaseDate,
|
||||
genres: [...this.genres],
|
||||
feedUrl: this.feedUrl,
|
||||
feedImageUrl: this.feedImageUrl,
|
||||
imageUrl: this.imageUrl,
|
||||
itunesPageUrl: this.itunesPageUrl,
|
||||
itunesId: this.itunesId,
|
||||
itunesArtistId: this.itunesArtistId,
|
||||
explicit: this.explicit
|
||||
explicit: this.explicit,
|
||||
language: this.language
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ function extractEpisodeData(item) {
|
|||
Logger.error(`[podcastUtils] Invalid podcast episode data`)
|
||||
return null
|
||||
}
|
||||
var arrayFields = ['title', 'pubDate', 'description', 'itunes:episodeType', 'itunes:episode', 'itunes:author', 'itunes:duration', 'itunes:explicit']
|
||||
var arrayFields = ['title', 'pubDate', 'description', 'itunes:episodeType', 'itunes:episode', 'itunes:author', 'itunes:duration', 'itunes:explicit', 'itunes:subtitle']
|
||||
var episode = {
|
||||
enclosure: {
|
||||
...item.enclosure[0]['$']
|
||||
|
|
@ -70,12 +70,27 @@ function extractEpisodeData(item) {
|
|||
return episode
|
||||
}
|
||||
|
||||
function cleanEpisodeData(data) {
|
||||
return {
|
||||
title: data.title,
|
||||
subtitle: data.subtitle || '',
|
||||
description: data.description || '',
|
||||
pubDate: data.pubDate || '',
|
||||
episodeType: data.episodeType || '',
|
||||
episode: data.episode || '',
|
||||
author: data.author || '',
|
||||
duration: data.duration || '',
|
||||
explicit: data.explicit || '',
|
||||
publishedAt: (new Date(data.pubDate)).valueOf()
|
||||
}
|
||||
}
|
||||
|
||||
function extractPodcastEpisodes(items) {
|
||||
var episodes = []
|
||||
items.forEach((item) => {
|
||||
var cleaned = extractEpisodeData(item)
|
||||
if (cleaned) {
|
||||
episodes.push(cleaned)
|
||||
var extracted = extractEpisodeData(item)
|
||||
if (extracted) {
|
||||
episodes.push(cleanEpisodeData(extracted))
|
||||
}
|
||||
})
|
||||
return episodes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue