2009-11-23 12:46:12 +00:00
|
|
|
package feeder
|
|
|
|
|
2013-12-05 15:18:13 +00:00
|
|
|
import (
|
|
|
|
"crypto/md5"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
2009-11-23 12:46:12 +00:00
|
|
|
type Item struct {
|
|
|
|
// RSS and Shared fields
|
2010-05-23 14:21:30 +00:00
|
|
|
Title string
|
2010-12-17 23:25:16 +00:00
|
|
|
Links []*Link
|
2010-05-23 14:21:30 +00:00
|
|
|
Description string
|
|
|
|
Author Author
|
2010-12-17 23:25:16 +00:00
|
|
|
Categories []*Category
|
2010-05-23 14:21:30 +00:00
|
|
|
Comments string
|
2010-12-17 23:25:16 +00:00
|
|
|
Enclosures []*Enclosure
|
2013-11-28 09:22:09 +00:00
|
|
|
Guid *string
|
2010-05-23 14:21:30 +00:00
|
|
|
PubDate string
|
2010-12-17 23:25:16 +00:00
|
|
|
Source *Source
|
2009-11-23 12:46:12 +00:00
|
|
|
|
|
|
|
// Atom specific fields
|
2010-05-23 14:21:30 +00:00
|
|
|
Id string
|
2010-12-17 23:25:16 +00:00
|
|
|
Generator *Generator
|
2010-05-23 14:21:30 +00:00
|
|
|
Contributors []string
|
2010-12-17 23:25:16 +00:00
|
|
|
Content *Content
|
2009-11-23 12:46:12 +00:00
|
|
|
}
|
2013-12-05 15:04:00 +00:00
|
|
|
|
|
|
|
func (i *Item) Key() string {
|
|
|
|
switch {
|
|
|
|
case i.Guid != nil && len(*i.Guid) != 0:
|
|
|
|
return *i.Guid
|
|
|
|
case len(i.Id) != 0:
|
|
|
|
return i.Id
|
2013-12-05 15:18:13 +00:00
|
|
|
case len(i.Title) > 0 && len(i.PubDate) > 0:
|
2013-12-05 15:04:00 +00:00
|
|
|
return i.Title + i.PubDate
|
2013-12-05 15:18:13 +00:00
|
|
|
default:
|
|
|
|
h := md5.New()
|
|
|
|
io.WriteString(h, i.Description)
|
|
|
|
return string(h.Sum(nil))
|
2013-12-05 15:04:00 +00:00
|
|
|
}
|
|
|
|
}
|