mirror of
https://github.com/iptv-org/iptv
synced 2026-09-06 03:50:47 -04:00
Merge remote-tracking branch 'origin/master' into pr/49871
# Conflicts: # tests/commands/playlist/format.test.ts
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user