2022-03-22 01:24:38 +01:00
|
|
|
const Path = require('path')
|
|
|
|
const { getId } = require('../utils/index')
|
|
|
|
const { sanitizeFilename } = require('../utils/fileUtils')
|
|
|
|
|
|
|
|
class PodcastEpisodeDownload {
|
|
|
|
constructor() {
|
|
|
|
this.id = null
|
|
|
|
this.podcastEpisode = null
|
|
|
|
this.url = null
|
|
|
|
this.libraryItem = null
|
|
|
|
|
|
|
|
this.isDownloading = false
|
|
|
|
this.startedAt = null
|
|
|
|
this.createdAt = null
|
|
|
|
this.finishedAt = null
|
|
|
|
}
|
|
|
|
|
|
|
|
get targetFilename() {
|
|
|
|
return sanitizeFilename(`${this.podcastEpisode.bestFilename}.mp3`)
|
|
|
|
}
|
|
|
|
|
|
|
|
get targetPath() {
|
|
|
|
return Path.join(this.libraryItem.path, this.targetFilename)
|
|
|
|
}
|
|
|
|
|
|
|
|
get targetRelPath() {
|
2022-03-27 00:23:33 +01:00
|
|
|
return this.targetFilename
|
2022-03-22 01:24:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setData(podcastEpisode, libraryItem) {
|
|
|
|
this.id = getId('epdl')
|
|
|
|
this.podcastEpisode = podcastEpisode
|
|
|
|
this.url = podcastEpisode.enclosure.url
|
|
|
|
this.libraryItem = libraryItem
|
|
|
|
this.createdAt = Date.now()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = PodcastEpisodeDownload
|