Skip to content

Commit 36a1c4f

Browse files
authored
feat: add freshrss.prefixCats (#139)
prefixes the categories from freshrss to the beginning of the etnry same as name option in yaml closes #92
1 parent e3b58f6 commit 36a1c4f

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ backends:
8080
host: http://myfreshrss.bar
8181
user: admin
8282
password: muchstrong
83+
prefixCats: true # prefix feed name for freshrss entries
8384
```
8485

8586
#### FreshRSS

internal/config/backends.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,24 @@ type FreshRSSResponse struct {
3232
Subscriptions []FreshRSSFeed `yaml:"subscriptions,omitempty"`
3333
}
3434

35+
type Cat struct {
36+
Label string `yaml:"label,omitempty"`
37+
}
38+
3539
type FreshRSSFeed struct {
36-
URL string `yaml:"url,omitempty"`
40+
URL string `yaml:"url,omitempty"`
41+
Categories []Cat `yaml:"categories,omitempty"`
42+
}
43+
44+
func (frss FreshRSSFeed) GetCats() string {
45+
ret := ""
46+
for i, v := range frss.Categories {
47+
if i != 0 {
48+
ret += ","
49+
}
50+
ret += v.Label
51+
}
52+
return ret
3753
}
3854

3955
func getFreshRSSFeeds(config *FreshRSSBackend) ([]Feed, error) {
@@ -82,7 +98,11 @@ func getFreshRSSFeeds(config *FreshRSSBackend) ([]Feed, error) {
8298
var ret []Feed
8399

84100
for _, f := range b.Subscriptions {
85-
ret = append(ret, Feed{URL: f.URL})
101+
name := ""
102+
if config.PrefixCats {
103+
name = f.GetCats()
104+
}
105+
ret = append(ret, Feed{URL: f.URL, Name: name})
86106
}
87107

88108
return ret, nil

internal/config/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ type MinifluxBackend struct {
2828
}
2929

3030
type FreshRSSBackend struct {
31-
Host string `yaml:"host"`
32-
User string `yaml:"user"`
33-
Password string `yaml:"password"`
31+
Host string `yaml:"host"`
32+
User string `yaml:"user"`
33+
Password string `yaml:"password"`
34+
PrefixCats bool `yaml:"prefixCats"`
3435
}
3536

3637
type Backends struct {

0 commit comments

Comments
 (0)