MCPcopy
hub / github.com/iptv-org/iptv / generate

Method generate

scripts/generators/regionsGenerator.ts:27–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25 }
26
27 async generate(): Promise<void> {
28 const streams = this.streams
29 .sortBy((stream: Stream) => stream.title)
30 .filter((stream: Stream) => stream.isSFW())
31
32 const streamsGroupedByRegionCode = {}
33 streams.forEach((stream: Stream) => {
34 stream.getBroadcastRegions().forEach((region: sdk.Models.Region) => {
35 if (streamsGroupedByRegionCode[region.code]) {
36 streamsGroupedByRegionCode[region.code].add(stream)
37 } else {
38 streamsGroupedByRegionCode[region.code] = new Collection<Stream>([stream])
39 }
40 })
41 })
42
43 for (const regionCode in streamsGroupedByRegionCode) {
44 const regionStreams = streamsGroupedByRegionCode[regionCode]
45
46 const playlist = new Playlist(regionStreams, { public: true })
47 const filepath = `regions/${regionCode.toLowerCase()}.m3u`
48 await this.storage.save(filepath, playlist.toString())
49 this.logFile.append(
50 JSON.stringify({ type: 'region', filepath, count: playlist.streams.count() }) + EOL
51 )
52 }
53 }
54}

Callers

nothing calls this directly

Calls 4

toStringMethod · 0.95
isSFWMethod · 0.80
getBroadcastRegionsMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected