|
|
@ -98,32 +98,37 @@ func AddOpml(content string) error {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func ExportOmpl() (model.OpmlModel, error) {
|
|
|
|
func ExportOmpl() ([]byte, error) {
|
|
|
|
podcasts := GetAllPodcasts("")
|
|
|
|
podcasts := GetAllPodcasts("")
|
|
|
|
var outlines []model.OpmlOutline
|
|
|
|
var outlines []model.OpmlOutline
|
|
|
|
for _, podcast := range *podcasts {
|
|
|
|
for _, podcast := range *podcasts {
|
|
|
|
toAdd := model.OpmlOutline{
|
|
|
|
toAdd := model.OpmlOutline{
|
|
|
|
AttrText: podcast.Title,
|
|
|
|
AttrText: podcast.Summary,
|
|
|
|
Type: "rss",
|
|
|
|
Type: "rss",
|
|
|
|
XmlUrl: podcast.URL,
|
|
|
|
XmlUrl: podcast.URL,
|
|
|
|
|
|
|
|
Title: podcast.Title,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
outlines = append(outlines, toAdd)
|
|
|
|
outlines = append(outlines, toAdd)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toExport := model.OpmlModel{
|
|
|
|
toExport := model.OpmlModel{
|
|
|
|
Head: model.OpmlHead{
|
|
|
|
Head: model.OpmlHead{
|
|
|
|
Title: "Podgrab Feed Export",
|
|
|
|
Title: "Podgrab Feed Export",
|
|
|
|
|
|
|
|
DateCreated: time.Now(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Body: model.OpmlBody{
|
|
|
|
Body: model.OpmlBody{
|
|
|
|
Outline: outlines,
|
|
|
|
Outline: outlines,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Version: "1.0",
|
|
|
|
Version: "2.0",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
data, err := xml.Marshal(toExport)
|
|
|
|
if data, err := xml.MarshalIndent(toExport, "", " "); err == nil {
|
|
|
|
//return string(data), err
|
|
|
|
// fmt.Println(xml.Header + string(data))
|
|
|
|
fmt.Println(string(data))
|
|
|
|
data = []byte(xml.Header + string(data))
|
|
|
|
return toExport, err
|
|
|
|
return data, err
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func AddPodcast(url string) (db.Podcast, error) {
|
|
|
|
func AddPodcast(url string) (db.Podcast, error) {
|
|
|
|
var podcast db.Podcast
|
|
|
|
var podcast db.Podcast
|
|
|
|