From e6354bdd2390cb4e1102419dd3f1c90b99c07091 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Wed, 23 Apr 2025 20:56:19 +0300 Subject: [PATCH] Update scripts --- scripts/commands/playlist/edit.ts | 2 +- scripts/commands/playlist/generate.ts | 54 ++++++++++---------- scripts/commands/playlist/test.ts | 2 +- scripts/commands/playlist/validate.ts | 6 +-- scripts/generators/categoriesGenerator.ts | 21 ++++---- scripts/generators/countriesGenerator.ts | 25 ++++----- scripts/generators/indexCategoryGenerator.ts | 17 +++--- scripts/generators/indexCountryGenerator.ts | 17 +++--- scripts/generators/indexGenerator.ts | 17 +++--- scripts/generators/indexLanguageGenerator.ts | 17 +++--- scripts/generators/indexNsfwGenerator.ts | 17 +++--- scripts/generators/indexRegionGenerator.ts | 17 +++--- scripts/generators/languagesGenerator.ts | 21 ++++---- scripts/generators/regionsGenerator.ts | 25 +++++---- scripts/models/feed.ts | 4 +- 15 files changed, 144 insertions(+), 118 deletions(-) diff --git a/scripts/commands/playlist/edit.ts b/scripts/commands/playlist/edit.ts index c57a62d1e..d87590b1f 100644 --- a/scripts/commands/playlist/edit.ts +++ b/scripts/commands/playlist/edit.ts @@ -1,7 +1,7 @@ import { Storage, Collection, Logger, Dictionary } from '@freearhey/core' import { DataLoader, DataProcessor, PlaylistParser } from '../../core' -import { Channel, Feed, Playlist, Stream } from '../../models' import type { ChannelSearchableData } from '../../types/channel' +import { Channel, Feed, Playlist, Stream } from '../../models' import { DataProcessorData } from '../../types/dataProcessor' import { DataLoaderData } from '../../types/dataLoader' import { select, input } from '@inquirer/prompts' diff --git a/scripts/commands/playlist/generate.ts b/scripts/commands/playlist/generate.ts index c323d5395..b903b5a43 100644 --- a/scripts/commands/playlist/generate.ts +++ b/scripts/commands/playlist/generate.ts @@ -1,27 +1,25 @@ -import { Logger, Storage } from '@freearhey/core' import { PlaylistParser, DataProcessor, DataLoader } from '../../core' +import type { DataProcessorData } from '../../types/dataProcessor' +import { DATA_DIR, LOGS_DIR, STREAMS_DIR } from '../../constants' +import type { DataLoaderData } from '../../types/dataLoader' +import { Logger, Storage, File } from '@freearhey/core' import { Stream } from '../../models' import { uniqueId } from 'lodash' import { + IndexCategoryGenerator, + IndexLanguageGenerator, + IndexCountryGenerator, + IndexRegionGenerator, CategoriesGenerator, CountriesGenerator, LanguagesGenerator, RegionsGenerator, - IndexGenerator, - IndexCategoryGenerator, - IndexCountryGenerator, - IndexLanguageGenerator, - IndexRegionGenerator + IndexGenerator } from '../../generators' -import { DATA_DIR, LOGS_DIR, STREAMS_DIR } from '../../constants' -import type { DataProcessorData } from '../../types/dataProcessor' -import type { DataLoaderData } from '../../types/dataLoader' async function main() { const logger = new Logger() - const generatorsLogger = new Logger({ - stream: await new Storage(LOGS_DIR).createStream(`generators.log`) - }) + const logFile = new File('generators.log') logger.info('loading data from api...') const processor = new DataProcessor() @@ -29,19 +27,19 @@ async function main() { const loader = new DataLoader({ storage: dataStorage }) const data: DataLoaderData = await loader.load() const { + feedsGroupedByChannelId, + channelsKeyById, categories, countries, - regions, - channelsKeyById, - feedsGroupedByChannelId + regions }: DataProcessorData = processor.process(data) logger.info('loading streams...') const streamsStorage = new Storage(STREAMS_DIR) const parser = new PlaylistParser({ storage: streamsStorage, - channelsKeyById, - feedsGroupedByChannelId + feedsGroupedByChannelId, + channelsKeyById }) const files = await streamsStorage.list('**/*.m3u') let streams = await parser.parse(files) @@ -62,42 +60,46 @@ async function main() { ) logger.info('generating categories/...') - await new CategoriesGenerator({ categories, streams, logger: generatorsLogger }).generate() + await new CategoriesGenerator({ categories, streams, logFile }).generate() logger.info('generating countries/...') await new CountriesGenerator({ countries, streams, - logger: generatorsLogger + logFile }).generate() logger.info('generating languages/...') - await new LanguagesGenerator({ streams, logger: generatorsLogger }).generate() + await new LanguagesGenerator({ streams, logFile }).generate() logger.info('generating regions/...') await new RegionsGenerator({ streams, regions, - logger: generatorsLogger + logFile }).generate() logger.info('generating index.m3u...') - await new IndexGenerator({ streams, logger: generatorsLogger }).generate() + await new IndexGenerator({ streams, logFile }).generate() logger.info('generating index.category.m3u...') - await new IndexCategoryGenerator({ streams, logger: generatorsLogger }).generate() + await new IndexCategoryGenerator({ streams, logFile }).generate() logger.info('generating index.country.m3u...') await new IndexCountryGenerator({ streams, - logger: generatorsLogger + logFile }).generate() logger.info('generating index.language.m3u...') - await new IndexLanguageGenerator({ streams, logger: generatorsLogger }).generate() + await new IndexLanguageGenerator({ streams, logFile }).generate() logger.info('generating index.region.m3u...') - await new IndexRegionGenerator({ streams, regions, logger: generatorsLogger }).generate() + await new IndexRegionGenerator({ streams, regions, logFile }).generate() + + logger.info('saving generators.log...') + const logStorage = new Storage(LOGS_DIR) + logStorage.saveFile(logFile) } main() diff --git a/scripts/commands/playlist/test.ts b/scripts/commands/playlist/test.ts index cc6f1dc14..a37b7ecd0 100644 --- a/scripts/commands/playlist/test.ts +++ b/scripts/commands/playlist/test.ts @@ -159,7 +159,7 @@ function onFinish() { drawTable() - logger.error(`\n${errors + warnings} problems (${errors} errors, ${warnings} warnings)`) + console.log(chalk.red(`\n${errors + warnings} problems (${errors} errors, ${warnings} warnings)`)) if (errors > 0) { process.exit(1) diff --git a/scripts/commands/playlist/validate.ts b/scripts/commands/playlist/validate.ts index 57bca4f6f..e089f7eff 100644 --- a/scripts/commands/playlist/validate.ts +++ b/scripts/commands/playlist/validate.ts @@ -94,14 +94,14 @@ async function main() { }) if (log.notEmpty()) { - logger.info(`\n${chalk.underline(filepath)}`) + console.log(`\n${chalk.underline(filepath)}`) log.forEach((logItem: LogItem) => { const position = logItem.line.toString().padEnd(6, ' ') const type = logItem.type.padEnd(9, ' ') const status = logItem.type === 'error' ? chalk.red(type) : chalk.yellow(type) - logger.info(` ${chalk.gray(position)}${status}${logItem.message}`) + console.log(` ${chalk.gray(position)}${status}${logItem.message}`) }) errors = errors.concat(log.filter((logItem: LogItem) => logItem.type === 'error')) @@ -109,7 +109,7 @@ async function main() { } } - logger.error( + console.log( chalk.red( `\n${ errors.count() + warnings.count() diff --git a/scripts/generators/categoriesGenerator.ts b/scripts/generators/categoriesGenerator.ts index cd20b6ea4..f6d455d4b 100644 --- a/scripts/generators/categoriesGenerator.ts +++ b/scripts/generators/categoriesGenerator.ts @@ -1,25 +1,26 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' +import { Collection, Storage, Logger, File } from '@freearhey/core' import { Stream, Category, Playlist } from '../models' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type CategoriesGeneratorProps = { streams: Collection categories: Collection - logger: Logger + logFile: File } export class CategoriesGenerator implements Generator { streams: Collection categories: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, categories, logger }: CategoriesGeneratorProps) { + constructor({ streams, categories, logFile }: CategoriesGeneratorProps) { this.streams = streams this.categories = categories this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate() { @@ -37,8 +38,8 @@ export class CategoriesGenerator implements Generator { const playlist = new Playlist(categoryStreams, { public: true }) const filepath = `categories/${category.id}.m3u` await this.storage.save(filepath, playlist.toString()) - this.logger.info( - JSON.stringify({ type: 'category', filepath, count: playlist.streams.count() }) + this.logFile.append( + JSON.stringify({ type: 'category', filepath, count: playlist.streams.count() }) + EOL ) }) @@ -46,8 +47,8 @@ export class CategoriesGenerator implements Generator { const playlist = new Playlist(undefinedStreams, { public: true }) const filepath = 'categories/undefined.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info( - JSON.stringify({ type: 'category', filepath, count: playlist.streams.count() }) + this.logFile.append( + JSON.stringify({ type: 'category', filepath, count: playlist.streams.count() }) + EOL ) } } diff --git a/scripts/generators/countriesGenerator.ts b/scripts/generators/countriesGenerator.ts index c935da5a4..7dc707cf9 100644 --- a/scripts/generators/countriesGenerator.ts +++ b/scripts/generators/countriesGenerator.ts @@ -1,25 +1,26 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' import { Country, Subdivision, Stream, Playlist } from '../models' +import { Collection, Storage, File } from '@freearhey/core' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type CountriesGeneratorProps = { streams: Collection countries: Collection - logger: Logger + logFile: File } export class CountriesGenerator implements Generator { streams: Collection countries: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, countries, logger }: CountriesGeneratorProps) { + constructor({ streams, countries, logFile }: CountriesGeneratorProps) { this.streams = streams this.countries = countries this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -36,8 +37,8 @@ export class CountriesGenerator implements Generator { const playlist = new Playlist(countryStreams, { public: true }) const filepath = `countries/${country.code.toLowerCase()}.m3u` await this.storage.save(filepath, playlist.toString()) - this.logger.info( - JSON.stringify({ type: 'country', filepath, count: playlist.streams.count() }) + this.logFile.append( + JSON.stringify({ type: 'country', filepath, count: playlist.streams.count() }) + EOL ) country.getSubdivisions().forEach(async (subdivision: Subdivision) => { @@ -50,8 +51,8 @@ export class CountriesGenerator implements Generator { const playlist = new Playlist(subdivisionStreams, { public: true }) const filepath = `subdivisions/${subdivision.code.toLowerCase()}.m3u` await this.storage.save(filepath, playlist.toString()) - this.logger.info( - JSON.stringify({ type: 'subdivision', filepath, count: playlist.streams.count() }) + this.logFile.append( + JSON.stringify({ type: 'subdivision', filepath, count: playlist.streams.count() }) + EOL ) }) }) @@ -60,12 +61,12 @@ export class CountriesGenerator implements Generator { const undefinedPlaylist = new Playlist(undefinedStreams, { public: true }) const undefinedFilepath = 'countries/undefined.m3u' await this.storage.save(undefinedFilepath, undefinedPlaylist.toString()) - this.logger.info( + this.logFile.append( JSON.stringify({ type: 'country', filepath: undefinedFilepath, count: undefinedPlaylist.streams.count() - }) + }) + EOL ) } } diff --git a/scripts/generators/indexCategoryGenerator.ts b/scripts/generators/indexCategoryGenerator.ts index 529ee8336..665f4cb0c 100644 --- a/scripts/generators/indexCategoryGenerator.ts +++ b/scripts/generators/indexCategoryGenerator.ts @@ -1,22 +1,23 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' +import { Collection, Storage, File } from '@freearhey/core' import { Stream, Playlist, Category } from '../models' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type IndexCategoryGeneratorProps = { streams: Collection - logger: Logger + logFile: File } export class IndexCategoryGenerator implements Generator { streams: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, logger }: IndexCategoryGeneratorProps) { + constructor({ streams, logFile }: IndexCategoryGeneratorProps) { this.streams = streams this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -48,6 +49,8 @@ export class IndexCategoryGenerator implements Generator { const playlist = new Playlist(groupedStreams, { public: true }) const filepath = 'index.category.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info(JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() })) + this.logFile.append( + JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL + ) } } diff --git a/scripts/generators/indexCountryGenerator.ts b/scripts/generators/indexCountryGenerator.ts index c65a43734..82eb335ef 100644 --- a/scripts/generators/indexCountryGenerator.ts +++ b/scripts/generators/indexCountryGenerator.ts @@ -1,22 +1,23 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' +import { Collection, Storage, File } from '@freearhey/core' import { Stream, Playlist, Country } from '../models' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type IndexCountryGeneratorProps = { streams: Collection - logger: Logger + logFile: File } export class IndexCountryGenerator implements Generator { streams: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, logger }: IndexCountryGeneratorProps) { + constructor({ streams, logFile }: IndexCountryGeneratorProps) { this.streams = streams this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -56,6 +57,8 @@ export class IndexCountryGenerator implements Generator { const playlist = new Playlist(groupedStreams, { public: true }) const filepath = 'index.country.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info(JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() })) + this.logFile.append( + JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL + ) } } diff --git a/scripts/generators/indexGenerator.ts b/scripts/generators/indexGenerator.ts index fafda061f..5cfa86c66 100644 --- a/scripts/generators/indexGenerator.ts +++ b/scripts/generators/indexGenerator.ts @@ -1,22 +1,23 @@ -import { Collection, Logger, Storage } from '@freearhey/core' +import { Collection, File, Storage } from '@freearhey/core' import { Stream, Playlist } from '../models' -import { Generator } from './generator' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type IndexGeneratorProps = { streams: Collection - logger: Logger + logFile: File } export class IndexGenerator implements Generator { streams: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, logger }: IndexGeneratorProps) { + constructor({ streams, logFile }: IndexGeneratorProps) { this.streams = streams this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -27,6 +28,8 @@ export class IndexGenerator implements Generator { const playlist = new Playlist(sfwStreams, { public: true }) const filepath = 'index.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info(JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() })) + this.logFile.append( + JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL + ) } } diff --git a/scripts/generators/indexLanguageGenerator.ts b/scripts/generators/indexLanguageGenerator.ts index 1116eb740..3df9f71f2 100644 --- a/scripts/generators/indexLanguageGenerator.ts +++ b/scripts/generators/indexLanguageGenerator.ts @@ -1,22 +1,23 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' +import { Collection, Storage, File } from '@freearhey/core' import { Stream, Playlist, Language } from '../models' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type IndexLanguageGeneratorProps = { streams: Collection - logger: Logger + logFile: File } export class IndexLanguageGenerator implements Generator { streams: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, logger }: IndexLanguageGeneratorProps) { + constructor({ streams, logFile }: IndexLanguageGeneratorProps) { this.streams = streams this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -47,6 +48,8 @@ export class IndexLanguageGenerator implements Generator { const playlist = new Playlist(groupedStreams, { public: true }) const filepath = 'index.language.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info(JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() })) + this.logFile.append( + JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL + ) } } diff --git a/scripts/generators/indexNsfwGenerator.ts b/scripts/generators/indexNsfwGenerator.ts index a89cf0a10..e1e98375b 100644 --- a/scripts/generators/indexNsfwGenerator.ts +++ b/scripts/generators/indexNsfwGenerator.ts @@ -1,22 +1,23 @@ -import { Collection, Logger, Storage } from '@freearhey/core' +import { Collection, File, Storage } from '@freearhey/core' import { Stream, Playlist } from '../models' -import { Generator } from './generator' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type IndexNsfwGeneratorProps = { streams: Collection - logger: Logger + logFile: File } export class IndexNsfwGenerator implements Generator { streams: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, logger }: IndexNsfwGeneratorProps) { + constructor({ streams, logFile }: IndexNsfwGeneratorProps) { this.streams = streams this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -25,6 +26,8 @@ export class IndexNsfwGenerator implements Generator { const playlist = new Playlist(allStreams, { public: true }) const filepath = 'index.nsfw.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info(JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() })) + this.logFile.append( + JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL + ) } } diff --git a/scripts/generators/indexRegionGenerator.ts b/scripts/generators/indexRegionGenerator.ts index 94537c9af..c462fcfce 100644 --- a/scripts/generators/indexRegionGenerator.ts +++ b/scripts/generators/indexRegionGenerator.ts @@ -1,25 +1,26 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' +import { Collection, Storage, File } from '@freearhey/core' import { Stream, Playlist, Region } from '../models' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type IndexRegionGeneratorProps = { streams: Collection regions: Collection - logger: Logger + logFile: File } export class IndexRegionGenerator implements Generator { streams: Collection regions: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, regions, logger }: IndexRegionGeneratorProps) { + constructor({ streams, regions, logFile }: IndexRegionGeneratorProps) { this.streams = streams this.regions = regions this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -58,6 +59,8 @@ export class IndexRegionGenerator implements Generator { const playlist = new Playlist(groupedStreams, { public: true }) const filepath = 'index.region.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info(JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() })) + this.logFile.append( + JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL + ) } } diff --git a/scripts/generators/languagesGenerator.ts b/scripts/generators/languagesGenerator.ts index 114fcddb2..f7ae9976e 100644 --- a/scripts/generators/languagesGenerator.ts +++ b/scripts/generators/languagesGenerator.ts @@ -1,19 +1,20 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' +import { Collection, Storage, File } from '@freearhey/core' import { Playlist, Language, Stream } from '../models' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' -type LanguagesGeneratorProps = { streams: Collection; logger: Logger } +type LanguagesGeneratorProps = { streams: Collection; logFile: File } export class LanguagesGenerator implements Generator { streams: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, logger }: LanguagesGeneratorProps) { + constructor({ streams, logFile }: LanguagesGeneratorProps) { this.streams = streams this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -38,8 +39,8 @@ export class LanguagesGenerator implements Generator { const playlist = new Playlist(languageStreams, { public: true }) const filepath = `languages/${language.code}.m3u` await this.storage.save(filepath, playlist.toString()) - this.logger.info( - JSON.stringify({ type: 'language', filepath, count: playlist.streams.count() }) + this.logFile.append( + JSON.stringify({ type: 'language', filepath, count: playlist.streams.count() }) + EOL ) }) @@ -50,8 +51,8 @@ export class LanguagesGenerator implements Generator { const playlist = new Playlist(undefinedStreams, { public: true }) const filepath = 'languages/undefined.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info( - JSON.stringify({ type: 'language', filepath, count: playlist.streams.count() }) + this.logFile.append( + JSON.stringify({ type: 'language', filepath, count: playlist.streams.count() }) + EOL ) } } diff --git a/scripts/generators/regionsGenerator.ts b/scripts/generators/regionsGenerator.ts index fb0a5d688..4d649a351 100644 --- a/scripts/generators/regionsGenerator.ts +++ b/scripts/generators/regionsGenerator.ts @@ -1,25 +1,26 @@ -import { Generator } from './generator' -import { Collection, Storage, Logger } from '@freearhey/core' +import { Collection, Storage, File } from '@freearhey/core' import { Playlist, Region, Stream } from '../models' import { PUBLIC_DIR } from '../constants' +import { Generator } from './generator' +import { EOL } from 'node:os' type RegionsGeneratorProps = { streams: Collection regions: Collection - logger: Logger + logFile: File } export class RegionsGenerator implements Generator { streams: Collection regions: Collection storage: Storage - logger: Logger + logFile: File - constructor({ streams, regions, logger }: RegionsGeneratorProps) { + constructor({ streams, regions, logFile }: RegionsGeneratorProps) { this.streams = streams this.regions = regions this.storage = new Storage(PUBLIC_DIR) - this.logger = logger + this.logFile = logFile } async generate(): Promise { @@ -35,8 +36,8 @@ export class RegionsGenerator implements Generator { const playlist = new Playlist(regionStreams, { public: true }) const filepath = `regions/${region.code.toLowerCase()}.m3u` await this.storage.save(filepath, playlist.toString()) - this.logger.info( - JSON.stringify({ type: 'region', filepath, count: playlist.streams.count() }) + this.logFile.append( + JSON.stringify({ type: 'region', filepath, count: playlist.streams.count() }) + EOL ) }) @@ -44,18 +45,20 @@ export class RegionsGenerator implements Generator { const internationalPlaylist = new Playlist(internationalStreams, { public: true }) const internationalFilepath = 'regions/int.m3u' await this.storage.save(internationalFilepath, internationalPlaylist.toString()) - this.logger.info( + this.logFile.append( JSON.stringify({ type: 'region', filepath: internationalFilepath, count: internationalPlaylist.streams.count() - }) + }) + EOL ) const undefinedStreams = streams.filter((stream: Stream) => !stream.hasBroadcastArea()) const playlist = new Playlist(undefinedStreams, { public: true }) const filepath = 'regions/undefined.m3u' await this.storage.save(filepath, playlist.toString()) - this.logger.info(JSON.stringify({ type: 'region', filepath, count: playlist.streams.count() })) + this.logFile.append( + JSON.stringify({ type: 'region', filepath, count: playlist.streams.count() }) + EOL + ) } } diff --git a/scripts/models/feed.ts b/scripts/models/feed.ts index 03ae31184..2b1fa9d34 100644 --- a/scripts/models/feed.ts +++ b/scripts/models/feed.ts @@ -144,8 +144,8 @@ export class Feed { this.broadcastRegions = regions.filter((region: Region) => { if (region.code === 'INT') return false - - return region.countryCodes.intersects(countriesCodes) + const intersected = region.countryCodes.intersects(countriesCodes) + return intersected.notEmpty() }) return this