mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-31 15:19:42 +02:00
Podcast episode downloader, update podcast data model
This commit is contained in:
parent
28d76d21f1
commit
920ca683b9
19 changed files with 407 additions and 49 deletions
|
@ -150,4 +150,23 @@ module.exports.downloadFile = async (url, filepath) => {
|
|||
writer.on('finish', resolve)
|
||||
writer.on('error', reject)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.sanitizeFilename = (filename, replacement = '') => {
|
||||
if (typeof filename !== 'string') {
|
||||
return false
|
||||
}
|
||||
var illegalRe = /[\/\?<>\\:\*\|"]/g;
|
||||
var controlRe = /[\x00-\x1f\x80-\x9f]/g;
|
||||
var reservedRe = /^\.+$/;
|
||||
var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
|
||||
var windowsTrailingRe = /[\. ]+$/;
|
||||
|
||||
var sanitized = filename
|
||||
.replace(illegalRe, replacement)
|
||||
.replace(controlRe, replacement)
|
||||
.replace(reservedRe, replacement)
|
||||
.replace(windowsReservedRe, replacement)
|
||||
.replace(windowsTrailingRe, replacement);
|
||||
return sanitized
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue