Update Playlist.js

This commit is contained in:
Aleksandr Statciuk 2021-09-16 03:30:52 +03:00
parent 04eeee5e84
commit 2a1eb57c05
1 changed files with 9 additions and 5 deletions

View File

@ -11,17 +11,21 @@ module.exports = class Playlist {
this.updated = false this.updated = false
} }
toString(options = {}) { getHeader() {
const config = { raw: false, ...options } let header = ['#EXTM3U']
let parts = ['#EXTM3U']
for (let key in this.header.attrs) { for (let key in this.header.attrs) {
let value = this.header.attrs[key] let value = this.header.attrs[key]
if (value) { if (value) {
parts.push(`${key}="${value}"`) header.push(`${key}="${value}"`)
} }
} }
let output = `${parts.join(' ')}\n` return header.join(' ')
}
toString(options = {}) {
const config = { raw: false, ...options }
let output = `${this.getHeader()}\n`
for (let channel of this.channels) { for (let channel of this.channels) {
output += channel.toString(config.raw) output += channel.toString(config.raw)
} }