From 53fa26b1d5507abf1920c7e7d47a9430b041337c Mon Sep 17 00:00:00 2001 From: Eric Duncan Date: Wed, 28 Oct 2020 18:24:23 -0400 Subject: [PATCH 1/2] Add Podcast Owner Custom Definitions per #171 Some users were saying their podcasts were getting rejected since `podcast.IOwner` wasn't being set. This PR adds that functionality to issue #171. * Did not disturb existing custom Author string, as users may already be using that (wasn't sure on the backwards compatibility with this repo). * "Name" needed a prefix, since there was already Title and Description. Picked `Owner` for now. * Added to existing Unit Test to ensure it gets set when custom config is used. NOTE: I do not have a way to test this as I do not use this repo. This is just a drive-by PR to help the authors. --- pkg/config/config.go | 2 ++ pkg/config/config_test.go | 15 ++++++++++++++- pkg/feed/xml.go | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 9052a410..6930f1dd 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -65,6 +65,8 @@ type Custom struct { Author string `toml:"author"` Title string `toml:"title"` Description string `toml:"description"` + OwnerName string `toml:"ownerName"` + OwnerEmail string `toml:"ownerEmail"` } type Server struct { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index f71a6301..60aabdfa 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -41,7 +41,17 @@ timeout = 15 quality = "low" filters = { title = "regex for title here" } clean = { keep_last = 10 } - custom = { cover_art = "http://img", cover_art_quality = "high", category = "TV", subcategories = ["1", "2"], explicit = true, lang = "en" } + custom = { + cover_art = "http://img", + cover_art_quality = "high", + category = "TV", + subcategories = ["1", "2"], + explicit = true, + lang = "en", + author = "Mrs. Smith (mrs@smith.org)", + ownerName = "Mrs. Smith", + ownerEmail = "mrs@smith.org" + } ` path := setup(t, file) defer os.Remove(path) @@ -77,6 +87,9 @@ timeout = 15 assert.EqualValues(t, "TV", feed.Custom.Category) assert.True(t, feed.Custom.Explicit) assert.EqualValues(t, "en", feed.Custom.Language) + assert.EqualValues(t, "Mrs. Smith (mrs@smith.org)", feed.Custom.Author) + assert.EqualValues(t, "Mrs. Smith", feed.Custom.OwnerName) + assert.EqualValues(t, "mrs@smith.org", feed.Custom.OwnerEmail) assert.EqualValues(t, feed.Custom.Subcategories, []string{"1", "2"}) diff --git a/pkg/feed/xml.go b/pkg/feed/xml.go index c4f17ca9..40769e36 100644 --- a/pkg/feed/xml.go +++ b/pkg/feed/xml.go @@ -61,6 +61,13 @@ func Build(ctx context.Context, feed *model.Feed, cfg *config.Feed, provider url p.IAuthor = author p.AddSummary(description) + if cfg.Custom.OwnerName != "" && cfg.Custom.OwnerEmail != "" { + p.IOwner = &itunes.Author{ + Name: cfg.Custom.OwnerName, + Email: cfg.Custom.OwnerEmail, + } + } + if cfg.Custom.CoverArt != "" { p.AddImage(cfg.Custom.CoverArt) } else { From c52cffa2ffa97aca43aa02bbeddab9136a592d3c Mon Sep 17 00:00:00 2001 From: Eric Duncan Date: Wed, 28 Oct 2020 18:42:13 -0400 Subject: [PATCH 2/2] Fix TOML inline table definition in Tests --- pkg/config/config_test.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 60aabdfa..8a1694ee 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -41,17 +41,16 @@ timeout = 15 quality = "low" filters = { title = "regex for title here" } clean = { keep_last = 10 } - custom = { - cover_art = "http://img", - cover_art_quality = "high", - category = "TV", - subcategories = ["1", "2"], - explicit = true, - lang = "en", - author = "Mrs. Smith (mrs@smith.org)", - ownerName = "Mrs. Smith", - ownerEmail = "mrs@smith.org" - } + [feeds.XYZ.custom] + cover_art = "http://img" + cover_art_quality = "high" + category = "TV" + subcategories = ["1", "2"] + explicit = true + lang = "en" + author = "Mrs. Smith (mrs@smith.org)" + ownerName = "Mrs. Smith" + ownerEmail = "mrs@smith.org" ` path := setup(t, file) defer os.Remove(path)