mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-14 17:28:24 +02:00
Add logs when sanitizing filename and update podcast episode download to set targetFilename on init #4121
This commit is contained in:
@ -20,6 +20,8 @@ class PodcastEpisodeDownload {
|
||||
|
||||
this.appendRandomId = false
|
||||
|
||||
this.targetFilename = null
|
||||
|
||||
this.startedAt = null
|
||||
this.createdAt = null
|
||||
this.finishedAt = null
|
||||
@ -74,11 +76,6 @@ class PodcastEpisodeDownload {
|
||||
get episodeTitle() {
|
||||
return this.rssPodcastEpisode.title
|
||||
}
|
||||
get targetFilename() {
|
||||
const appendage = this.appendRandomId ? ` (${this.id})` : ''
|
||||
const filename = `${this.rssPodcastEpisode.title}${appendage}.${this.fileExtension}`
|
||||
return sanitizeFilename(filename)
|
||||
}
|
||||
get targetPath() {
|
||||
return filePathToPOSIX(Path.join(this.libraryItem.path, this.targetFilename))
|
||||
}
|
||||
@ -93,6 +90,23 @@ class PodcastEpisodeDownload {
|
||||
return new Date(this.rssPodcastEpisode.publishedAt).getFullYear()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} title
|
||||
*/
|
||||
getSanitizedFilename(title) {
|
||||
const appendage = this.appendRandomId ? ` (${this.id})` : ''
|
||||
const filename = `${title.trim()}${appendage}.${this.fileExtension}`
|
||||
return sanitizeFilename(filename)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} appendRandomId
|
||||
*/
|
||||
setAppendRandomId(appendRandomId) {
|
||||
this.appendRandomId = appendRandomId
|
||||
this.targetFilename = this.getSanitizedFilename(this.rssPodcastEpisode.title || '')
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('../utils/podcastUtils').RssPodcastEpisode} rssPodcastEpisode - from rss feed
|
||||
@ -112,6 +126,8 @@ class PodcastEpisodeDownload {
|
||||
this.url = encodeURI(url)
|
||||
}
|
||||
|
||||
this.targetFilename = this.getSanitizedFilename(this.rssPodcastEpisode.title || '')
|
||||
|
||||
this.libraryItem = libraryItem
|
||||
this.isAutoDownload = isAutoDownload
|
||||
this.createdAt = Date.now()
|
||||
|
Reference in New Issue
Block a user