fix: playlist format placeholders not being replaced correctly

This commit is contained in:
Jelle Glebbeek
2021-07-03 21:01:24 +02:00
parent 912701586c
commit bee467b666

View File

@@ -198,13 +198,13 @@ class Utils {
if(metadata == null) actualMetadata = {};
let formatParsed = format;
const regex = new RegExp(/%\((\w+)\)(s?)/g);
let z;
while((z=regex.exec(formatParsed)) != null) {
if(z[1] != null) {
if(actualMetadata[z[1]] != null) {
formatParsed = formatParsed.replace(z[0], actualMetadata[z[1]]);
}
}
const placeholders = format.matchAll(regex);
for(const match of placeholders) {
if(match == null) continue;
if(match[0] == null || match[1] == null) continue;
const placeholderValue = actualMetadata[match[1]];
if(placeholderValue == null) continue;
formatParsed = formatParsed.replace(match[0], placeholderValue)
}
return formatParsed;
}