()
| 25 | } |
| 26 | |
| 27 | async generate() { |
| 28 | const streams = this.streams.sortBy([(stream: Stream) => stream.title]) |
| 29 | |
| 30 | this.categories.forEach(async (category: sdk.Models.Category) => { |
| 31 | const categoryStreams = streams |
| 32 | .filter((stream: Stream) => stream.hasCategory(category)) |
| 33 | .map((stream: Stream) => { |
| 34 | const groupTitle = stream |
| 35 | .getCategories() |
| 36 | .map(category => category.name) |
| 37 | .sort() |
| 38 | .join(';') |
| 39 | if (groupTitle) stream.groupTitle = groupTitle |
| 40 | |
| 41 | return stream |
| 42 | }) |
| 43 | |
| 44 | const playlist = new Playlist(categoryStreams, { public: true }) |
| 45 | const filepath = `categories/${category.id}.m3u` |
| 46 | await this.storage.save(filepath, playlist.toString()) |
| 47 | this.logFile.append( |
| 48 | JSON.stringify({ type: 'category', filepath, count: playlist.streams.count() }) + EOL |
| 49 | ) |
| 50 | }) |
| 51 | |
| 52 | const undefinedStreams = streams.filter((stream: Stream) => stream.getCategories().isEmpty()) |
| 53 | const playlist = new Playlist(undefinedStreams, { public: true }) |
| 54 | const filepath = 'categories/undefined.m3u' |
| 55 | await this.storage.save(filepath, playlist.toString()) |
| 56 | this.logFile.append( |
| 57 | JSON.stringify({ type: 'category', filepath, count: playlist.streams.count() }) + EOL |
| 58 | ) |
| 59 | } |
| 60 | } |
nothing calls this directly
no test coverage detected