Skip to content

Commit

Permalink
go: add episode_blacklist support
Browse files Browse the repository at this point in the history
  • Loading branch information
azimut committed Sep 12, 2024
1 parent 75518a6 commit b059eef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions jobs/go/feeds.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"feeds": [
{
"name": "Tech Over Tea",
"url": "https://anchor.fm/s/149fd51c/podcast/rss",
"episode_blacklist": ["Solo", "Solo Episode"]
},
{ "url": "https://bdebob.com/category/epsecretos/feed/" },
{ "url": "https://bdebob.com/category/bdebobpodcast/feed/" },
{
Expand Down
24 changes: 18 additions & 6 deletions jobs/go/src/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ type Address struct {
}

type Feed struct {
Url string `json:"url"`
Title string `json:"title"`
TrimPrefixes []string `json:"trim_prefixes"`
TrimSuffixes []string `json:"trim_suffixes"`
ContentEndMark []string `json:"content_end_mark"`
ContentExclude []Address `json:"content_exclude"`
Url string `json:"url"`
Title string `json:"title"`
TrimPrefixes []string `json:"trim_prefixes"`
TrimSuffixes []string `json:"trim_suffixes"`
EpisodeBlackList []string `json:"episode_blacklist"`
ContentEndMark []string `json:"content_end_mark"`
ContentExclude []Address `json:"content_exclude"`

RawId int
RawEtag string
Expand Down Expand Up @@ -102,6 +103,7 @@ func (feed *Feed) Fetch() error {

html2md := md.NewConverter("", true, nil)

var keepItem bool
for _, item := range rawFeed.Items {
// Process only NEW entries, after last fetch (avoid INSERT attempts)
if item.PublishedParsed.Before(feed.RawLastFetch) {
Expand All @@ -114,6 +116,16 @@ func (feed *Feed) Fetch() error {
Description: item.Description,
Content: item.Content,
}
keepItem = true
for _, word := range feed.EpisodeBlackList {
if strings.Contains(entry.Title, word) {
keepItem = false
break
}
}
if !keepItem {
continue
}
if item.Content == item.Description { // prefer content
entry.Description = ""
}
Expand Down

0 comments on commit b059eef

Please sign in to comment.