Update scripts

This commit is contained in:
freearhey committed 2026-09-18 11:31:21 +03:00
1 parent 9902121ac0
commit 9d7cac7bda
21 files changed
+129 -55

No files matched your search

+14
View File
@@ -84,6 +84,20 @@ async function main() {
errors = errors.concat(validateStreamId(streamId))
}
}
if (
data.missing([
'stream_id',
'quality',
'live_247',
'geo_blocked',
'http_user_agent',
'http_referrer'
])
) {
errors.push('The request does not contain any changes')
done()
}
}
done()
+1 -1
View File
@@ -128,7 +128,7 @@ async function main() {
if (streams.isEmpty()) return
const playlist = new Playlist(streams, { public: false })
const playlist = new Playlist(streams, { public: false, raw: true })
await streamsStorage.save(filepath, playlist.toString())
}
}
+18 -3
View File
@@ -44,20 +44,35 @@ async function main() {
logger.info('generating raw/...')
await new RawGenerator({ streams, logFile }).generate()
logger.info('create unique names...')
const channelCountries = new Map<string, Set<string>>()
streams.forEach((stream: Stream) => {
if (!channelCountries.has(stream.channelName)) {
channelCountries.set(stream.channelName, new Set())
}
channelCountries.get(stream.channelName)!.add(stream.countryName)
})
for (const stream of streams.all()) {
const countries = channelCountries.get(stream.channelName)
stream.hasUniqueName = countries ? countries.size === 1 : false
}
logger.info('sorting streams...')
streams = streams.sortBy(
[
(stream: Stream) => stream.getId(),
(stream: Stream) => stream.channelUniqueName,
(stream: Stream) => (stream.hasMainFeed ? 1 : 0),
(stream: Stream) => stream.feedName,
(stream: Stream) => (stream.isGeoBlocked ? -1 : 0),
(stream: Stream) => (stream.isNot247 ? -1 : 0),
(stream: Stream) => stream.getVerticalResolution()
],
['asc', 'desc', 'desc', 'desc']
['asc', 'desc', 'asc', 'desc', 'desc', 'desc']
)
logger.info('filtering streams...')
streams = streams
.filter((stream: Stream) => !!stream.getId())
.filter((stream: Stream) => stream.hasChannel() && stream.hasFeed())
.uniqBy((stream: Stream) => stream.getId() || uniqueId())
const { categories, countries, subdivisions, cities, regions } = data
+1 -1
View File
@@ -164,7 +164,7 @@ async function removeBrokenLinks() {
streams = streams.filter((stream: Stream) => !isBroken(stream))
const playlist = new Playlist(streams, { public: false })
const playlist = new Playlist(streams, { public: false, raw: true })
await rootStorage.save(filepath, playlist.toString())
}
}
+1 -1
View File
@@ -68,7 +68,7 @@ async function saveStreams() {
let filteredStreams = new Collection<Stream>(groupedStreams.get(filepath))
filteredStreams = filteredStreams.filter((stream: Stream) => stream.removed === false)
const playlist = new Playlist(filteredStreams, { public: false })
const playlist = new Playlist(filteredStreams, { public: false, raw: true })
await streamsStorage.save(filepath, playlist.toString())
}
}
+14 -3
View File
@@ -1,4 +1,5 @@
import { Logger, Collection, Dictionary } from '@freearhey/core'
import { OptionValues, program } from 'commander'
import { Storage } from '@freearhey/storage-js'
import { PlaylistParser } from '../../core'
import { data, loadData } from '../../api'
@@ -6,10 +7,14 @@ import { ROOT_DIR } from '../../constants'
import { isURI } from '../../utils.js'
import { Stream } from '../../models'
import * as sdk from '@iptv-org/sdk'
import { program } from 'commander'
import chalk from 'chalk'
program.argument('[filepath...]', 'Path to file to validate').parse(process.argv)
program
.argument('[filepath...]', 'Path to file to validate')
.option('--log-level <level>', 'Specify the minimum log level (error or warning)')
.parse(process.argv)
const options: OptionValues = program.opts()
type LogItem = {
type: string
@@ -51,7 +56,7 @@ async function main() {
const streams = streamsGroupedByFilepath.get(filepath)
if (!streams) continue
const log = new Collection<LogItem>()
let log = new Collection<LogItem>()
streams.forEach((stream: Stream) => {
if (!stream.channel) {
log.add({
@@ -130,6 +135,12 @@ async function main() {
}
})
if (options.logLevel === 'error') {
log = log.filter(i => ['error'].includes(i.type))
} else if (options.logLevel === 'warning') {
log = log.filter(i => ['warning', 'error'].includes(i.type))
}
if (log.isNotEmpty()) {
console.log(`\n${chalk.underline(filepath)}`)