mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-23 20:29:37 +00:00
Include library item podcast queries
This commit is contained in:
parent
eeaf012cdc
commit
95c4b3862b
7 changed files with 231 additions and 22 deletions
|
|
@ -400,8 +400,15 @@ module.exports = (sequelize) => {
|
|||
})
|
||||
}
|
||||
|
||||
static async getByFilterAndSort(libraryId, userId, options) {
|
||||
const { libraryItems, count } = await libraryFilters.getFilteredLibraryItems(libraryId, userId, options)
|
||||
/**
|
||||
* Get library items using filter and sort
|
||||
* @param {oldLibrary} library
|
||||
* @param {string} userId
|
||||
* @param {object} options
|
||||
* @returns {object} { libraryItems:oldLibraryItem[], count:number }
|
||||
*/
|
||||
static async getByFilterAndSort(library, userId, options) {
|
||||
const { libraryItems, count } = await libraryFilters.getFilteredLibraryItems(library, userId, options)
|
||||
return {
|
||||
libraryItems: libraryItems.map(li => {
|
||||
const oldLibraryItem = this.getOldLibraryItem(li).toJSONMinified()
|
||||
|
|
@ -414,6 +421,16 @@ module.exports = (sequelize) => {
|
|||
if (li.rssFeed) {
|
||||
oldLibraryItem.rssFeed = sequelize.models.feed.getOldFeed(li.rssFeed).toJSONMinified()
|
||||
}
|
||||
if (li.media.numEpisodes) {
|
||||
oldLibraryItem.media.numEpisodes = li.media.numEpisodes
|
||||
}
|
||||
if (li.size && !oldLibraryItem.media.size) {
|
||||
oldLibraryItem.media.size = li.size
|
||||
}
|
||||
if (li.numEpisodesIncomplete) {
|
||||
oldLibraryItem.numEpisodesIncomplete = li.numEpisodesIncomplete
|
||||
}
|
||||
|
||||
return oldLibraryItem
|
||||
}),
|
||||
count
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module.exports = (sequelize) => {
|
|||
class Podcast extends Model {
|
||||
static getOldPodcast(libraryItemExpanded) {
|
||||
const podcastExpanded = libraryItemExpanded.media
|
||||
const podcastEpisodes = podcastExpanded.podcastEpisodes.map(ep => ep.getOldPodcastEpisode(libraryItemExpanded.id)).sort((a, b) => a.index - b.index)
|
||||
const podcastEpisodes = podcastExpanded.podcastEpisodes?.map(ep => ep.getOldPodcastEpisode(libraryItemExpanded.id)).sort((a, b) => a.index - b.index)
|
||||
return {
|
||||
id: podcastExpanded.id,
|
||||
libraryItemId: libraryItemExpanded.id,
|
||||
|
|
@ -25,7 +25,7 @@ module.exports = (sequelize) => {
|
|||
},
|
||||
coverPath: podcastExpanded.coverPath,
|
||||
tags: podcastExpanded.tags,
|
||||
episodes: podcastEpisodes,
|
||||
episodes: podcastEpisodes || [],
|
||||
autoDownloadEpisodes: podcastExpanded.autoDownloadEpisodes,
|
||||
autoDownloadSchedule: podcastExpanded.autoDownloadSchedule,
|
||||
lastEpisodeCheck: podcastExpanded.lastEpisodeCheck?.valueOf() || null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue