mirror of
https://github.com/iptv-org/iptv
synced 2025-12-17 02:47:33 -05:00
Update scripts
This commit is contained in:
@@ -17,7 +17,7 @@ export class CategoriesGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, categories, logFile }: CategoriesGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.categories = categories
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
@@ -30,7 +30,8 @@ export class CategoriesGenerator implements Generator {
|
||||
const categoryStreams = streams
|
||||
.filter((stream: Stream) => stream.hasCategory(category))
|
||||
.map((stream: Stream) => {
|
||||
stream.groupTitle = stream.getCategoryNames().join(';')
|
||||
const groupTitle = stream.getCategoryNames().join(';')
|
||||
if (groupTitle) stream.groupTitle = groupTitle
|
||||
|
||||
return stream
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ export class CountriesGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, countries, logFile }: CountriesGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.countries = countries
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
export * from './categoriesGenerator'
|
||||
export * from './countriesGenerator'
|
||||
export * from './languagesGenerator'
|
||||
export * from './regionsGenerator'
|
||||
export * from './indexGenerator'
|
||||
export * from './indexNsfwGenerator'
|
||||
export * from './indexCategoryGenerator'
|
||||
export * from './indexCountryGenerator'
|
||||
export * from './indexGenerator'
|
||||
export * from './indexLanguageGenerator'
|
||||
export * from './indexNsfwGenerator'
|
||||
export * from './indexRegionGenerator'
|
||||
export * from './languagesGenerator'
|
||||
export * from './regionsGenerator'
|
||||
export * from './sourcesGenerator'
|
||||
|
||||
@@ -15,7 +15,7 @@ export class IndexCategoryGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logFile }: IndexCategoryGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export class IndexCountryGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logFile }: IndexCountryGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export class IndexGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logFile }: IndexGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
}
|
||||
@@ -24,6 +24,12 @@ export class IndexGenerator implements Generator {
|
||||
const sfwStreams = this.streams
|
||||
.orderBy(stream => stream.getTitle())
|
||||
.filter((stream: Stream) => stream.isSFW())
|
||||
.map((stream: Stream) => {
|
||||
const groupTitle = stream.getCategoryNames().join(';')
|
||||
if (groupTitle) stream.groupTitle = groupTitle
|
||||
|
||||
return stream
|
||||
})
|
||||
|
||||
const playlist = new Playlist(sfwStreams, { public: true })
|
||||
const filepath = 'index.m3u'
|
||||
|
||||
@@ -15,7 +15,7 @@ export class IndexLanguageGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logFile }: IndexLanguageGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export class IndexNsfwGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logFile }: IndexNsfwGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class IndexRegionGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, regions, logFile }: IndexRegionGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.regions = regions
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
|
||||
@@ -12,7 +12,7 @@ export class LanguagesGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logFile }: LanguagesGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class RegionsGenerator implements Generator {
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, regions, logFile }: RegionsGeneratorProps) {
|
||||
this.streams = streams
|
||||
this.streams = streams.clone()
|
||||
this.regions = regions
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
|
||||
44
scripts/generators/sourcesGenerator.ts
Normal file
44
scripts/generators/sourcesGenerator.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Collection, Storage, File, type Dictionary } from '@freearhey/core'
|
||||
import { Stream, Playlist } from '../models'
|
||||
import { PUBLIC_DIR } from '../constants'
|
||||
import { Generator } from './generator'
|
||||
import { EOL } from 'node:os'
|
||||
|
||||
type SourcesGeneratorProps = {
|
||||
streams: Collection
|
||||
logFile: File
|
||||
}
|
||||
|
||||
export class SourcesGenerator implements Generator {
|
||||
streams: Collection
|
||||
storage: Storage
|
||||
logFile: File
|
||||
|
||||
constructor({ streams, logFile }: SourcesGeneratorProps) {
|
||||
this.streams = streams.clone()
|
||||
this.storage = new Storage(PUBLIC_DIR)
|
||||
this.logFile = logFile
|
||||
}
|
||||
|
||||
async generate() {
|
||||
const files: Dictionary = this.streams.groupBy((stream: Stream) => stream.getFilename())
|
||||
|
||||
for (let filename of files.keys()) {
|
||||
if (!filename) continue
|
||||
|
||||
let streams = new Collection(files.get(filename))
|
||||
streams = streams.map((stream: Stream) => {
|
||||
const groupTitle = stream.getCategoryNames().join(';')
|
||||
if (groupTitle) stream.groupTitle = groupTitle
|
||||
|
||||
return stream
|
||||
})
|
||||
const playlist = new Playlist(streams, { public: true })
|
||||
const filepath = `sources/${filename}`
|
||||
await this.storage.save(filepath, playlist.toString())
|
||||
this.logFile.append(
|
||||
JSON.stringify({ type: 'source', filepath, count: playlist.streams.count() }) + EOL
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user