Merge remote-tracking branch 'origin/master' into pr/49871

# Conflicts:
#	tests/commands/playlist/format.test.ts
This commit is contained in:
Sanaei
2026-09-04 17:30:25 +02:00
47 changed files with 882 additions and 488 deletions
+5 -7
View File
@@ -58,6 +58,7 @@ const rootStorage = new Storage(ROOT_DIR)
async function main() {
if (await isOffline()) {
logger.error(chalk.red('Internet connection is required for the script to work'))
process.exitCode = 1
return
}
@@ -195,13 +196,10 @@ async function onFinish(error: Error | null | undefined) {
process.exit(0)
}
async function isOffline() {
return new Promise((resolve, reject) => {
dns.lookup('info.cern.ch', err => {
if (err) resolve(true)
reject(false)
})
}).catch(() => {})
async function isOffline(): Promise<boolean> {
return new Promise(resolve => {
dns.lookup('info.cern.ch', err => resolve(Boolean(err)))
})
}
function getColor(stream: Stream): string {
+6 -5
View File
@@ -78,7 +78,7 @@ export class Stream extends sdk.Models.Stream {
let title = name
const [, label] = title.match(/ \[(.*)\]$/) || [null, '']
title = title.replace(new RegExp(` \\[${escapeRegExp(label)}\\]$`), '')
const [, quality] = title.match(/ \(([0-9]+[p|i])\)$/) || [null, '']
const [, quality] = title.match(/ \(([0-9]+[pi])\)$/) || [null, '']
title = title.replace(new RegExp(` \\(${quality}\\)$`), '')
return { title, label, quality }
@@ -87,7 +87,8 @@ export class Stream extends sdk.Models.Stream {
if (!data.name) throw new Error('"name" property is required')
if (!data.url) throw new Error('"url" property is required')
const [channelId, feedId] = data.tvg.id.split('@')
const tvgId = data.tvg?.id || ''
const [channelId, feedId] = tvgId.split('@')
const { title, label, quality } = parseName(data.name)
const stream = new Stream({
@@ -96,12 +97,12 @@ export class Stream extends sdk.Models.Stream {
title: title,
quality: quality || null,
url: data.url,
referrer: data.http.referrer || null,
user_agent: data.http['user-agent'] || null,
referrer: data.http?.referrer || null,
user_agent: data.http?.['user-agent'] || null,
label: label || null
})
stream.tvgId = data.tvg.id
stream.tvgId = tvgId
stream.line = data.line
return stream
+11 -2
View File
@@ -39,9 +39,18 @@ export function isURI(string: string): boolean {
}
export function normalizeURL(url: string): string {
const normalized = normalizeUrl(url, { stripWWW: false })
let normalized: string
try {
normalized = normalizeUrl(url, { stripWWW: false })
} catch {
return url.replace(/\s/g, '+')
}
return decodeURIComponent(normalized).replace(/\s/g, '+').toString()
try {
return decodeURIComponent(normalized).replace(/\s/g, '+')
} catch {
return normalized.replace(/\s/g, '+')
}
}
export function getStoragePath(filepath: string, rootDir: string): string {