added total tracks and last updated date

This commit is contained in:
2020-08-31 15:34:52 -05:00
parent 6c7cf29d7a
commit 4c7e7f2970

View File

@@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"os" "os"
"bufio" "bufio"
"time"
"github.com/beevik/etree" "github.com/beevik/etree"
) )
@@ -154,6 +155,9 @@ func main() {
// at this point, our playlist should be sorted // at this point, our playlist should be sorted
// get date
currentTime := time.Now()
// create the xml file // create the xml file
file, err := os.OpenFile("main_parsed.xml", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) file, err := os.OpenFile("main_parsed.xml", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil { if err != nil {
@@ -166,6 +170,13 @@ func main() {
fmt.Fprintln(w, `<playlist xmlns="https://xspf.org/ns/0/" version="1">`) fmt.Fprintln(w, `<playlist xmlns="https://xspf.org/ns/0/" version="1">`)
fmt.Fprintln(w, "<tracklist>") fmt.Fprintln(w, "<tracklist>")
// print out information at the header
fmt.Fprintln(w, "<track>")
fmt.Fprintln(w, "<title>dtam playlist</title>")
fmt.Fprintln(w, "<creator>" + strconv.Itoa(len(playlist_tracks)) + " tracks (Last updated: " + currentTime.Format("Jan 02, 2006") + ")</creator>")
fmt.Fprintln(w, "<location>https://dtam.pw/music/empty.m4a</location>")
fmt.Fprintln(w, "</track>")
// cycle through our ordered playlist and write it to the file // cycle through our ordered playlist and write it to the file
for _, e := range playlist { for _, e := range playlist {
fmt.Fprintln(w, "<track>") fmt.Fprintln(w, "<track>")