Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rssblue/types
Go data types for Podcasting 2.0: easily marshal to XML!
https://github.com/rssblue/types
go podcasting20 rss
Last synced: 6 days ago
JSON representation
Go data types for Podcasting 2.0: easily marshal to XML!
- Host: GitHub
- URL: https://github.com/rssblue/types
- Owner: rssblue
- License: mit
- Created: 2022-07-22T17:33:08.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-15T19:37:51.000Z (6 months ago)
- Last Synced: 2024-06-20T03:36:19.904Z (5 months ago)
- Topics: go, podcasting20, rss
- Language: Go
- Homepage:
- Size: 80.1 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Types
This package provides a number of Go struct types with field tags for XML marshalling.
There are standard RSS 2.0, iTunes and many of the [Podcasting 2.0](https://github.com/Podcastindex-org/podcast-namespace) tags available.## Install
There is no stable release yet, and backwards-incompatible changes may still be introduced.
But if you want to try it, you can simply do
```
go get github.com/rssblue/types
```## Example
### Code
```go
package mainimport (
"encoding/xml"
"fmt"
"time""github.com/rssblue/types"
)func main() {
rss := types.RSS{
NamespaceITunes: true,
NamespacePodcast: true,
Channel: types.Channel{
Title: pointer("Bookworm Podcast"),
Description: &types.Description{
Description: "Podcast about books.",
IsCDATA: true,
},
Language: pointer("en"),
ITunesAuthor: pointer("John"),
ITunesOwner: &types.ITunesOwner{
Name: "John",
Email: "[email protected]",
},
ITunesImage: &types.ITunesImage{
URL: "https://example.com/cover-art.png",
},
ITunesCategories: []types.ITunesCategory{
{
Category: "Arts",
},
},
ITunesType: pointer("episodic"),
PodcastGUID: pointer(types.PodcastGUID("cda647ce-56b8-5d7c-9448-ba1993ab46b7")),
Items: []types.Item{
{
Title: pointer("Book Review: Moby-Dick"),
Enclosure: &types.Enclosure{
URL: "https://example.com/moby-dick.mp3",
Length: 4096,
Mimetype: "audio/mpeg",
},
GUID: &types.GUID{GUID: "https://example.com/moby-dick"},
ITunesEpisodeType: pointer("full"),
PubDate: pointer(types.Date(time.Date(2022, time.July, 23, 10, 30, 0, 0, time.UTC))),
PodcastLocation: &types.PodcastLocation{
OSM: &types.PodcastOSM{
Type: 'R',
FeatureID: 2396248,
},
},
},
},
},
}output, err := xml.MarshalIndent(&rss, "", " ")
if err != nil {
panic(err)
}fmt.Printf("%s%s\n", xml.Header, output)
}
func pointer[T any](v T) *T {
return &v
}
```### Output
```xml
books.]]>
en
Bookworm Podcast
John
John
[email protected]
episodic
cda647ce-56b8-5d7c-9448-ba1993ab46b7
https://example.com/moby-dick
Sat, 23 Jul 2022 10:30:00 GMT
Book Review: Moby-Dick
full
```