Categorygithub.com/rssblue/types
modulepackage
0.0.0-20240515193739-5bd2a0202a26
Repository: https://github.com/rssblue/types.git
Documentation: pkg.go.dev

# 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 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

package main

import (
  "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 <em>books</em>.",
        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 version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://podcastindex.org/namespace/1.0">
  <channel>
    <description><![CDATA[Podcast about <em>books</em>.]]></description>
    <language>en</language>
    <title>Bookworm Podcast</title>
    <itunes:author>John</itunes:author>
    <itunes:category text="Arts"></itunes:category>
    <itunes:image href="https://example.com/cover-art.png"></itunes:image>
    <itunes:owner>
      <itunes:name>John</itunes:name>
      <itunes:email>[email protected]</itunes:email>
    </itunes:owner>
    <itunes:type>episodic</itunes:type>
    <podcast:guid>cda647ce-56b8-5d7c-9448-ba1993ab46b7</podcast:guid>
    <item>
      <enclosure url="https://example.com/moby-dick.mp3" length="4096" type="audio/mpeg"></enclosure>
      <guid>https://example.com/moby-dick</guid>
      <pubDate>Sat, 23 Jul 2022 10:30:00 GMT</pubDate>
      <title>Book Review: Moby-Dick</title>
      <itunes:episodeType>full</itunes:episodeType>
      <podcast:location osm="R2396248"></podcast:location>
    </item>
  </channel>
</rss>

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NamespaceAtom is the Atom namespace.
NamespaceContent is the namespace for RSS format's content module.
NamespaceGooglePlay is the Google Play namespace.
NamespaceITunes is the iTunes namespace.
NamespacePodcast is the Podcasting 2.0 namespace.
NamespacePSC is the namespace for Podlove Simple Chapters.
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

AtomLink defines a reference from an entry or feed to a Web resource.
Channel represents the podcast's feed.
ContentEncoded is used for podcast's or episode's description.
Description is used for podcast's or episode's description.
Enclosure is used to link to the episode's media file.
GUID is a unique identifier for an episode.
Item represents episode of a podcast.
ITunesCategory denotes podcast's category information.
ITunesImage is podcast's or episode's artwork.
ITunesOwner is used for owner's contact information.
PodcastAlternateEnclosure provides different versions of, or companion media to the main `<enclosure>` file.
PodcastChapters denotes episode's chapters.
PodcastChat is an experimental tag to enable chat during a livestream.
No description provided by the author
PodcastEpisode exists largely for compatibility with PodcastSeason.
PodcastFunding denotes donation/funding links.
No description provided by the author
PodcastISRC is an experimental tag to store International Standard Recording Codes.
No description provided by the author
PodcastLiveValue is an experimental tag to transmit updates during a livestream.
PodcastLocation describes editorial focus of podcast's or episode's content.
PodcastLocked tells podcast hosting platforms whether they are allowed to import the feed.
PodcastOSM encodes OpenStreetMap location information.
PodcastPerson specifies a person of interest to the podcast.
PodcastPodping allows feed owners to signal to aggregators that the feed sends out Podping notifications when changes are made to it.
PodcastPublisher allows a podcast feed to link to it's "publisher feed" parent.
PodcastRemoteItem provides a way to "point" to another feed or item in it.
PodcastSeason is used for identifying which episodes in a podcast are part of a particular "season".
PodcastSingleItem denotes whether the feed contains a single item or multiple items.
PodcastSoundbite denotes soundbite associated with an episode.
PodcastSource defines a uri location for a `<podcast:alternateEnclosure>` media file.
PodcastTrailer is used to define the location of an audio or video file to be used as a trailer for the entire podcast or a specific season.
PodcastTranscript denotes episode's transcript.
PodcastTXT is intended for free-form text and is modeled after the DNS "TXT" record.
PodcastValue enables to describe Value 4 Value payments.
PodcastValueRecipient describes the recipient of Value 4 Value payments.
PodcastValueTimeSplit describes value splits that are valid for a certain period of time Read more at https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#value-time-split.
PSCChapter is a single chapter in Podlove Simple Chapters.
PSCChapters is the root element for Podlove Simple Chapters.
RSS is the root element of podcast's RSS feed, denoting the namespaces and the version of the protocol.

# Type aliases

Date is used to format the publish date of an episode.
Duration denotes timestamps and durations during a podcast episode.
DurationInteger denotes timestamps and durations during a podcast episode, but which are converted to integer seconds.
ITunesDuration denotesthe duration of an episode.
ITunesSubcategory is more granural; it is a subset of Category.
No description provided by the author
PodcastGUID is the global identifier for a podcast.
No description provided by the author
PodcastMedium tells what the content contained within the feed is.
RSSVersion denotes the RSS version.