2022-03-09 02:31:44 +01:00
|
|
|
const AudioFile = require('../files/AudioFile')
|
2022-03-18 01:10:47 +01:00
|
|
|
const AudioTrack = require('../files/AudioTrack')
|
2022-03-09 02:31:44 +01:00
|
|
|
|
|
|
|
class PodcastEpisode {
|
|
|
|
constructor(episode) {
|
|
|
|
this.id = null
|
2022-03-17 01:15:25 +01:00
|
|
|
this.index = null
|
2022-03-09 02:31:44 +01:00
|
|
|
this.podcastId = null
|
|
|
|
this.episodeNumber = null
|
|
|
|
|
|
|
|
this.audioFile = null
|
|
|
|
this.addedAt = null
|
|
|
|
this.updatedAt = null
|
|
|
|
|
|
|
|
if (episode) {
|
|
|
|
this.construct(episode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
construct(episode) {
|
|
|
|
this.id = episode.id
|
2022-03-17 01:15:25 +01:00
|
|
|
this.index = episode.index
|
2022-03-09 02:31:44 +01:00
|
|
|
this.podcastId = episode.podcastId
|
|
|
|
this.episodeNumber = episode.episodeNumber
|
|
|
|
this.audioFile = new AudioFile(episode.audioFile)
|
|
|
|
this.addedAt = episode.addedAt
|
|
|
|
this.updatedAt = episode.updatedAt
|
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
|
|
|
id: this.id,
|
2022-03-17 01:15:25 +01:00
|
|
|
index: this.index,
|
2022-03-09 02:31:44 +01:00
|
|
|
podcastId: this.podcastId,
|
|
|
|
episodeNumber: this.episodeNumber,
|
|
|
|
audioFile: this.audioFile.toJSON(),
|
|
|
|
addedAt: this.addedAt,
|
|
|
|
updatedAt: this.updatedAt
|
|
|
|
}
|
|
|
|
}
|
2022-03-18 01:10:47 +01:00
|
|
|
|
|
|
|
get isPlaybackMediaEntity() { return true }
|
|
|
|
get tracks() {
|
|
|
|
return [this.audioFile]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only checks container format
|
|
|
|
checkCanDirectPlay(payload) {
|
|
|
|
var supportedMimeTypes = payload.supportedMimeTypes || []
|
|
|
|
return supportedMimeTypes.includes(this.audioFile.mimeType)
|
|
|
|
}
|
|
|
|
|
|
|
|
getDirectPlayTracklist(libraryItemId) {
|
|
|
|
var audioTrack = new AudioTrack()
|
|
|
|
audioTrack.setData(libraryItemId, this.audioFile, 0)
|
|
|
|
return [audioTrack]
|
|
|
|
}
|
2022-03-09 02:31:44 +01:00
|
|
|
}
|
|
|
|
module.exports = PodcastEpisode
|