Update scripts

This commit is contained in:
freearhey
2026-05-25 13:29:39 +03:00
parent b7cd2a1d5a
commit 254458135a
6 changed files with 86 additions and 36 deletions
+5 -1
View File
@@ -5,8 +5,8 @@ import { Storage } from '@freearhey/storage-js'
import { STREAMS_DIR } from '../../constants'
import { PlaylistParser } from '../../core'
import { getStreamInfo } from '../../utils'
import { loadData, data } from '../../api'
import cliProgress from 'cli-progress'
import { loadData } from '../../api'
import { eachLimit } from 'async'
import path from 'node:path'
import os from 'node:os'
@@ -44,6 +44,10 @@ async function main() {
let files = program.args.length ? program.args : await streamsStorage.list('**/*.m3u')
files = files.map((filepath: string) => path.basename(filepath))
let streams = await parser.parse(files)
streams = streams.map((stream: Stream) => {
stream.setGuides(data.guidesGroupedByStreamId.get(stream.getId()))
return stream
})
logger.info(`found ${streams.count()} streams`)
+9 -24
View File
@@ -34,6 +34,10 @@ async function main() {
})
const files = await streamsStorage.list('**/*.m3u')
let streams = await parser.parse(files)
streams = streams.map((stream: Stream) => {
stream.setGuides(data.guidesGroupedByStreamId.get(stream.getId()))
return stream
})
const totalStreams = streams.count()
logger.info(`found ${totalStreams} streams`)
@@ -62,32 +66,16 @@ async function main() {
await new LanguagesGenerator({ streams, logFile }).generate()
logger.info('generating countries/...')
await new CountriesGenerator({
countries,
streams,
logFile
}).generate()
await new CountriesGenerator({ countries, streams, logFile }).generate()
logger.info('generating subdivisions/...')
await new SubdivisionsGenerator({
subdivisions,
streams,
logFile
}).generate()
await new SubdivisionsGenerator({ subdivisions, streams, logFile }).generate()
logger.info('generating cities/...')
await new CitiesGenerator({
cities,
streams,
logFile
}).generate()
await new CitiesGenerator({ cities, streams, logFile }).generate()
logger.info('generating regions/...')
await new RegionsGenerator({
streams,
regions,
logFile
}).generate()
await new RegionsGenerator({ streams, regions, logFile }).generate()
logger.info('generating sources/...')
await new SourcesGenerator({ streams, logFile }).generate()
@@ -99,10 +87,7 @@ async function main() {
await new IndexCategoryGenerator({ streams, logFile }).generate()
logger.info('generating index.country.m3u...')
await new IndexCountryGenerator({
streams,
logFile
}).generate()
await new IndexCountryGenerator({ streams, logFile }).generate()
logger.info('generating index.language.m3u...')
await new IndexLanguageGenerator({ streams, logFile }).generate()
+9 -1
View File
@@ -81,6 +81,10 @@ async function loadStreams() {
const files = await streamsStorage.list('**/*.m3u')
streams = await parser.parse(files)
streams = streams.map((stream: Stream) => {
stream.setGuides(apiData.guidesGroupedByStreamId.get(stream.getId()))
return stream
})
}
async function processIssues(issues: Collection<Issue>) {
@@ -132,7 +136,7 @@ async function removeStream(issue: Issue) {
if (changed) {
processedIssues.add(issue)
} else {
log.error(`None of the URLs specified in the request were found in the playlists`)
log.error('None of the URLs specified in the request were found in the playlists')
skippedIssues.add(issue)
}
}
@@ -162,6 +166,8 @@ async function editStream(issue: Issue) {
stream.updateWithIssue(data)
stream.setGuides(apiData.guidesGroupedByStreamId.get(stream.getId()))
const errors = new Collection<Error>()
errors.concat(stream.validate())
if (errors.isNotEmpty()) {
@@ -260,6 +266,8 @@ async function addStream(issue: Issue) {
stream.updateTitle().updateFilepath()
stream.setGuides(apiData.guidesGroupedByStreamId.get(stream.getId()))
streams.add(stream)
const errors = new Collection<Error>()