2023-09-22 04:17:22 +02:00
|
|
|
import { Collection } from '@freearhey/core'
|
2023-09-15 17:40:35 +02:00
|
|
|
import { Stream } from '../models'
|
|
|
|
|
|
|
|
type PlaylistOptions = {
|
|
|
|
public: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Playlist {
|
|
|
|
streams: Collection
|
|
|
|
options: {
|
|
|
|
public: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(streams: Collection, options?: PlaylistOptions) {
|
|
|
|
this.streams = streams
|
|
|
|
this.options = options || { public: false }
|
|
|
|
}
|
|
|
|
|
|
|
|
toString() {
|
2023-09-22 05:22:47 +02:00
|
|
|
let output = '#EXTM3U\n'
|
2023-09-15 17:40:35 +02:00
|
|
|
|
|
|
|
this.streams.forEach((stream: Stream) => {
|
2023-09-22 05:22:47 +02:00
|
|
|
output += stream.toString(this.options) + '\n'
|
2023-09-15 17:40:35 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
}
|