feed.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package rss
  2. import (
  3. "encoding/json"
  4. "time"
  5. "github.com/mmcdole/gofeed/extensions"
  6. )
  7. // Feed is an RSS Feed
  8. type Feed struct {
  9. Title string `json:"title,omitempty"`
  10. Link string `json:"link,omitempty"`
  11. Description string `json:"description,omitempty"`
  12. Language string `json:"language,omitempty"`
  13. Copyright string `json:"copyright,omitempty"`
  14. ManagingEditor string `json:"managingEditor,omitempty"`
  15. WebMaster string `json:"webMaster,omitempty"`
  16. PubDate string `json:"pubDate,omitempty"`
  17. PubDateParsed *time.Time `json:"pubDateParsed,omitempty"`
  18. LastBuildDate string `json:"lastBuildDate,omitempty"`
  19. LastBuildDateParsed *time.Time `json:"lastBuildDateParsed,omitempty"`
  20. Categories []*Category `json:"categories,omitempty"`
  21. Generator string `json:"generator,omitempty"`
  22. Docs string `json:"docs,omitempty"`
  23. TTL string `json:"ttl,omitempty"`
  24. Image *Image `json:"image,omitempty"`
  25. Rating string `json:"rating,omitempty"`
  26. SkipHours []string `json:"skipHours,omitempty"`
  27. SkipDays []string `json:"skipDays,omitempty"`
  28. Cloud *Cloud `json:"cloud,omitempty"`
  29. TextInput *TextInput `json:"textInput,omitempty"`
  30. DublinCoreExt *ext.DublinCoreExtension `json:"dcExt,omitempty"`
  31. ITunesExt *ext.ITunesFeedExtension `json:"itunesExt,omitempty"`
  32. Extensions ext.Extensions `json:"extensions,omitempty"`
  33. Items []*Item `json:"items"`
  34. Version string `json:"version"`
  35. }
  36. func (f Feed) String() string {
  37. json, _ := json.MarshalIndent(f, "", " ")
  38. return string(json)
  39. }
  40. // Item is an RSS Item
  41. type Item struct {
  42. Title string `json:"title,omitempty"`
  43. Link string `json:"link,omitempty"`
  44. Description string `json:"description,omitempty"`
  45. Content string `json:"content,omitempty"`
  46. Author string `json:"author,omitempty"`
  47. Categories []*Category `json:"categories,omitempty"`
  48. Comments string `json:"comments,omitempty"`
  49. Enclosure *Enclosure `json:"enclosure,omitempty"`
  50. GUID *GUID `json:"guid,omitempty"`
  51. PubDate string `json:"pubDate,omitempty"`
  52. PubDateParsed *time.Time `json:"pubDateParsed,omitempty"`
  53. Source *Source `json:"source,omitempty"`
  54. DublinCoreExt *ext.DublinCoreExtension `json:"dcExt,omitempty"`
  55. ITunesExt *ext.ITunesItemExtension `json:"itunesExt,omitempty"`
  56. Extensions ext.Extensions `json:"extensions,omitempty"`
  57. }
  58. // Image is an image that represents the feed
  59. type Image struct {
  60. URL string `json:"url,omitempty"`
  61. Link string `json:"link,omitempty"`
  62. Title string `json:"title,omitempty"`
  63. Width string `json:"width,omitempty"`
  64. Height string `json:"height,omitempty"`
  65. Description string `json:"description,omitempty"`
  66. }
  67. // Enclosure is a media object that is attached to
  68. // the item
  69. type Enclosure struct {
  70. URL string `json:"url,omitempty"`
  71. Length string `json:"length,omitempty"`
  72. Type string `json:"type,omitempty"`
  73. }
  74. // GUID is a unique identifier for an item
  75. type GUID struct {
  76. Value string `json:"value,omitempty"`
  77. IsPermalink string `json:"isPermalink,omitempty"`
  78. }
  79. // Source contains feed information for another
  80. // feed if a given item came from that feed
  81. type Source struct {
  82. Title string `json:"title,omitempty"`
  83. URL string `json:"url,omitempty"`
  84. }
  85. // Category is category metadata for Feeds and Entries
  86. type Category struct {
  87. Domain string `json:"domain,omitempty"`
  88. Value string `json:"value,omitempty"`
  89. }
  90. // TextInput specifies a text input box that
  91. // can be displayed with the channel
  92. type TextInput struct {
  93. Title string `json:"title,omitempty"`
  94. Description string `json:"description,omitempty"`
  95. Name string `json:"name,omitempty"`
  96. Link string `json:"link,omitempty"`
  97. }
  98. // Cloud allows processes to register with a
  99. // cloud to be notified of updates to the channel,
  100. // implementing a lightweight publish-subscribe protocol
  101. // for RSS feeds
  102. type Cloud struct {
  103. Domain string `json:"domain,omitempty"`
  104. Port string `json:"port,omitempty"`
  105. Path string `json:"path,omitempty"`
  106. RegisterProcedure string `json:"registerProcedure,omitempty"`
  107. Protocol string `json:"protocol,omitempty"`
  108. }