diff --git a/rss/feed.go b/rss/feed.go index fc8041de..dd9c9e5c 100644 --- a/rss/feed.go +++ b/rss/feed.go @@ -59,6 +59,7 @@ type Item struct { DublinCoreExt *ext.DublinCoreExtension `json:"dcExt,omitempty"` ITunesExt *ext.ITunesItemExtension `json:"itunesExt,omitempty"` Extensions ext.Extensions `json:"extensions,omitempty"` + Custom map[string]string `json:"custom,omitempty"` } // Image is an image that represents the feed diff --git a/rss/parser.go b/rss/parser.go index 684d160f..1bbd46cb 100644 --- a/rss/parser.go +++ b/rss/parser.go @@ -415,8 +415,14 @@ func (rp *Parser) parseItem(p *xpp.XMLPullParser) (item *Item, err error) { } categories = append(categories, result) } else { - // Skip any elements not part of the item spec - p.Skip() + result, err := shared.ParseText(p) + if err != nil { + continue + } + if item.Custom == nil { + item.Custom = make(map[string]string, 0) + } + item.Custom[name] = result } } } diff --git a/testdata/parser/rss/rss_channel_item_custom.json b/testdata/parser/rss/rss_channel_item_custom.json new file mode 100644 index 00000000..5e739a61 --- /dev/null +++ b/testdata/parser/rss/rss_channel_item_custom.json @@ -0,0 +1,11 @@ +{ + "items": [ + { + "custom": { + "apcategory": "s", + "test": "test" + } + } + ], + "version": "2.0" +} diff --git a/testdata/parser/rss/rss_channel_item_custom.xml b/testdata/parser/rss/rss_channel_item_custom.xml new file mode 100644 index 00000000..fdc7c297 --- /dev/null +++ b/testdata/parser/rss/rss_channel_item_custom.xml @@ -0,0 +1,11 @@ + + + + + s + test + + + diff --git a/testdata/translator/rss/feed_item_category_-_rss_channel_item_custom.json b/testdata/translator/rss/feed_item_category_-_rss_channel_item_custom.json new file mode 100644 index 00000000..24add264 --- /dev/null +++ b/testdata/translator/rss/feed_item_category_-_rss_channel_item_custom.json @@ -0,0 +1,12 @@ +{ + "items": [ + { + "custom": { + "apcategory": "s", + "test": "test" + } + } + ], + "feedType": "rss", + "feedVersion": "2.0" +} diff --git a/testdata/translator/rss/feed_item_category_-_rss_channel_item_custom.xml b/testdata/translator/rss/feed_item_category_-_rss_channel_item_custom.xml new file mode 100644 index 00000000..b70463b9 --- /dev/null +++ b/testdata/translator/rss/feed_item_category_-_rss_channel_item_custom.xml @@ -0,0 +1,8 @@ + + + + test + s + + + diff --git a/translator.go b/translator.go index d7aa0fa2..6a71e3a0 100644 --- a/translator.go +++ b/translator.go @@ -78,6 +78,7 @@ func (t *DefaultRSSTranslator) translateFeedItem(rssItem *rss.Item) (item *Item) item.DublinCoreExt = rssItem.DublinCoreExt item.ITunesExt = rssItem.ITunesExt item.Extensions = rssItem.Extensions + item.Custom = rssItem.Custom return }