mirror of
https://github.com/gmemstr/pogo.git
synced 2024-09-20 01:31:09 +01:00
gonfig -> viper for configuration file
Currently focusing on the RSS generation, JSON will come later - that is more aimed at the frontend or external apps. Have to have feeds fully validating on https://validator.w3.org/feed/ before being deemed "acceptable" and "production ready". Will be writing a lot of changes to my feeds fork, which will not be pulled into the main feeds repository.
This commit is contained in:
parent
a78472364c
commit
80dd22004b
15
feed.json
15
feed.json
|
@ -1,16 +1,21 @@
|
||||||
{
|
{
|
||||||
"version": "https://jsonfeed.org/version/1",
|
"version": "https://jsonfeed.org/version/1",
|
||||||
"title": "",
|
"title": "Git Galaxy Stargazers",
|
||||||
|
"home_page_url": "https://podcast.gitgalaxy.com",
|
||||||
"description": "discussion about open source projects",
|
"description": "discussion about open source projects",
|
||||||
"author": {},
|
"author": {
|
||||||
|
"name": "Gabriel Simmer"
|
||||||
|
},
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"id": "",
|
"id": "",
|
||||||
"url": "/download/2017-07-12_TESTING WORLD.mp3",
|
"url": "https://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3",
|
||||||
"title": "TESTING WORLD",
|
"title": "TESTING WORLD",
|
||||||
"summary": "testing4",
|
"summary": "In this episode, Gabriel discusses the format of the podcast, rambles about his complete lack of knowledge of Machine Learning, and covers a couple interesting Machine Learning centered projects.",
|
||||||
"date_published": "2017-07-12T00:00:00Z",
|
"date_published": "2017-07-12T00:00:00Z",
|
||||||
"author": {}
|
"author": {
|
||||||
|
"name": "Gabriel Simmer"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
19
feed.rss
19
feed.rss
|
@ -1,19 +1,20 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">
|
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<title></title>
|
<title>Git Galaxy Stargazers</title>
|
||||||
<link></link>
|
<link>http://podcast.gitgalaxy.com</link>
|
||||||
<description>discussion about open source projects</description>
|
<description>discussion about open source projects</description>
|
||||||
<pubDate>Sat, 01 Jul 2017 00:23:10 -0700</pubDate>
|
<managingEditor>gabriel@gitgalaxy.com (Gabriel Simmer)</managingEditor>
|
||||||
|
<pubDate>Sat, 01 Jul 2017 23:35:38 -0700</pubDate>
|
||||||
<image>
|
<image>
|
||||||
<url></url>
|
<url>http://podcast.gitgalaxy.com/assets/podcast_image.png</url>
|
||||||
<title></title>
|
<title>http://podcast.gitgalaxy.com/assets/podcast_image.png</title>
|
||||||
<link></link>
|
<link>http://podcast.gitgalaxy.com/assets/podcast_image.png</link>
|
||||||
</image>
|
</image>
|
||||||
<item>
|
<item>
|
||||||
<title>TESTING WORLD</title>
|
<title>TESTING WORLD</title>
|
||||||
<link>/download/2017-07-12_TESTING WORLD.mp3</link>
|
<link>http://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3</link>
|
||||||
<description>testing4</description>
|
<description>In this episode, Gabriel discusses the format of the podcast, rambles about his complete lack of knowledge of Machine Learning, and covers a couple interesting Machine Learning centered projects.</description>
|
||||||
<enclosure url="/download/2017-07-12_TESTING WORLD.mp3" length="100" type="audio/mpeg"></enclosure>
|
<enclosure url="http://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3" length="100" type="audio/mpeg"></enclosure>
|
||||||
<pubDate>Wed, 12 Jul 2017 00:00:00 +0000</pubDate>
|
<pubDate>Wed, 12 Jul 2017 00:00:00 +0000</pubDate>
|
||||||
</item>
|
</item>
|
||||||
</channel>
|
</channel>
|
||||||
|
|
|
@ -9,17 +9,9 @@ import (
|
||||||
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/gmemstr/feeds"
|
"github.com/gmemstr/feeds"
|
||||||
"github.com/Tkanos/gonfig"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Configuration struct {
|
|
||||||
Name string
|
|
||||||
Host string
|
|
||||||
Email string
|
|
||||||
Image string
|
|
||||||
PodcastUrl string
|
|
||||||
}
|
|
||||||
|
|
||||||
func watch() {
|
func watch() {
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -51,12 +43,12 @@ func watch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func generate_rss() {
|
func generate_rss() {
|
||||||
configuration := Configuration{}
|
viper.SetConfigName("config")
|
||||||
err := gonfig.GetConf("config.json", &configuration)
|
viper.AddConfigPath(".")
|
||||||
if err != nil {
|
err := viper.ReadInConfig() // Find and read the config file
|
||||||
log.Fatal(err)
|
if err != nil { // Handle errors reading the config file
|
||||||
|
panic(fmt.Errorf("Fatal error config file: %s \n", err))
|
||||||
}
|
}
|
||||||
fmt.Println(configuration)
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
files, err := ioutil.ReadDir("podcasts")
|
files, err := ioutil.ReadDir("podcasts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -64,12 +56,12 @@ func generate_rss() {
|
||||||
}
|
}
|
||||||
|
|
||||||
feed := &feeds.Feed{
|
feed := &feeds.Feed{
|
||||||
Title: configuration.Name,
|
Title: viper.GetString("Name"),
|
||||||
Link: &feeds.Link{Href: configuration.PodcastUrl},
|
Link: &feeds.Link{Href: viper.GetString("PodcastUrl")},
|
||||||
Description: "discussion about open source projects",
|
Description: "discussion about open source projects",
|
||||||
Author: &feeds.Author{Name: configuration.Host, Email: configuration.Email},
|
Author: &feeds.Author{Name: viper.GetString("Host"), Email:viper.GetString("Email")},
|
||||||
Created: now,
|
Created: now,
|
||||||
Image: &feeds.Image{Url: configuration.Image},
|
Image: &feeds.Image{Url: viper.GetString("Image")},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
|
@ -88,10 +80,10 @@ func generate_rss() {
|
||||||
feed.Items = []*feeds.Item{
|
feed.Items = []*feeds.Item{
|
||||||
&feeds.Item{
|
&feeds.Item{
|
||||||
Title: title,
|
Title: title,
|
||||||
Link: &feeds.Link{Href: configuration.PodcastUrl + "/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
Link: &feeds.Link{Href: viper.GetString("PodcastUrl") + "/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
||||||
Enclosure: &feeds.Enclosure{Url: configuration.PodcastUrl + "/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
Enclosure: &feeds.Enclosure{Url: viper.GetString("PodcastUrl") + "/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
||||||
Description: string(description),
|
Description: string(description),
|
||||||
Author: &feeds.Author{Name: configuration.Host, Email: configuration.Email},
|
Author: &feeds.Author{Name: viper.GetString("Host"), Email: viper.GetString("Email")},
|
||||||
Created: date,
|
Created: date,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue