Skip to content
Permalink
Browse files

Improve feed customizations

  • Loading branch information
mxpv committed Mar 8, 2020
1 parent 7ca1d03 commit f3565b2895a0a1fa76bf4aee7d7d93e824e9e3d7
Showing with 35 additions and 11 deletions.
  1. +1 −1 README.md
  2. +9 −0 pkg/config/config.go
  3. +6 −0 pkg/config/config_test.go
  4. +0 −1 pkg/db/badger_test.go
  5. +19 −7 pkg/feed/build.go
  6. +0 −2 pkg/model/feed.go
@@ -23,7 +23,7 @@ any device in podcast client.
- mp3 encoding
- Update scheduler supports cron expressions
- Episodes filtering (match by title).
- Feeds customizations (custom artwork).
- Feeds customizations (custom artwork, category, language, etc).
- Supports episodes cleanup (keep last X episodes).
- One-click deployment for AWS.
- Runs on Windows, Mac OS, Linux, and Docker.
@@ -40,6 +40,15 @@ type Feed struct {
Filters Filters `toml:"filters"`
// Clean is a cleanup policy to use for this feed
Clean Cleanup `toml:"clean"`
// Custom is a list of feed customizations
Custom Custom `toml:"custom"`
}

type Custom struct {
CoverArt string `toml:"cover_art"`
Category string `toml:"category"`
Explicit bool `toml:"explicit"`
Language string `toml:"lang"`
}

type Tokens struct {
@@ -34,6 +34,7 @@ dir = "/home/user/db/"
quality = "low"
filters = { title = "regex for title here" }
clean = { keep_last = 10 }
custom = { cover_art = "http://img", category = "TV", explicit = true, lang = "en" }
`

f, err := ioutil.TempFile("", "")
@@ -66,6 +67,11 @@ dir = "/home/user/db/"
assert.EqualValues(t, "low", feed.Quality)
assert.EqualValues(t, "regex for title here", feed.Filters.Title)
assert.EqualValues(t, 10, feed.Clean.KeepLast)

assert.EqualValues(t, "http://img", feed.Custom.CoverArt)
assert.EqualValues(t, "TV", feed.Custom.Category)
assert.True(t, feed.Custom.Explicit)
assert.EqualValues(t, "en", feed.Custom.Language)
}

func TestApplyDefaults(t *testing.T) {
@@ -196,7 +196,6 @@ func getFeed() *model.Feed {
Format: "video",
Quality: "high",
PageSize: 50,
Language: "en",
Title: "Test",
Description: "Test",
PubDate: time.Now().UTC(),
@@ -23,24 +23,36 @@ func Build(ctx context.Context, feed *model.Feed, cfg *config.Feed, provider url
defaultCategory = "TV & Film"
)

now := time.Now().UTC()
var (
now = time.Now().UTC()
)

p := itunes.New(feed.Title, feed.ItemURL, feed.Description, &feed.PubDate, &now)
p.Generator = podsyncGenerator
p.AddSubTitle(feed.Title)
p.AddCategory(defaultCategory, nil)
p.AddImage(feed.CoverArt)
p.IAuthor = feed.Title
p.AddSummary(feed.Description)

if feed.Explicit {
if cfg.Custom.CoverArt != "" {
p.AddImage(cfg.Custom.CoverArt)
} else {
p.AddImage(feed.CoverArt)
}

if cfg.Custom.Category != "" {
p.AddCategory(cfg.Custom.Category, nil)
} else {
p.AddCategory(defaultCategory, nil)
}

if cfg.Custom.Explicit {
p.IExplicit = "yes"
} else {
p.IExplicit = "no"
}

if feed.Language != "" {
p.Language = feed.Language
if cfg.Custom.Language != "" {
p.Language = cfg.Custom.Language
}

for i, episode := range feed.Episodes {
@@ -87,7 +99,7 @@ func Build(ctx context.Context, feed *model.Feed, cfg *config.Feed, provider url
item.Description = " "
}

if feed.Explicit {
if cfg.Custom.Explicit {
item.IExplicit = "yes"
} else {
item.IExplicit = "no"
@@ -48,8 +48,6 @@ type Feed struct {
Quality Quality `json:"quality"`
PageSize int `json:"page_size"`
CoverArt string `json:"cover_art"`
Explicit bool `json:"explicit"`
Language string `json:"language"` // ISO 639
Title string `json:"title"`
Description string `json:"description"`
PubDate time.Time `json:"pub_date"`

0 comments on commit f3565b2

Please sign in to comment.
You can’t perform that action at this time.