ability to export OPML with podgrab urls

pull/175/head
Akhil Gupta 3 years ago
parent 2382f53b5a
commit 06671b3d01

@ -36,8 +36,11 @@
<div class="columns two">
<a href="/backups" class="button">Backups</a>
</div>
<div class="columns two">
<a href="/opml" class="button">Export OPML</a>
<div class="columns three">
<a href="/opml" class="button" title="Export OPML file with original podcast urls">Export OPML (Original Urls)</a>
</div>
<div class="columns three">
<a href="/opml?usePodgrabLink=true" class="button" title="Export OPML file with Podgrab podcast feed urls">Export OPML (Podgrab Urls)</a>
</div>
<div class="columns two">
<a title="Import this rss feed in your favorite podcast player" target="_blank" href="/rss" class="button">Rss Feed</a>

@ -332,7 +332,10 @@ func Search(c *gin.Context) {
}
func GetOmpl(c *gin.Context) {
data, err := service.ExportOmpl()
usePodgrabLink := c.DefaultQuery("usePodgrabLink", "false") == "true"
data, err := service.ExportOmpl(usePodgrabLink, getBaseUrl(c))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"message": "Invalid request"})
return

@ -141,14 +141,22 @@ func AddOpml(content string) error {
}
func ExportOmpl() ([]byte, error) {
func ExportOmpl(usePodgrabLink bool, baseUrl string) ([]byte, error) {
podcasts := GetAllPodcasts("")
var outlines []model.OpmlOutline
for _, podcast := range *podcasts {
xmlUrl := podcast.URL
if usePodgrabLink {
xmlUrl = fmt.Sprintf("%s/podcasts/%s/rss", baseUrl, podcast.ID)
}
toAdd := model.OpmlOutline{
AttrText: podcast.Summary,
Type: "rss",
XmlUrl: podcast.URL,
XmlUrl: xmlUrl,
Title: podcast.Title,
}
outlines = append(outlines, toAdd)

Loading…
Cancel
Save