Add podcast episode auto download new episodes cron

This commit is contained in:
advplyr 2022-03-26 19:58:59 -05:00
parent d5e96a3422
commit 0dd219f303
10 changed files with 155 additions and 15 deletions

View file

@ -126,5 +126,10 @@ class PodcastEpisode {
audioTrack.setData(libraryItemId, this.audioFile, 0)
return [audioTrack]
}
checkEqualsEnclosureUrl(url) {
if (!this.enclosure || !this.enclosure.url) return false
return this.enclosure.url == url
}
}
module.exports = PodcastEpisode

View file

@ -15,6 +15,7 @@ class Podcast {
this.episodes = []
this.autoDownloadEpisodes = false
this.lastEpisodeCheck = 0
this.lastCoverSearch = null
this.lastCoverSearchQuery = null
@ -30,6 +31,7 @@ class Podcast {
this.tags = [...podcast.tags]
this.episodes = podcast.episodes.map((e) => new PodcastEpisode(e))
this.autoDownloadEpisodes = !!podcast.autoDownloadEpisodes
this.lastEpisodeCheck = podcast.lastEpisodeCheck || 0
}
toJSON() {
@ -38,7 +40,8 @@ class Podcast {
coverPath: this.coverPath,
tags: [...this.tags],
episodes: this.episodes.map(e => e.toJSON()),
autoDownloadEpisodes: this.autoDownloadEpisodes
autoDownloadEpisodes: this.autoDownloadEpisodes,
lastEpisodeCheck: this.lastEpisodeCheck
}
}
@ -49,6 +52,7 @@ class Podcast {
tags: [...this.tags],
episodes: this.episodes.map(e => e.toJSON()),
autoDownloadEpisodes: this.autoDownloadEpisodes,
lastEpisodeCheck: this.lastEpisodeCheck,
size: this.size
}
}
@ -60,6 +64,7 @@ class Podcast {
tags: [...this.tags],
episodes: this.episodes.map(e => e.toJSONExpanded()),
autoDownloadEpisodes: this.autoDownloadEpisodes,
lastEpisodeCheck: this.lastEpisodeCheck,
size: this.size
}
}
@ -135,6 +140,7 @@ class Podcast {
this.coverPath = mediaMetadata.coverPath || null
this.autoDownloadEpisodes = !!mediaMetadata.autoDownloadEpisodes
this.lastEpisodeCheck = Date.now() // Makes sure new episodes are after this
}
async syncMetadataFiles(textMetadataFiles, opfMetadataOverrideDetails) {
@ -149,6 +155,9 @@ class Podcast {
checkHasEpisode(episodeId) {
return this.episodes.some(ep => ep.id === episodeId)
}
checkHasEpisodeByFeedUrl(url) {
return this.episodes.some(ep => ep.checkEqualsEnclosureUrl(url))
}
// Only checks container format
checkCanDirectPlay(payload, episodeId) {