diff --git a/scripts/core/playlistParser.ts b/scripts/core/playlistParser.ts index 192fa5a45..cae8ffb4f 100644 --- a/scripts/core/playlistParser.ts +++ b/scripts/core/playlistParser.ts @@ -53,8 +53,13 @@ export class PlaylistParser { function parseTitle(title: string): { name: string; label: string; quality: string } { const [, label] = title.match(/ \[(.*)\]$/) || [null, ''] - const [, quality] = title.match(/ \(([0-9]+p)\)/) || [null, ''] - const name = title.replace(` (${quality})`, '').replace(` [${label}]`, '') + title = title.replace(new RegExp(` \\[${escapeRegExp(label)}\\]$`), '') + const [, quality] = title.match(/ \(([0-9]+p)\)$/) || [null, ''] + title = title.replace(new RegExp(` \\(${quality}\\)$`), '') - return { name, label, quality } + return { name: title, label, quality } +} + +function escapeRegExp(text) { + return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') }