Back to previous API.

(IE, the previous breaking changes are unbroken.)
This commit is contained in:
Sean Schulte 2014-03-24 21:58:36 -05:00
parent 2c67b94a04
commit c6a7816435
3 changed files with 9 additions and 5 deletions

View File

@ -56,7 +56,7 @@ func (this *Feed) readAtom(doc *xmlx.Document) (err error) {
i = new(Item)
i.Title = item.S(ns, "title")
i.Id = item.S(ns, "id")
i.PubDate, _ = parseTime(item.S(ns, "updated"))
i.PubDate = item.S(ns, "updated")
i.Description = item.S(ns, "summary")
links := item.SelectNodes(ns, "link")

10
item.go
View File

@ -16,7 +16,7 @@ type Item struct {
Comments string
Enclosures []*Enclosure
Guid *string
PubDate time.Time
PubDate string
Source *Source
// Atom specific fields
@ -28,14 +28,18 @@ type Item struct {
Extensions map[string]map[string][]Extension
}
func (i *Item) ParsedPubDate() (time.Time, error) {
return parseTime(i.PubDate)
}
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
case len(i.Title) > 0 && !i.PubDate.IsZero():
return i.Title + i.PubDate.String()
case len(i.Title) > 0 && len(i.PubDate) > 0:
return i.Title + i.PubDate
default:
h := md5.New()
io.WriteString(h, i.Description)

2
rss.go
View File

@ -162,7 +162,7 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
i.Guid = &guid
}
i.PubDate, _ = parseTime(item.S(ns, "pubDate"))
i.PubDate = item.S(ns, "pubDate")
tl = item.SelectNodes(ns, "category")
for _, lv := range tl {