mirror of
https://github.com/gmemstr/pogo.git
synced 2024-09-20 01:31:09 +01:00
Implementing configuration
Very tired. Must sleep. Wanted to work. Working on making config.json a thing so rss feed can be edited outside of the code.
This commit is contained in:
parent
baa3ef76ae
commit
a78472364c
7
config.json
Normal file
7
config.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"Name": "Git Galaxy Stargazers",
|
||||||
|
"Host": "Gabriel Simmer",
|
||||||
|
"Email": "gabriel@gitgalaxy.com",
|
||||||
|
"Image": "https://podcast.gitgalaxy.com/assets/podcast_image.png",
|
||||||
|
"PodcastUrl": "https://podcast.gitgalaxy.com"
|
||||||
|
}
|
15
feed.json
15
feed.json
|
@ -1,21 +1,16 @@
|
||||||
{
|
{
|
||||||
"version": "https://jsonfeed.org/version/1",
|
"version": "https://jsonfeed.org/version/1",
|
||||||
"title": "Git Galaxy Stargazers",
|
"title": "",
|
||||||
"home_page_url": "https://gitgalaxy.com",
|
|
||||||
"description": "discussion about open source projects",
|
"description": "discussion about open source projects",
|
||||||
"author": {
|
"author": {},
|
||||||
"name": "Gabriel Simmer"
|
|
||||||
},
|
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"id": "",
|
"id": "",
|
||||||
"url": "https://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3",
|
"url": "/download/2017-07-12_TESTING WORLD.mp3",
|
||||||
"title": "TESTING WORLD",
|
"title": "TESTING WORLD",
|
||||||
"summary": "Hello, World!",
|
"summary": "testing4",
|
||||||
"date_published": "2017-07-12T00:00:00Z",
|
"date_published": "2017-07-12T00:00:00Z",
|
||||||
"author": {
|
"author": {}
|
||||||
"name": "Gabriel Simmer"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
15
feed.rss
15
feed.rss
|
@ -1,20 +1,19 @@
|
||||||
<?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>Git Galaxy Stargazers</title>
|
<title></title>
|
||||||
<link>https://gitgalaxy.com</link>
|
<link></link>
|
||||||
<description>discussion about open source projects</description>
|
<description>discussion about open source projects</description>
|
||||||
<managingEditor>gabriel@gitgalaxy.com (Gabriel Simmer)</managingEditor>
|
<pubDate>Sat, 01 Jul 2017 00:23:10 -0700</pubDate>
|
||||||
<pubDate>Mon, 19 Jun 2017 07:36:34 -0700</pubDate>
|
|
||||||
<image>
|
<image>
|
||||||
<url>https://podcast.gitgalaxy.com/assets/podcast_image.png</url>
|
<url></url>
|
||||||
<title></title>
|
<title></title>
|
||||||
<link></link>
|
<link></link>
|
||||||
</image>
|
</image>
|
||||||
<item>
|
<item>
|
||||||
<title>TESTING WORLD</title>
|
<title>TESTING WORLD</title>
|
||||||
<link>https://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3</link>
|
<link>/download/2017-07-12_TESTING WORLD.mp3</link>
|
||||||
<description>Hello, World!</description>
|
<description>testing4</description>
|
||||||
<enclosure url="https://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3" length="100" type="audio/mpeg"></enclosure>
|
<enclosure url="/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,8 +9,17 @@ import (
|
||||||
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/gmemstr/feeds"
|
"github.com/gmemstr/feeds"
|
||||||
|
"github.com/Tkanos/gonfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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 {
|
||||||
|
@ -42,6 +51,12 @@ func watch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func generate_rss() {
|
func generate_rss() {
|
||||||
|
configuration := Configuration{}
|
||||||
|
err := gonfig.GetConf("config.json", &configuration)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(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 {
|
||||||
|
@ -49,31 +64,37 @@ func generate_rss() {
|
||||||
}
|
}
|
||||||
|
|
||||||
feed := &feeds.Feed{
|
feed := &feeds.Feed{
|
||||||
Title: "Git Galaxy Stargazers",
|
Title: configuration.Name,
|
||||||
Link: &feeds.Link{Href: "https://gitgalaxy.com"},
|
Link: &feeds.Link{Href: configuration.PodcastUrl},
|
||||||
Description: "discussion about open source projects",
|
Description: "discussion about open source projects",
|
||||||
Author: &feeds.Author{Name: "Gabriel Simmer", Email: "gabriel@gitgalaxy.com"},
|
Author: &feeds.Author{Name: configuration.Host, Email: configuration.Email},
|
||||||
Created: now,
|
Created: now,
|
||||||
Image: &feeds.Image{Url: "https://podcast.gitgalaxy.com/assets/podcast_image.png"},
|
Image: &feeds.Image{Url: configuration.Image},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
s := strings.Split(file.Name(), "_")
|
if strings.Contains(file.Name(), ".mp3") {
|
||||||
t := strings.Split(s[1], ".")
|
s := strings.Split(file.Name(), "_")
|
||||||
title := t[0]
|
t := strings.Split(s[1], ".")
|
||||||
date, err := time.Parse("2006-01-02", s[0])
|
title := t[0]
|
||||||
if err != nil {
|
description,err := ioutil.ReadFile("podcasts/" + strings.Replace(file.Name(), ".mp3", "_SHOWNOTES.md", 2))
|
||||||
log.Fatal(err)
|
if err != nil {
|
||||||
}
|
log.Fatal(err)
|
||||||
feed.Items = []*feeds.Item{
|
}
|
||||||
&feeds.Item{
|
date, err := time.Parse("2006-01-02", s[0])
|
||||||
Title: title,
|
if err != nil {
|
||||||
Link: &feeds.Link{Href: "https://podcast.gitgalaxy.com/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
log.Fatal(err)
|
||||||
Enclosure: &feeds.Enclosure{Url: "https://podcast.gitgalaxy.com/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
}
|
||||||
Description: "Hello, World!",
|
feed.Items = []*feeds.Item{
|
||||||
Author: &feeds.Author{Name: "Gabriel Simmer", Email: "gabriel@gitgalaxy.com"},
|
&feeds.Item{
|
||||||
Created: date,
|
Title: title,
|
||||||
},
|
Link: &feeds.Link{Href: configuration.PodcastUrl + "/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
||||||
|
Enclosure: &feeds.Enclosure{Url: configuration.PodcastUrl + "/download/" + file.Name(), Length: "100", Type: "audio/mpeg"},
|
||||||
|
Description: string(description),
|
||||||
|
Author: &feeds.Author{Name: configuration.Host, Email: configuration.Email},
|
||||||
|
Created: date,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rss, err := feed.ToRss()
|
rss, err := feed.ToRss()
|
||||||
|
|
Loading…
Reference in a new issue