Skip to content

Commit

Permalink
go: add json param to cut content after marks
Browse files Browse the repository at this point in the history
can make search results more clear on too verbose
or too keywordy episodes descriptions
  • Loading branch information
azimut committed Mar 31, 2024
1 parent f086435 commit ee5a3b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 8 additions & 1 deletion backend/feeds.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@
"url": "https://seradio.libsyn.com/rss",
"trim_prefixes": ["SE Radio"]
},
{ "url": "https://www.functionalgeekery.com/feed/mp3/" },
{
"url": "https://www.functionalgeekery.com/feed/mp3/",
"content_end_mark": [
"### Announcements",
"### Conference Announcements",
"### Topics"
]
},
{ "title": "SICP Podcast", "url": "https://www.sicpers.info/feed/podcast" },
{
"title": "YT | ColdFusion",
Expand Down
19 changes: 12 additions & 7 deletions backend/src/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import (
const DB_NAME = "./feeds.db"

type Feed struct {
Entries Entries
RawTitle string
Title string `json:"title"`
TrimPrefixes []string `json:"trim_prefixes"`
TrimSuffixes []string `json:"trim_suffixes"`
Description string
Url string `json:"url"`
Entries Entries
RawTitle string
Title string `json:"title"`
TrimPrefixes []string `json:"trim_prefixes"`
TrimSuffixes []string `json:"trim_suffixes"`
ContentEndMark []string `json:"content_end_mark"`
Description string
Url string `json:"url"`
}

type Entry struct {
Expand Down Expand Up @@ -252,6 +253,10 @@ func (feed *Feed) fetch() error {
if metric > 0.1 { // prefer content (3)
entry.Description = ""
}
for _, mark := range feed.ContentEndMark {
before, _, _ := strings.Cut(entry.Content, mark)
entry.Content = before
}
feed.Entries = append(feed.Entries, entry)
}

Expand Down

0 comments on commit ee5a3b8

Please sign in to comment.