mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-03 16:59:41 +00:00
Update podcasts to new library item model
This commit is contained in:
parent
0357dc90d4
commit
69d1744496
11 changed files with 235 additions and 141 deletions
|
|
@ -6,8 +6,10 @@ const globals = require('../utils/globals')
|
|||
class PodcastEpisodeDownload {
|
||||
constructor() {
|
||||
this.id = null
|
||||
/** @type {import('../objects/entities/PodcastEpisode')} */
|
||||
this.podcastEpisode = null
|
||||
this.url = null
|
||||
/** @type {import('../models/LibraryItem')} */
|
||||
this.libraryItem = null
|
||||
this.libraryId = null
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ class PodcastEpisodeDownload {
|
|||
id: this.id,
|
||||
episodeDisplayTitle: this.podcastEpisode?.title ?? null,
|
||||
url: this.url,
|
||||
libraryItemId: this.libraryItem?.id || null,
|
||||
libraryItemId: this.libraryItemId,
|
||||
libraryId: this.libraryId || null,
|
||||
isFinished: this.isFinished,
|
||||
failed: this.failed,
|
||||
|
|
@ -35,8 +37,8 @@ class PodcastEpisodeDownload {
|
|||
startedAt: this.startedAt,
|
||||
createdAt: this.createdAt,
|
||||
finishedAt: this.finishedAt,
|
||||
podcastTitle: this.libraryItem?.media.metadata.title ?? null,
|
||||
podcastExplicit: !!this.libraryItem?.media.metadata.explicit,
|
||||
podcastTitle: this.libraryItem?.media.title ?? null,
|
||||
podcastExplicit: !!this.libraryItem?.media.explicit,
|
||||
season: this.podcastEpisode?.season ?? null,
|
||||
episode: this.podcastEpisode?.episode ?? null,
|
||||
episodeType: this.podcastEpisode?.episodeType ?? 'full',
|
||||
|
|
@ -80,9 +82,16 @@ class PodcastEpisodeDownload {
|
|||
return this.targetFilename
|
||||
}
|
||||
get libraryItemId() {
|
||||
return this.libraryItem ? this.libraryItem.id : null
|
||||
return this.libraryItem?.id || null
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('../objects/entities/PodcastEpisode')} podcastEpisode - old model
|
||||
* @param {import('../models/LibraryItem')} libraryItem
|
||||
* @param {*} isAutoDownload
|
||||
* @param {*} libraryId
|
||||
*/
|
||||
setData(podcastEpisode, libraryItem, isAutoDownload, libraryId) {
|
||||
this.id = uuidv4()
|
||||
this.podcastEpisode = podcastEpisode
|
||||
|
|
|
|||
|
|
@ -167,10 +167,5 @@ class PodcastEpisode {
|
|||
}
|
||||
return hasUpdates
|
||||
}
|
||||
|
||||
checkEqualsEnclosureUrl(url) {
|
||||
if (!this.enclosure?.url) return false
|
||||
return this.enclosure.url == url
|
||||
}
|
||||
}
|
||||
module.exports = PodcastEpisode
|
||||
|
|
|
|||
|
|
@ -193,11 +193,6 @@ class Podcast {
|
|||
checkHasEpisode(episodeId) {
|
||||
return this.episodes.some((ep) => ep.id === episodeId)
|
||||
}
|
||||
checkHasEpisodeByFeedEpisode(feedEpisode) {
|
||||
const guid = feedEpisode.guid
|
||||
const url = feedEpisode.enclosure.url
|
||||
return this.episodes.some((ep) => (ep.guid && ep.guid === guid) || ep.checkEqualsEnclosureUrl(url))
|
||||
}
|
||||
|
||||
addPodcastEpisode(podcastEpisode) {
|
||||
this.episodes.push(podcastEpisode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue