mirror of
https://github.com/iptv-org/iptv
synced 2025-12-16 10:26:48 -05:00
Update scripts
This commit is contained in:
@@ -15,7 +15,8 @@ import {
|
|||||||
LanguagesGenerator,
|
LanguagesGenerator,
|
||||||
RegionsGenerator,
|
RegionsGenerator,
|
||||||
IndexGenerator,
|
IndexGenerator,
|
||||||
SourcesGenerator
|
SourcesGenerator,
|
||||||
|
RawGenerator
|
||||||
} from '../../generators'
|
} from '../../generators'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -49,6 +50,9 @@ async function main() {
|
|||||||
const totalStreams = streams.count()
|
const totalStreams = streams.count()
|
||||||
logger.info(`found ${totalStreams} streams`)
|
logger.info(`found ${totalStreams} streams`)
|
||||||
|
|
||||||
|
logger.info('generating raw/...')
|
||||||
|
await new RawGenerator({ streams, logFile }).generate()
|
||||||
|
|
||||||
logger.info('filtering streams...')
|
logger.info('filtering streams...')
|
||||||
streams = streams.uniqBy((stream: Stream) =>
|
streams = streams.uniqBy((stream: Stream) =>
|
||||||
stream.hasId() ? stream.getChannelId() + stream.getFeedId() : uniqueId()
|
stream.hasId() ? stream.getChannelId() + stream.getFeedId() : uniqueId()
|
||||||
|
|||||||
@@ -7,5 +7,6 @@ export * from './indexLanguageGenerator'
|
|||||||
export * from './indexNsfwGenerator'
|
export * from './indexNsfwGenerator'
|
||||||
export * from './indexRegionGenerator'
|
export * from './indexRegionGenerator'
|
||||||
export * from './languagesGenerator'
|
export * from './languagesGenerator'
|
||||||
|
export * from './rawGenerator'
|
||||||
export * from './regionsGenerator'
|
export * from './regionsGenerator'
|
||||||
export * from './sourcesGenerator'
|
export * from './sourcesGenerator'
|
||||||
|
|||||||
41
scripts/generators/rawGenerator.ts
Normal file
41
scripts/generators/rawGenerator.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Collection, Storage, File } from '@freearhey/core'
|
||||||
|
import { Stream, Playlist } from '../models'
|
||||||
|
import { PUBLIC_DIR } from '../constants'
|
||||||
|
import { Generator } from './generator'
|
||||||
|
import { EOL } from 'node:os'
|
||||||
|
|
||||||
|
type RawGeneratorProps = {
|
||||||
|
streams: Collection
|
||||||
|
logFile: File
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RawGenerator implements Generator {
|
||||||
|
streams: Collection
|
||||||
|
storage: Storage
|
||||||
|
logFile: File
|
||||||
|
|
||||||
|
constructor({ streams, logFile }: RawGeneratorProps) {
|
||||||
|
this.streams = streams.clone()
|
||||||
|
this.storage = new Storage(PUBLIC_DIR)
|
||||||
|
this.logFile = logFile
|
||||||
|
}
|
||||||
|
|
||||||
|
async generate() {
|
||||||
|
const files = this.streams.groupBy((stream: Stream) => stream.getFilename())
|
||||||
|
|
||||||
|
for (let filename of files.keys()) {
|
||||||
|
const streams = new Collection(files.get(filename)).map((stream: Stream) => {
|
||||||
|
const groupTitle = stream.getCategoryNames().join(';')
|
||||||
|
if (groupTitle) stream.groupTitle = groupTitle
|
||||||
|
|
||||||
|
return stream
|
||||||
|
})
|
||||||
|
const playlist = new Playlist(streams, { public: true })
|
||||||
|
const filepath = `raw/${filename}`
|
||||||
|
await this.storage.save(filepath, playlist.toString())
|
||||||
|
this.logFile.append(
|
||||||
|
JSON.stringify({ type: 'raw', filepath, count: playlist.streams.count() }) + EOL
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user