Browse Source

Fetch the title

master
2577 3 years ago
parent
commit
df1c36bd13
  1. 10
      feed.go
  2. 5
      go.mod
  3. 2
      go.sum

10
feed.go

@ -28,8 +28,9 @@ type queueItem struct {
}
type feedItem struct {
URL string
Date time.Time
URL string
Title string
Date time.Time
}
type feed struct {
@ -115,12 +116,13 @@ func (f *feed) publish() {
feedB := tx.Bucket(feedBucket)
key, _ := time.Now().MarshalBinary()
value, err := json.Marshal(feedItem{url, time.Now()})
value, err := json.Marshal(feedItem{url, getTitle(url), time.Now()})
if err != nil {
log.Printf("Error adding feed item: %v", err)
}
log.Printf("Publish: %s", url)
feedB.Put(key, value)
queueB.Delete([]byte(url))
return nil
})
}
@ -205,7 +207,7 @@ func (f feed) rss() string {
continue
}
channel.Item = append(channel.Item, Item{
Title: item.URL, // TODO
Title: item.Title,
Link: item.URL,
GUID: item.URL,
PubDate: item.Date.Format(rfc2822),

5
go.mod

@ -1 +1,6 @@
module git.sindominio.net/2577/feed
require (
go.etcd.io/bbolt v1.3.3
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7
)

2
go.sum

@ -7,5 +7,7 @@ go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

Loading…
Cancel
Save