audiobookshelf/server/objects/entities/Podcast.js
2022-03-08 19:31:44 -06:00

43 lines
1.0 KiB
JavaScript

const PodcastEpisode = require('./PodcastEpisode')
const PodcastMetadata = require('../metadata/PodcastMetadata')
class Podcast {
constructor(podcast) {
this.id = null
this.metadata = null
this.cover = null
this.coverFullPath = null
this.episodes = []
this.createdAt = null
this.lastUpdate = null
if (podcast) {
this.construct(podcast)
}
}
construct(podcast) {
this.id = podcast.id
this.metadata = new PodcastMetadata(podcast.metadata)
this.cover = podcast.cover
this.coverFullPath = podcast.coverFullPath
this.episodes = podcast.episodes.map((e) => new PodcastEpisode(e))
this.createdAt = podcast.createdAt
this.lastUpdate = podcast.lastUpdate
}
toJSON() {
return {
id: this.id,
metadata: this.metadata.toJSON(),
cover: this.cover,
coverFullPath: this.coverFullPath,
episodes: this.episodes.map(e => e.toJSON()),
createdAt: this.createdAt,
lastUpdate: this.lastUpdate
}
}
}
module.exports = Podcast