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"> <div class="columns two">
<a href="/backups" class="button">Backups</a> <a href="/backups" class="button">Backups</a>
</div> </div>
<div class="columns two"> <div class="columns three">
<a href="/opml" class="button">Export OPML</a> <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>
<div class="columns two"> <div class="columns two">
<a title="Import this rss feed in your favorite podcast player" target="_blank" href="/rss" class="button">Rss Feed</a> <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) { 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 { if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"message": "Invalid request"}) c.JSON(http.StatusBadRequest, gin.H{"message": "Invalid request"})
return return

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

Loading…
Cancel
Save