mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-25 01:16:40 +02:00
Update podcast.numEpisodes when episodes are created or destroyed
This commit is contained in:
parent
8f192b1b17
commit
0169bf5518
@ -498,6 +498,10 @@ class PodcastController {
|
|||||||
req.libraryItem.changed('libraryFiles', true)
|
req.libraryItem.changed('libraryFiles', true)
|
||||||
await req.libraryItem.save()
|
await req.libraryItem.save()
|
||||||
|
|
||||||
|
// update number of episodes
|
||||||
|
req.libraryItem.media.numEpisodes = req.libraryItem.media.podcastEpisodes.length
|
||||||
|
await req.libraryItem.media.save()
|
||||||
|
|
||||||
SocketAuthority.emitter('item_updated', req.libraryItem.toOldJSONExpanded())
|
SocketAuthority.emitter('item_updated', req.libraryItem.toOldJSONExpanded())
|
||||||
res.json(req.libraryItem.toOldJSON())
|
res.json(req.libraryItem.toOldJSON())
|
||||||
}
|
}
|
||||||
|
@ -232,6 +232,11 @@ class PodcastManager {
|
|||||||
|
|
||||||
await libraryItem.save()
|
await libraryItem.save()
|
||||||
|
|
||||||
|
if (libraryItem.media.numEpisodes !== libraryItem.media.podcastEpisodes.length) {
|
||||||
|
libraryItem.media.numEpisodes = libraryItem.media.podcastEpisodes.length
|
||||||
|
await libraryItem.media.save()
|
||||||
|
}
|
||||||
|
|
||||||
SocketAuthority.emitter('item_updated', libraryItem.toOldJSONExpanded())
|
SocketAuthority.emitter('item_updated', libraryItem.toOldJSONExpanded())
|
||||||
const podcastEpisodeExpanded = podcastEpisode.toOldJSONExpanded(libraryItem.id)
|
const podcastEpisodeExpanded = podcastEpisode.toOldJSONExpanded(libraryItem.id)
|
||||||
podcastEpisodeExpanded.libraryItem = libraryItem.toOldJSONExpanded()
|
podcastEpisodeExpanded.libraryItem = libraryItem.toOldJSONExpanded()
|
||||||
|
@ -131,6 +131,11 @@ class PodcastScanner {
|
|||||||
|
|
||||||
let hasMediaChanges = false
|
let hasMediaChanges = false
|
||||||
|
|
||||||
|
if (existingPodcastEpisodes.length !== media.numEpisodes) {
|
||||||
|
media.numEpisodes = existingPodcastEpisodes.length
|
||||||
|
hasMediaChanges = true
|
||||||
|
}
|
||||||
|
|
||||||
// Check if cover was removed
|
// Check if cover was removed
|
||||||
if (media.coverPath && libraryItemData.imageLibraryFilesRemoved.some(lf => lf.metadata.path === media.coverPath)) {
|
if (media.coverPath && libraryItemData.imageLibraryFilesRemoved.some(lf => lf.metadata.path === media.coverPath)) {
|
||||||
media.coverPath = null
|
media.coverPath = null
|
||||||
@ -283,7 +288,8 @@ class PodcastScanner {
|
|||||||
lastEpisodeCheck: 0,
|
lastEpisodeCheck: 0,
|
||||||
maxEpisodesToKeep: 0,
|
maxEpisodesToKeep: 0,
|
||||||
maxNewEpisodesToDownload: 3,
|
maxNewEpisodesToDownload: 3,
|
||||||
podcastEpisodes: newPodcastEpisodes
|
podcastEpisodes: newPodcastEpisodes,
|
||||||
|
numEpisodes: newPodcastEpisodes.length
|
||||||
}
|
}
|
||||||
|
|
||||||
const libraryItemObj = libraryItemData.libraryItemObject
|
const libraryItemObj = libraryItemData.libraryItemObject
|
||||||
|
Loading…
Reference in New Issue
Block a user