Merge pull request #6 from akhilrex/master

Merge from upstream
pull/279/head
kucksdorfs 3 years ago committed by GitHub
commit efd8163c11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,7 +14,7 @@
</a> -->
<h1 align="center" style="margin-bottom:0px">Podgrab</h1>
<p align="center">Current Version -2021.10.01</p>
<p align="center">Current Version -2021.12.03</p>
<p align="center">
A self-hosted podcast manager to download episodes as soon as they become live

@ -694,7 +694,7 @@ div#large-visualization{
<div id="player-left-bottom">
<div id="time-container">
<span class="current-time">
<span class="amplitude-current-minutes" ></span>:<span class="amplitude-current-seconds"></span>
<span class="amplitude-current-hours" ></span>:<span class="amplitude-current-minutes" ></span>:<span class="amplitude-current-seconds"></span>
</span>
<div id="progress-container">

@ -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>
@ -132,7 +135,7 @@
<table>
<tr>
<td>Current Version</td>
<td> 2021.10.01</td>
<td> 2021.12.03</td>
</tr>
<tr>
<td>Website</td>

@ -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

@ -289,7 +289,7 @@ func GetPodcastItemFileById(c *gin.Context) {
c.Header("Content-Description", "File Transfer")
c.Header("Content-Transfer-Encoding", "binary")
c.Header("Content-Disposition", "attachment; filename="+path.Base(podcast.DownloadPath))
c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Type", GetFileContentType(podcast.DownloadPath))
c.File(podcast.DownloadPath)
} else {
c.Redirect(302, podcast.FileURL)
@ -300,6 +300,19 @@ func GetPodcastItemFileById(c *gin.Context) {
}
}
func GetFileContentType(filePath string) string {
file, err := os.Open(filePath)
if err != nil {
return "application/octet-stream"
}
defer file.Close()
buffer := make([]byte, 512)
if _, err := file.Read(buffer); err != nil {
return "application/octet-stream"
}
return http.DetectContentType(buffer)
}
func MarkPodcastItemAsUnplayed(c *gin.Context) {
var searchByIdQuery SearchByIdQuery
@ -439,7 +452,7 @@ func getBaseUrl(c *gin.Context) string {
return setting.BaseUrl
}
func createRss(items []db.PodcastItem, title, description string, c *gin.Context) model.RssPodcastData {
func createRss(items []db.PodcastItem, title, description, image string, c *gin.Context) model.RssPodcastData {
var rssItems []model.RssItem
url := getBaseUrl(c)
for _, item := range items {
@ -468,6 +481,12 @@ func createRss(items []db.PodcastItem, title, description string, c *gin.Context
}
rssItems = append(rssItems, rssItem)
}
imagePath := fmt.Sprintf("%s/webassets/blank.png", url)
if image != "" {
imagePath = image
}
return model.RssPodcastData{
Itunes: "http://www.itunes.com/dtds/podcast-1.0.dtd",
Media: "http://search.yahoo.com/mrss/",
@ -482,7 +501,7 @@ func createRss(items []db.PodcastItem, title, description string, c *gin.Context
Summary: description,
Author: "Podgrab Aggregation",
Link: fmt.Sprintf("%s/allTags", url),
Image: model.RssItemImage{Text: title, Href: fmt.Sprintf("%s/webassets/blank.png", url)},
Image: model.RssItemImage{Text: title, URL: imagePath},
},
}
}
@ -491,7 +510,7 @@ func GetRssForPodcastById(c *gin.Context) {
var searchByIdQuery SearchByIdQuery
if c.ShouldBindUri(&searchByIdQuery) == nil {
var podcast db.Podcast
err:=db.GetPodcastById(searchByIdQuery.Id,&podcast)
err := db.GetPodcastById(searchByIdQuery.Id, &podcast)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
}
@ -503,7 +522,7 @@ func GetRssForPodcastById(c *gin.Context) {
title := podcast.Title
if err == nil {
c.XML(200, createRss(items, title, description, c))
c.XML(200, createRss(items, title, description, podcast.Image, c))
}
} else {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
@ -523,7 +542,7 @@ func GetRssForTagById(c *gin.Context) {
title := fmt.Sprintf(" %s | Podgrab", tag.Label)
if err == nil {
c.XML(200, createRss(items, title, description, c))
c.XML(200, createRss(items, title, description, "", c))
}
} else {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
@ -540,7 +559,7 @@ func GetRss(c *gin.Context) {
title := "Podgrab"
description := "Pograb playlist"
c.XML(200, createRss(items, title, description, c))
c.XML(200, createRss(items, title, description, "", c))
}
func DeleteTagById(c *gin.Context) {

@ -56,6 +56,7 @@ type RssItemEnclosure struct {
type RssItemImage struct {
Text string `xml:",chardata"`
Href string `xml:"href,attr"`
URL string `xml:"url"`
}
type RssItemGuid struct {

@ -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