Update playlistParser.ts

Fixes https://github.com/iptv-org/iptv/issues/17533
This commit is contained in:
freearhey 2024-12-20 10:05:26 +03:00
parent 51d6244418
commit 57ad6f4e0b

View file

@ -53,8 +53,13 @@ export class PlaylistParser {
function parseTitle(title: string): { name: string; label: string; quality: string } { function parseTitle(title: string): { name: string; label: string; quality: string } {
const [, label] = title.match(/ \[(.*)\]$/) || [null, ''] const [, label] = title.match(/ \[(.*)\]$/) || [null, '']
const [, quality] = title.match(/ \(([0-9]+p)\)/) || [null, ''] title = title.replace(new RegExp(` \\[${escapeRegExp(label)}\\]$`), '')
const name = title.replace(` (${quality})`, '').replace(` [${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, '\\$&')
} }