39 lines
820 B
Go
39 lines
820 B
Go
package nfo
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
|
|
"git.meatbag.se/varl/subsyt/internal/models"
|
|
)
|
|
|
|
func WriteEpisodeNFO(ep models.Episode, info_path string) {
|
|
out_path := strings.Replace(info_path, ".info.json", ".nfo", 1)
|
|
|
|
log.Printf("writing info from '%s' to '%s'\n", info_path, out_path)
|
|
|
|
xmlData, err := xml.MarshalIndent(ep, "", " ")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
complete := xml.Header + string(xmlData)
|
|
log.Printf("%s", complete)
|
|
os.WriteFile(out_path, xmlData, 0644)
|
|
}
|
|
|
|
func WriteShowInfo(show models.Show, out_path string) {
|
|
log.Printf("writing info from '%s' to '%s'\n", show, out_path)
|
|
|
|
xmlData, err := xml.MarshalIndent(show, "", " ")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
complete := xml.Header + string(xmlData)
|
|
log.Printf("%s", complete)
|
|
os.WriteFile(out_path, xmlData, 0644)
|
|
}
|