Update scripts

This commit is contained in:
freearhey
2026-09-03 14:53:13 +03:00
parent b700995496
commit d4f07c0a4c
7 changed files with 81 additions and 39 deletions
+3 -2
View File
@@ -114,11 +114,12 @@ async function main() {
streams = streams.sortBy(
[
(stream: Stream) => stream.title,
(stream: Stream) => (stream.isGeoBlocked ? -1 : 0),
(stream: Stream) => (stream.isNot247 ? -1 : 0),
(stream: Stream) => stream.getVerticalResolution(),
(stream: Stream) => stream.label,
(stream: Stream) => stream.url
],
['asc', 'desc', 'asc', 'asc']
['asc', 'desc', 'desc', 'desc', 'asc']
)
logger.info('saving...')
+4 -3
View File
@@ -48,10 +48,11 @@ async function main() {
streams = streams.sortBy(
[
(stream: Stream) => stream.getId(),
(stream: Stream) => stream.getVerticalResolution(),
(stream: Stream) => stream.label
(stream: Stream) => (stream.isGeoBlocked ? -1 : 0),
(stream: Stream) => (stream.isNot247 ? -1 : 0),
(stream: Stream) => stream.getVerticalResolution()
],
['asc', 'desc', 'desc']
['asc', 'desc', 'desc', 'desc', 'asc']
)
logger.info('filtering streams...')
+6 -6
View File
@@ -108,7 +108,7 @@ async function runTest(stream: Stream) {
stream.statusCode = result.status.code
if (stream.statusCode === 'OK') return
if (errorStatusCodes.includes(stream.statusCode) && !stream.label) {
if (errorStatusCodes.includes(stream.statusCode) && !stream.getLabels().length) {
errors++
} else {
warnings++
@@ -128,7 +128,7 @@ function drawTable() {
{ name: '', alignment: 'center', minLen: 3, maxLen: 3 },
{ name: 'tvg-id', alignment: 'left', color: 'green', minLen: 25, maxLen: 25 },
{ name: 'url', alignment: 'left', color: 'green', minLen: 100, maxLen: 100 },
{ name: 'label', alignment: 'left', color: 'yellow', minLen: 13, maxLen: 13 },
{ name: 'labels', alignment: 'left', color: 'yellow', minLen: 13, maxLen: 13 },
{ name: 'status', alignment: 'left', minLen: 25, maxLen: 25 }
]
})
@@ -137,14 +137,14 @@ function drawTable() {
const tvgId = truncate(stream.getTvgId(), 25)
const url = truncate(stream.url, 100)
const color = getColor(stream)
const label = stream.label || ''
const labels = stream.getLabels().join(';')
const status = stream.statusCode || 'PENDING'
const row = {
'': index,
'tvg-id': chalk[color](tvgId),
url: chalk[color](url),
label: chalk[color](label),
labels: chalk[color](labels),
status: chalk[color](status)
}
table.append(row)
@@ -208,14 +208,14 @@ function getColor(stream: Stream): string {
if (!stream.statusCode) return 'gray'
if (stream.statusCode === 'LOADING...') return 'white'
if (stream.statusCode === 'OK') return 'green'
if (errorStatusCodes.includes(stream.statusCode) && !stream.label) return 'red'
if (errorStatusCodes.includes(stream.statusCode) && !stream.getLabels().length) return 'red'
return 'yellow'
}
function isBroken(stream: Stream): boolean {
if (!stream.statusCode) return false
if (stream.label) return false
if (stream.getLabels().length) return false
if (!errorStatusCodes.includes(stream.statusCode)) return false
return true
+4 -1
View File
@@ -261,9 +261,12 @@ async function addStream(issue: Issue) {
user_agent: httpUserAgent,
referrer: httpReferrer,
quality,
label: data.getString('label') || ''
label: null
})
stream.isNot247 = data.has('live_247') ? !data.getBoolean('live_247') : false
stream.isGeoBlocked = data.has('geo_blocked') ? data.getBoolean('geo_blocked') : false
stream.updateTitle().updateFilepath()
stream.setGuides(apiData.guidesGroupedByStreamId.get(stream.getId()))