()
| 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 | } |
nothing calls this directly
no test coverage detected