2022-03-09 02:31:44 +01:00
|
|
|
class PodcastMetadata {
|
|
|
|
constructor(metadata) {
|
|
|
|
this.title = null
|
2022-03-19 01:16:54 +01:00
|
|
|
this.author = null
|
2022-03-09 02:31:44 +01:00
|
|
|
this.description = null
|
|
|
|
this.releaseDate = null
|
|
|
|
this.genres = []
|
|
|
|
this.feedUrl = null
|
2022-03-19 12:41:54 +01:00
|
|
|
this.imageUrl = null
|
2022-03-09 02:31:44 +01:00
|
|
|
this.itunesPageUrl = null
|
|
|
|
this.itunesId = null
|
|
|
|
this.itunesArtistId = null
|
2022-03-11 01:45:02 +01:00
|
|
|
this.explicit = false
|
2022-03-19 12:41:54 +01:00
|
|
|
this.language = null
|
2022-03-09 02:31:44 +01:00
|
|
|
|
|
|
|
if (metadata) {
|
|
|
|
this.construct(metadata)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
construct(metadata) {
|
|
|
|
this.title = metadata.title
|
2022-03-19 01:16:54 +01:00
|
|
|
this.author = metadata.author
|
2022-03-09 02:31:44 +01:00
|
|
|
this.description = metadata.description
|
|
|
|
this.releaseDate = metadata.releaseDate
|
|
|
|
this.genres = [...metadata.genres]
|
|
|
|
this.feedUrl = metadata.feedUrl
|
2022-03-19 12:41:54 +01:00
|
|
|
this.imageUrl = metadata.imageUrl
|
2022-03-09 02:31:44 +01:00
|
|
|
this.itunesPageUrl = metadata.itunesPageUrl
|
|
|
|
this.itunesId = metadata.itunesId
|
|
|
|
this.itunesArtistId = metadata.itunesArtistId
|
2022-03-11 01:45:02 +01:00
|
|
|
this.explicit = metadata.explicit
|
2022-03-19 12:41:54 +01:00
|
|
|
this.language = metadata.language || null
|
2022-03-09 02:31:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
toJSON() {
|
|
|
|
return {
|
|
|
|
title: this.title,
|
2022-03-19 01:16:54 +01:00
|
|
|
author: this.author,
|
2022-03-09 02:31:44 +01:00
|
|
|
description: this.description,
|
|
|
|
releaseDate: this.releaseDate,
|
|
|
|
genres: [...this.genres],
|
|
|
|
feedUrl: this.feedUrl,
|
2022-03-19 12:41:54 +01:00
|
|
|
imageUrl: this.imageUrl,
|
2022-03-09 02:31:44 +01:00
|
|
|
itunesPageUrl: this.itunesPageUrl,
|
|
|
|
itunesId: this.itunesId,
|
|
|
|
itunesArtistId: this.itunesArtistId,
|
2022-03-19 12:41:54 +01:00
|
|
|
explicit: this.explicit,
|
|
|
|
language: this.language
|
2022-03-09 02:31:44 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-11 01:45:02 +01:00
|
|
|
|
|
|
|
toJSONExpanded() {
|
|
|
|
return this.toJSON()
|
|
|
|
}
|
2022-03-13 18:39:12 +01:00
|
|
|
|
2022-03-16 00:57:15 +01:00
|
|
|
clone() {
|
|
|
|
return new PodcastMetadata(this.toJSON())
|
|
|
|
}
|
|
|
|
|
2022-03-13 18:39:12 +01:00
|
|
|
searchQuery(query) { // Returns key if match is found
|
2022-03-19 01:16:54 +01:00
|
|
|
var keysToCheck = ['title', 'author', 'itunesId', 'itunesArtistId']
|
2022-03-13 18:39:12 +01:00
|
|
|
for (var key of keysToCheck) {
|
|
|
|
if (this[key] && String(this[key]).toLowerCase().includes(query)) {
|
|
|
|
return {
|
|
|
|
matchKey: key,
|
|
|
|
matchText: this[key]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
2022-03-09 02:31:44 +01:00
|
|
|
}
|
|
|
|
module.exports = PodcastMetadata
|