mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-18 09:49:36 +00:00
Start of new data model
This commit is contained in:
parent
2b7f53b0a7
commit
65793f7109
18 changed files with 672 additions and 8 deletions
43
server/objects/entities/Podcast.js
Normal file
43
server/objects/entities/Podcast.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue