Skip to content

Commit cee287d

Browse files
matthewruzzinmdias
andauthored
Add podcast namespace guid tag (#200)
* Add podcast namespace guid tag * Update Podcast.swift --------- Co-authored-by: Nuno Dias <nmdias@users.noreply.github.com>
1 parent acb340d commit cee287d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Sources/FeedKit/Namespaces/Podcast/Podcast.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ import XMLKit
3232
/// See https://github.com/Podcastindex-org/podcast-namespace
3333
public struct Podcast {
3434
// MARK: Lifecycle
35+
36+
public init(
37+
guid: String? = nil,
38+
transcripts: [PodcastTranscript]? = nil
3539

36-
public init(transcripts: [PodcastTranscript]? = nil) {
40+
) {
41+
self.guid = guid
3742
self.transcripts = transcripts
3843
}
3944

4045
// MARK: Public
46+
/// This element is used to declare a unique, global identifier for a podcast.
47+
/// See https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/tags/guid.md
48+
public var guid: String?
4149

4250
/// Links to transcript or closed captions files for a podcast episode.
4351
///
@@ -71,18 +79,21 @@ extension Podcast: Hashable {}
7179

7280
extension Podcast: Codable {
7381
private enum CodingKeys: String, CodingKey {
82+
case guid = "podcast:guid"
7483
case transcripts = "podcast:transcript"
7584
}
7685

7786
public init(from decoder: any Decoder) throws {
7887
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
79-
88+
89+
guid = try container.decodeIfPresent(String.self, forKey: CodingKeys.guid)
8090
transcripts = try container.decodeIfPresent([PodcastTranscript].self, forKey: CodingKeys.transcripts)
8191
}
8292

8393
public func encode(to encoder: any Encoder) throws {
8494
var container = encoder.container(keyedBy: CodingKeys.self)
8595

96+
try container.encodeIfPresent(guid, forKey: CodingKeys.guid)
8697
try container.encodeIfPresent(transcripts, forKey: CodingKeys.transcripts)
8798
}
8899
}

0 commit comments

Comments
 (0)