@@ -3,9 +3,12 @@ package types
3
3
import (
4
4
"encoding/xml"
5
5
"fmt"
6
+ "math"
6
7
"strconv"
7
8
"strings"
8
9
"time"
10
+
11
+ "github.com/google/uuid"
9
12
)
10
13
11
14
// NamespacePodcast is the Podcasting 2.0 namespace.
@@ -36,11 +39,12 @@ type PodcastChapters struct {
36
39
// PodcastValue enables to describe Value 4 Value payments. Read more at
37
40
// https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#value
38
41
type PodcastValue struct {
39
- XMLName xml.Name `xml:"podcast:value"`
40
- Type string `xml:"type,attr"`
41
- Method string `xml:"method,attr"`
42
- Suggested * float64 `xml:"suggested,attr,omitempty"`
43
- Recipients []PodcastValueRecipient
42
+ XMLName xml.Name `xml:"podcast:value"`
43
+ Type string `xml:"type,attr"`
44
+ Method string `xml:"method,attr"`
45
+ Suggested * float64 `xml:"suggested,attr,omitempty"`
46
+ Recipients []PodcastValueRecipient
47
+ ValueTimeSplits []PodcastValueTimeSplit
44
48
}
45
49
46
50
// PodcastValueRecipient describes the recipient of Value 4 Value payments.
@@ -57,6 +61,29 @@ type PodcastValueRecipient struct {
57
61
Fee * bool `xml:"bool,attr"`
58
62
}
59
63
64
+ // PodcastValueTimeSplit describes value splits that are valid for a certain period of time
65
+ // Read more at
66
+ // https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#value-time-split
67
+ type PodcastValueTimeSplit struct {
68
+ XMLName xml.Name `xml:"podcast:valueTimeSplit"`
69
+ StartTime DurationInteger `xml:"startTime,attr"`
70
+ Duration DurationInteger `xml:"duration,attr"`
71
+ RemoteStartTime * DurationInteger `xml:"remoteStartTime,attr,omitempty"`
72
+ RemotePercentage * uint `xml:"remotePercentage,attr,omitempty"`
73
+ Recipients []PodcastValueRecipient
74
+ RemoteItem PodcastRemoteItem
75
+ }
76
+
77
+ // PodcastRemoteItem provides a way to "point" to another feed or item in it.
78
+ // Read more at
79
+ // https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#remote-item
80
+ type PodcastRemoteItem struct {
81
+ XMLName xml.Name `xml:"podcast:remoteItem"`
82
+ ItemGUID * string `xml:"itemGuid,attr"`
83
+ FeedGUID uuid.UUID `xml:"feedGuid,attr"`
84
+ Medium * PodcastMedium `xml:"medium,attr"`
85
+ }
86
+
60
87
// PodcastLocked tells podcast hosting platforms whether they are allowed to import
61
88
// the feed. Read more at
62
89
// https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#locked
@@ -170,6 +197,17 @@ func (duration Duration) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
170
197
return xml.Attr {Name : xml.Name {Local : name .Local }, Value : s }, nil
171
198
}
172
199
200
+ // DurationInteger denotes timestamps and durations during a podcast episode, but which are converted to integer seconds.
201
+ type DurationInteger time.Duration
202
+
203
+ func (duration DurationInteger ) MarshalXMLAttr (name xml.Name ) (xml.Attr , error ) {
204
+ seconds := time .Duration (duration ).Seconds ()
205
+ seconds = math .Round (seconds )
206
+ s := strconv .Itoa (int (seconds ))
207
+
208
+ return xml.Attr {Name : xml.Name {Local : name .Local }, Value : s }, nil
209
+ }
210
+
173
211
// PodcastPerson specifies a person of interest to the podcast. Read more at
174
212
// https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#person
175
213
type PodcastPerson struct {
0 commit comments