Adds a fallback ID function.
This commit is contained in:
parent
6b6086e389
commit
b4a80d771a
11
item.go
11
item.go
|
@ -1,5 +1,10 @@
|
||||||
package feeder
|
package feeder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
// RSS and Shared fields
|
// RSS and Shared fields
|
||||||
Title string
|
Title string
|
||||||
|
@ -26,7 +31,11 @@ func (i *Item) Key() string {
|
||||||
return *i.Guid
|
return *i.Guid
|
||||||
case len(i.Id) != 0:
|
case len(i.Id) != 0:
|
||||||
return i.Id
|
return i.Id
|
||||||
default:
|
case len(i.Title) > 0 && len(i.PubDate) > 0:
|
||||||
return i.Title + i.PubDate
|
return i.Title + i.PubDate
|
||||||
|
default:
|
||||||
|
h := md5.New()
|
||||||
|
io.WriteString(h, i.Description)
|
||||||
|
return string(h.Sum(nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue