diff --git a/config.json b/config.json new file mode 100644 index 0000000..93a8e28 --- /dev/null +++ b/config.json @@ -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" +} \ No newline at end of file diff --git a/feed.json b/feed.json index ed5704b..e93a407 100644 --- a/feed.json +++ b/feed.json @@ -1,21 +1,16 @@ { "version": "https://jsonfeed.org/version/1", - "title": "Git Galaxy Stargazers", - "home_page_url": "https://gitgalaxy.com", + "title": "", "description": "discussion about open source projects", - "author": { - "name": "Gabriel Simmer" - }, + "author": {}, "items": [ { "id": "", - "url": "https://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3", + "url": "/download/2017-07-12_TESTING WORLD.mp3", "title": "TESTING WORLD", - "summary": "Hello, World!", + "summary": "testing4", "date_published": "2017-07-12T00:00:00Z", - "author": { - "name": "Gabriel Simmer" - } + "author": {} } ] } \ No newline at end of file diff --git a/feed.rss b/feed.rss index 5dbeeb7..2579646 100644 --- a/feed.rss +++ b/feed.rss @@ -1,20 +1,19 @@ - Git Galaxy Stargazers - https://gitgalaxy.com + + discussion about open source projects - gabriel@gitgalaxy.com (Gabriel Simmer) - Mon, 19 Jun 2017 07:36:34 -0700 + Sat, 01 Jul 2017 00:23:10 -0700 - https://podcast.gitgalaxy.com/assets/podcast_image.png + TESTING WORLD - https://podcast.gitgalaxy.com/download/2017-07-12_TESTING WORLD.mp3 - Hello, World! - + /download/2017-07-12_TESTING WORLD.mp3 + testing4 + Wed, 12 Jul 2017 00:00:00 +0000 diff --git a/generate_rss.go b/generate_rss.go index 6d1807a..536ebf7 100644 --- a/generate_rss.go +++ b/generate_rss.go @@ -9,8 +9,17 @@ import ( "github.com/fsnotify/fsnotify" "github.com/gmemstr/feeds" + "github.com/Tkanos/gonfig" ) +type Configuration struct { + Name string + Host string + Email string + Image string + PodcastUrl string +} + func watch() { watcher, err := fsnotify.NewWatcher() if err != nil { @@ -42,6 +51,12 @@ func watch() { } func generate_rss() { + configuration := Configuration{} + err := gonfig.GetConf("config.json", &configuration) + if err != nil { + log.Fatal(err) + } + fmt.Println(configuration) now := time.Now() files, err := ioutil.ReadDir("podcasts") if err != nil { @@ -49,31 +64,37 @@ func generate_rss() { } feed := &feeds.Feed{ - Title: "Git Galaxy Stargazers", - Link: &feeds.Link{Href: "https://gitgalaxy.com"}, + Title: configuration.Name, + Link: &feeds.Link{Href: configuration.PodcastUrl}, 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, - Image: &feeds.Image{Url: "https://podcast.gitgalaxy.com/assets/podcast_image.png"}, + Image: &feeds.Image{Url: configuration.Image}, } for _, file := range files { - s := strings.Split(file.Name(), "_") - t := strings.Split(s[1], ".") - title := t[0] - date, err := time.Parse("2006-01-02", s[0]) - if err != nil { - log.Fatal(err) - } - feed.Items = []*feeds.Item{ - &feeds.Item{ - Title: title, - Link: &feeds.Link{Href: "https://podcast.gitgalaxy.com/download/" + file.Name(), Length: "100", Type: "audio/mpeg"}, - Enclosure: &feeds.Enclosure{Url: "https://podcast.gitgalaxy.com/download/" + file.Name(), Length: "100", Type: "audio/mpeg"}, - Description: "Hello, World!", - Author: &feeds.Author{Name: "Gabriel Simmer", Email: "gabriel@gitgalaxy.com"}, - Created: date, - }, + if strings.Contains(file.Name(), ".mp3") { + s := strings.Split(file.Name(), "_") + t := strings.Split(s[1], ".") + title := t[0] + description,err := ioutil.ReadFile("podcasts/" + strings.Replace(file.Name(), ".mp3", "_SHOWNOTES.md", 2)) + if err != nil { + log.Fatal(err) + } + date, err := time.Parse("2006-01-02", s[0]) + if err != nil { + log.Fatal(err) + } + feed.Items = []*feeds.Item{ + &feeds.Item{ + 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()