New data model save covers, scanner, new api routes

This commit is contained in:
advplyr 2022-03-12 17:45:32 -06:00
parent 5f4e5cd3d8
commit 73257188f6
37 changed files with 1649 additions and 672 deletions

View file

@ -1,5 +1,6 @@
const PodcastEpisode = require('./PodcastEpisode')
const PodcastMetadata = require('../metadata/PodcastMetadata')
const { areEquivalent, copyValue } = require('../../utils/index')
class Podcast {
constructor(podcast) {
@ -10,8 +11,8 @@ class Podcast {
this.tags = []
this.episodes = []
this.createdAt = null
this.lastUpdate = null
this.lastCoverSearch = null
this.lastCoverSearchQuery = null
if (podcast) {
this.construct(podcast)
@ -24,8 +25,6 @@ class Podcast {
this.coverPath = podcast.coverPath
this.tags = [...podcast.tags]
this.episodes = podcast.episodes.map((e) => new PodcastEpisode(e))
this.createdAt = podcast.createdAt
this.lastUpdate = podcast.lastUpdate
}
toJSON() {
@ -35,8 +34,6 @@ class Podcast {
coverPath: this.coverPath,
tags: [...this.tags],
episodes: this.episodes.map(e => e.toJSON()),
createdAt: this.createdAt,
lastUpdate: this.lastUpdate
}
}
@ -47,8 +44,7 @@ class Podcast {
coverPath: this.coverPath,
tags: [...this.tags],
episodes: this.episodes.map(e => e.toJSON()),
createdAt: this.createdAt,
lastUpdate: this.lastUpdate
}
}
@ -59,9 +55,74 @@ class Podcast {
coverPath: this.coverPath,
tags: [...this.tags],
episodes: this.episodes.map(e => e.toJSON()),
createdAt: this.createdAt,
lastUpdate: this.lastUpdate
}
}
get tracks() {
return []
}
get duration() {
return 0
}
get size() {
return 0
}
get hasMediaFiles() {
return !!this.episodes.length
}
get shouldSearchForCover() {
return false
}
get hasEmbeddedCoverArt() {
return false
}
update(payload) {
var json = this.toJSON()
var hasUpdates = false
for (const key in json) {
if (payload[key] !== undefined) {
if (key === 'metadata') {
if (this.metadata.update(payload.metadata)) {
hasUpdates = true
}
} else if (!areEquivalent(payload[key], json[key])) {
this[key] = copyValue(payload[key])
Logger.debug('[Podcast] Key updated', key, this[key])
hasUpdates = true
}
}
}
return hasUpdates
}
updateCover(coverPath) {
coverPath = coverPath.replace(/\\/g, '/')
if (this.coverPath === coverPath) return false
this.coverPath = coverPath
return true
}
checkUpdateMissingTracks() {
return false
}
removeFileWithInode(inode) {
return false
}
findFileWithInode(inode) {
return null
}
setData(scanMediaMetadata) {
this.metadata = new PodcastMetadata()
this.metadata.setData(scanMediaMetadata)
}
async syncMetadataFiles(textMetadataFiles, opfMetadataOverrideDetails) {
return false
}
}
module.exports = Podcast