From 06671b3d01390b006264ceffc04d8b05d1c19d0f Mon Sep 17 00:00:00 2001 From: Akhil Gupta Date: Fri, 3 Dec 2021 14:10:22 +0530 Subject: [PATCH] ability to export OPML with podgrab urls --- client/settings.html | 7 +++++-- controllers/pages.go | 5 ++++- service/podcastService.go | 12 ++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/client/settings.html b/client/settings.html index 6beba6c..2931050 100644 --- a/client/settings.html +++ b/client/settings.html @@ -36,8 +36,11 @@
Backups
-
- Export OPML + +
Rss Feed diff --git a/controllers/pages.go b/controllers/pages.go index 7f2660d..2034e22 100644 --- a/controllers/pages.go +++ b/controllers/pages.go @@ -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 diff --git a/service/podcastService.go b/service/podcastService.go index 8efa1fa..345d2a2 100644 --- a/service/podcastService.go +++ b/service/podcastService.go @@ -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)