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

Method generate

scripts/generators/indexCategoryGenerator.ts:24–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22 }
23
24 async generate(): Promise<void> {
25 const streams = this.streams.sortBy(stream => stream.title).filter(stream => stream.isSFW())
26
27 let groupedStreams = new Collection<Stream>()
28 streams.forEach((stream: Stream) => {
29 const streamCategories = stream.getCategories()
30 if (streamCategories.isEmpty()) {
31 const streamClone = stream.clone()
32 streamClone.groupTitle = 'Undefined'
33 groupedStreams.add(streamClone)
34 return
35 }
36
37 streamCategories.forEach((category: sdk.Models.Category) => {
38 const streamClone = stream.clone()
39 streamClone.groupTitle = category.name
40 groupedStreams.add(streamClone)
41 })
42 })
43
44 groupedStreams = groupedStreams.sortBy(stream => {
45 if (stream.groupTitle === 'Undefined') return 'ZZ'
46 return stream.groupTitle
47 })
48
49 const playlist = new Playlist(groupedStreams, { public: true })
50 const filepath = 'index.category.m3u'
51 await this.storage.save(filepath, playlist.toString())
52 this.logFile.append(
53 JSON.stringify({ type: 'index', filepath, count: playlist.streams.count() }) + EOL
54 )
55 }
56}

Callers

nothing calls this directly

Calls 4

toStringMethod · 0.95
isSFWMethod · 0.80
cloneMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected