mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-30 01:15:24 +02:00
Update podcast scanner to remove media progress and episodes from playlist
This commit is contained in:
parent
62194b8781
commit
b47d7b734d
@ -62,14 +62,33 @@ class PodcastScanner {
|
|||||||
const episodesToRemove = []
|
const episodesToRemove = []
|
||||||
existingPodcastEpisodes = existingPodcastEpisodes.filter((ep) => {
|
existingPodcastEpisodes = existingPodcastEpisodes.filter((ep) => {
|
||||||
if (libraryItemData.checkAudioFileRemoved(ep.audioFile)) {
|
if (libraryItemData.checkAudioFileRemoved(ep.audioFile)) {
|
||||||
libraryScan.addLog(LogLevel.INFO, `Podcast episode "${ep.title}" audio file was removed`)
|
|
||||||
episodesToRemove.push(ep)
|
episodesToRemove.push(ep)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
await Promise.all(episodesToRemove.map((ep) => ep.destroy()))
|
if (episodesToRemove.length) {
|
||||||
|
// Remove episodes from playlists and media progress
|
||||||
|
const episodeIds = episodesToRemove.map((ep) => ep.id)
|
||||||
|
await Database.playlistModel.removeMediaItemsFromPlaylists(episodeIds)
|
||||||
|
const mediaProgressRemoved = await Database.mediaProgressModel.destroy({
|
||||||
|
where: {
|
||||||
|
mediaItemId: episodeIds
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (mediaProgressRemoved) {
|
||||||
|
libraryScan.addLog(LogLevel.INFO, `Removed ${mediaProgressRemoved} media progress for episodes`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove episodes
|
||||||
|
await Promise.all(
|
||||||
|
episodesToRemove.map(async (ep) => {
|
||||||
|
await ep.destroy()
|
||||||
|
libraryScan.addLog(LogLevel.INFO, `Podcast episode "${ep.title}" audio file was removed`)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Update audio files that were modified
|
// Update audio files that were modified
|
||||||
if (libraryItemData.audioLibraryFilesModified.length) {
|
if (libraryItemData.audioLibraryFilesModified.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user