mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Improve feed customizations
This commit is contained in:
@@ -23,7 +23,7 @@ any device in podcast client.
|
|||||||
- mp3 encoding
|
- mp3 encoding
|
||||||
- Update scheduler supports cron expressions
|
- Update scheduler supports cron expressions
|
||||||
- Episodes filtering (match by title).
|
- Episodes filtering (match by title).
|
||||||
- Feeds customizations (custom artwork).
|
- Feeds customizations (custom artwork, category, language, etc).
|
||||||
- Supports episodes cleanup (keep last X episodes).
|
- Supports episodes cleanup (keep last X episodes).
|
||||||
- One-click deployment for AWS.
|
- One-click deployment for AWS.
|
||||||
- Runs on Windows, Mac OS, Linux, and Docker.
|
- Runs on Windows, Mac OS, Linux, and Docker.
|
||||||
|
@@ -40,6 +40,15 @@ type Feed struct {
|
|||||||
Filters Filters `toml:"filters"`
|
Filters Filters `toml:"filters"`
|
||||||
// Clean is a cleanup policy to use for this feed
|
// Clean is a cleanup policy to use for this feed
|
||||||
Clean Cleanup `toml:"clean"`
|
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 {
|
type Tokens struct {
|
||||||
|
@@ -34,6 +34,7 @@ dir = "/home/user/db/"
|
|||||||
quality = "low"
|
quality = "low"
|
||||||
filters = { title = "regex for title here" }
|
filters = { title = "regex for title here" }
|
||||||
clean = { keep_last = 10 }
|
clean = { keep_last = 10 }
|
||||||
|
custom = { cover_art = "http://img", category = "TV", explicit = true, lang = "en" }
|
||||||
`
|
`
|
||||||
|
|
||||||
f, err := ioutil.TempFile("", "")
|
f, err := ioutil.TempFile("", "")
|
||||||
@@ -66,6 +67,11 @@ dir = "/home/user/db/"
|
|||||||
assert.EqualValues(t, "low", feed.Quality)
|
assert.EqualValues(t, "low", feed.Quality)
|
||||||
assert.EqualValues(t, "regex for title here", feed.Filters.Title)
|
assert.EqualValues(t, "regex for title here", feed.Filters.Title)
|
||||||
assert.EqualValues(t, 10, feed.Clean.KeepLast)
|
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) {
|
func TestApplyDefaults(t *testing.T) {
|
||||||
|
@@ -196,7 +196,6 @@ func getFeed() *model.Feed {
|
|||||||
Format: "video",
|
Format: "video",
|
||||||
Quality: "high",
|
Quality: "high",
|
||||||
PageSize: 50,
|
PageSize: 50,
|
||||||
Language: "en",
|
|
||||||
Title: "Test",
|
Title: "Test",
|
||||||
Description: "Test",
|
Description: "Test",
|
||||||
PubDate: time.Now().UTC(),
|
PubDate: time.Now().UTC(),
|
||||||
|
@@ -23,24 +23,36 @@ func Build(ctx context.Context, feed *model.Feed, cfg *config.Feed, provider url
|
|||||||
defaultCategory = "TV & Film"
|
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 := itunes.New(feed.Title, feed.ItemURL, feed.Description, &feed.PubDate, &now)
|
||||||
p.Generator = podsyncGenerator
|
p.Generator = podsyncGenerator
|
||||||
p.AddSubTitle(feed.Title)
|
p.AddSubTitle(feed.Title)
|
||||||
p.AddCategory(defaultCategory, nil)
|
|
||||||
p.AddImage(feed.CoverArt)
|
|
||||||
p.IAuthor = feed.Title
|
p.IAuthor = feed.Title
|
||||||
p.AddSummary(feed.Description)
|
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"
|
p.IExplicit = "yes"
|
||||||
} else {
|
} else {
|
||||||
p.IExplicit = "no"
|
p.IExplicit = "no"
|
||||||
}
|
}
|
||||||
|
|
||||||
if feed.Language != "" {
|
if cfg.Custom.Language != "" {
|
||||||
p.Language = feed.Language
|
p.Language = cfg.Custom.Language
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, episode := range feed.Episodes {
|
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 = " "
|
item.Description = " "
|
||||||
}
|
}
|
||||||
|
|
||||||
if feed.Explicit {
|
if cfg.Custom.Explicit {
|
||||||
item.IExplicit = "yes"
|
item.IExplicit = "yes"
|
||||||
} else {
|
} else {
|
||||||
item.IExplicit = "no"
|
item.IExplicit = "no"
|
||||||
|
@@ -48,8 +48,6 @@ type Feed struct {
|
|||||||
Quality Quality `json:"quality"`
|
Quality Quality `json:"quality"`
|
||||||
PageSize int `json:"page_size"`
|
PageSize int `json:"page_size"`
|
||||||
CoverArt string `json:"cover_art"`
|
CoverArt string `json:"cover_art"`
|
||||||
Explicit bool `json:"explicit"`
|
|
||||||
Language string `json:"language"` // ISO 639
|
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
PubDate time.Time `json:"pub_date"`
|
PubDate time.Time `json:"pub_date"`
|
||||||
|
Reference in New Issue
Block a user