From 52921aeffa03f1647cd2adc498845ca1ff7d117d Mon Sep 17 00:00:00 2001
From: Aleksandr Statciuk <github@oiya.xyz>
Date: Fri, 11 Mar 2022 18:31:05 +0300
Subject: [PATCH] Update playlist.js

---
 scripts/core/playlist.js | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/scripts/core/playlist.js b/scripts/core/playlist.js
index fdf57aec9c..eefc0a494d 100644
--- a/scripts/core/playlist.js
+++ b/scripts/core/playlist.js
@@ -1,4 +1,5 @@
 const store = require('./store')
+const m3u = require('./m3u')
 const _ = require('lodash')
 
 const playlist = {}
@@ -50,34 +51,7 @@ class Playlist {
   }
 
   toString() {
-    let output = `#EXTM3U`
-    for (const attr in this.header) {
-      const value = this.header[attr]
-      output += ` ${attr}="${value}"`
-    }
-    output += `\n`
-
-    for (const link of this.links) {
-      output += `#EXTINF:-1`
-      for (const name in link.attrs) {
-        const value = link.attrs[name]
-        if (value !== undefined) {
-          output += ` ${name}="${value}"`
-        }
-      }
-      output += `,${link.title}\n`
-
-      for (const name in link.vlcOpts) {
-        const value = link.vlcOpts[name]
-        if (value !== undefined) {
-          output += `#EXTVLCOPT:${name}=${value}\n`
-        }
-      }
-
-      output += `${link.url}\n`
-    }
-
-    return output
+    return m3u.create(this.links, this.header)
   }
 }