pull/114/head
Akhil Gupta 4 years ago
parent 509749e74e
commit 44671d3b07

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

@ -86,6 +86,10 @@
<input type="checkbox" name="downloadEpisodeImages" v-model="downloadEpisodeImages">
<span class="label-body">Download Episode Images with files</span>
</label>
<label for="generateNFOFile">
<input type="checkbox" name="generateNFOFile" v-model="generateNFOFile">
<span class="label-body">Generate NFO files for Podcasts</span>
</label>
<input type="submit" value="Save" class="button">
@ -117,7 +121,7 @@
<table>
<tr>
<td>Current Version</td>
<td>2021.05.06</td>
<td>2021.05.07</td>
</tr>
<tr>
<td>Website</td>
@ -160,8 +164,8 @@ var app = new Vue({
appendDateToFileName:self.appendDateToFileName,
appendEpisodeNumberToFileName:self.appendEpisodeNumberToFileName,
darkMode:self.darkMode,
downloadEpisodeImages:self.downloadEpisodeImages
downloadEpisodeImages:self.downloadEpisodeImages,
generateNFOFile:self.generateNFOFile
})
.then(function(response){
Vue.toasted.show('Settings saved successfully.' ,{
@ -203,6 +207,7 @@ var app = new Vue({
darkMode:{{ .setting.DarkMode }},
originalThemeSetting:{{ .setting.DarkMode }},
downloadEpisodeImages:{{.setting.DownloadEpisodeImages }},
generateNFOFile:{{.setting.GenerateNFOFile }},
},
})

@ -28,6 +28,7 @@ type SettingModel struct {
AppendEpisodeNumberToFileName bool `form:"appendEpisodeNumberToFileName" json:"appendEpisodeNumberToFileName" query:"appendEpisodeNumberToFileName"`
DarkMode bool `form:"darkMode" json:"darkMode" query:"darkMode"`
DownloadEpisodeImages bool `form:"downloadEpisodeImages" json:"downloadEpisodeImages" query:"downloadEpisodeImages"`
GenerateNFOFile bool `form:"generateNFOFile" json:"generateNFOFile" query:"generateNFOFile"`
}
var searchOptions = map[string]string{

@ -465,7 +465,7 @@ func UpdateSetting(c *gin.Context) {
err = service.UpdateSettings(model.DownloadOnAdd, model.InitialDownloadCount,
model.AutoDownload, model.AppendDateToFileName, model.AppendEpisodeNumberToFileName,
model.DarkMode, model.DownloadEpisodeImages)
model.DarkMode, model.DownloadEpisodeImages, model.GenerateNFOFile)
if err == nil {
c.JSON(200, gin.H{"message": "Success"})

@ -82,6 +82,7 @@ type Setting struct {
AppendEpisodeNumberToFileName bool `gorm:"default:false"`
DarkMode bool `gorm:"default:false"`
DownloadEpisodeImages bool `gorm:"default:false"`
GenerateNFOFile bool `gorm:"default:false"`
}
type Migration struct {
Base

@ -3,9 +3,11 @@ package service
import (
"archive/tar"
"compress/gzip"
"encoding/xml"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
@ -15,6 +17,7 @@ import (
"strconv"
"time"
"github.com/akhilrex/podgrab/db"
"github.com/akhilrex/podgrab/internal/sanitize"
stringy "github.com/gobeam/stringy"
)
@ -68,6 +71,32 @@ func GetPodcastLocalImagePath(link string, podcastName string) string {
return finalPath
}
func CreateNfoFile(podcast *db.Podcast) error {
fileName := "album.nfo"
folder := createDataFolderIfNotExists(podcast.Title)
finalPath := path.Join(folder, fileName)
type NFO struct {
XMLName xml.Name `xml:"album"`
Title string `xml:"title"`
Type string `xml:"type"`
Thumb string `xml:"thumb"`
}
toSave := NFO{
Title: podcast.Title,
Type: "Broadcast",
Thumb: podcast.Image,
}
out, err := xml.MarshalIndent(toSave, " ", " ")
if err != nil {
return err
}
toPersist := xml.Header + string(out)
return ioutil.WriteFile(finalPath, []byte(toPersist), 0644)
}
func DownloadPodcastCoverImage(link string, podcastName string) (string, error) {
if link == "" {
return "", errors.New("Download path empty")

@ -198,7 +198,7 @@ func getItunesImageUrl(body []byte) string {
func AddPodcast(url string) (db.Podcast, error) {
var podcast db.Podcast
err := db.GetPodcastByURL(url, &podcast)
setting := db.GetOrCreateSetting()
if errors.Is(err, gorm.ErrRecordNotFound) {
data, body, err := FetchURL(url)
if err != nil {
@ -221,6 +221,9 @@ func AddPodcast(url string) (db.Podcast, error) {
err = db.CreatePodcast(&podcast)
go DownloadPodcastCoverImage(podcast.Image, podcast.Title)
if setting.GenerateNFOFile {
go CreateNfoFile(&podcast)
}
return podcast, err
}
@ -617,6 +620,9 @@ func DeletePodcastEpisodes(id string) error {
}
for _, item := range podcastItems {
DeleteFile(item.DownloadPath)
if item.LocalImage != "" {
DeleteFile(item.LocalImage)
}
SetPodcastItemAsNotDownloaded(item.ID, db.Deleted)
}
@ -719,7 +725,7 @@ func GetSearchFromPodcastIndex(pod *podcastindex.Podcast) *model.CommonSearchRes
return p
}
func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool, appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool) error {
func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool, appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool, generateNFOFile bool) error {
setting := db.GetOrCreateSetting()
setting.AutoDownload = autoDownload
@ -729,6 +735,7 @@ func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload b
setting.AppendEpisodeNumberToFileName = appendEpisodeNumberToFileName
setting.DarkMode = darkMode
setting.DownloadEpisodeImages = downloadEpisodeImages
setting.GenerateNFOFile = generateNFOFile
return db.UpdateSettings(setting)
}

Loading…
Cancel
Save