Skip to content

Commit

Permalink
update: parse <podcast:person> as PodcastPerdon object
Browse files Browse the repository at this point in the history
  • Loading branch information
devahmedshendy committed Sep 6, 2023
1 parent 0ef1dba commit b7b8935
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/SyndiKit/Formats/Feeds/RSS/RSSItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public struct RSSItem: Codable {
public let itunesExplicit: String?
public let itunesDuration: iTunesDuration?
public let itunesImage: iTunesImage?
public let podcastPerson: [PodcastPerson]?
public let enclosure: Enclosure?
public let creators: [String]
public let wpCommentStatus: CData?
Expand Down Expand Up @@ -57,6 +58,7 @@ public struct RSSItem: Codable {
itunesExplicit: String? = nil,
itunesDuration: TimeInterval? = nil,
itunesImage: iTunesImage? = nil,
podcastPerson: [PodcastPerson]? = nil,
enclosure: Enclosure? = nil,
creators: [String] = [],
wpCommentStatus: String? = nil,
Expand Down Expand Up @@ -94,6 +96,7 @@ public struct RSSItem: Codable {
self.itunesExplicit = itunesExplicit
self.itunesDuration = itunesDuration.map(iTunesDuration.init)
self.itunesImage = itunesImage
self.podcastPerson = podcastPerson
self.enclosure = enclosure
self.creators = creators
self.wpCommentStatus = wpCommentStatus.map(CData.init)
Expand Down Expand Up @@ -139,6 +142,12 @@ public struct RSSItem: Codable {
iTunesDuration.self, forKey: .itunesDuration
)
itunesImage = try container.decodeIfPresent(iTunesImage.self, forKey: .itunesImage)

podcastPerson = try container.decodeIfPresent(
[PodcastPerson].self,
forKey: .podcastPerson
)

enclosure = try container.decodeIfPresent(Enclosure.self, forKey: .enclosure)
creators = try container.decode([String].self, forKey: .creators)

Expand Down Expand Up @@ -222,6 +231,7 @@ public struct RSSItem: Codable {
case itunesSubtitle = "itunes:subtitle"
case itunesSummary = "itunes:summary"
case itunesExplicit = "itunes:explicit"
case podcastPerson = "podcast:person"
case itunesDuration = "itunes:duration"
case itunesImage = "itunes:image"
case creators = "dc:creator"
Expand Down
18 changes: 18 additions & 0 deletions Sources/SyndiKit/Formats/Media/Podcast/PodcastPerson.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation

public struct PodcastPerson: Codable {
public let email: String?
public let role: String
public let href: String
public let img: String?

public let name: String

enum CodingKeys: String, CodingKey {
case email
case role
case href
case img
case name = ""
}
}

0 comments on commit b7b8935

Please sign in to comment.