Skip to main content

feedparser_rs/types/
podcast.rs

1use super::common::{MimeType, Url};
2
3/// iTunes podcast metadata for feeds
4///
5/// Contains podcast-level iTunes namespace metadata from the `itunes:` prefix.
6/// Namespace URI: `http://www.itunes.com/dtds/podcast-1.0.dtd`
7///
8/// # Examples
9///
10/// ```
11/// use feedparser_rs::ItunesFeedMeta;
12///
13/// let mut itunes = ItunesFeedMeta::default();
14/// itunes.author = Some("John Doe".to_string());
15/// itunes.explicit = Some(false);
16/// itunes.podcast_type = Some("episodic".to_string());
17///
18/// assert_eq!(itunes.author.as_deref(), Some("John Doe"));
19/// ```
20#[derive(Debug, Clone, Default)]
21#[non_exhaustive]
22pub struct ItunesFeedMeta {
23    /// Podcast author (itunes:author)
24    pub author: Option<String>,
25    /// Podcast owner contact information (itunes:owner)
26    pub owner: Option<ItunesOwner>,
27    /// Podcast categories with optional subcategories
28    pub categories: Vec<ItunesCategory>,
29    /// Explicit content flag (itunes:explicit)
30    pub explicit: Option<bool>,
31    /// Podcast artwork URL (itunes:image href attribute)
32    pub image: Option<Url>,
33    /// Search keywords (itunes:keywords)
34    pub keywords: Vec<String>,
35    /// Podcast type: "episodic" or "serial"
36    pub podcast_type: Option<String>,
37    /// Podcast completion status (itunes:complete)
38    ///
39    /// Raw XML text value from the feed (e.g., "Yes", "No").
40    pub complete: Option<String>,
41    /// New feed URL for migrated podcasts (itunes:new-feed-url)
42    ///
43    /// Indicates the podcast has moved to a new feed location.
44    ///
45    /// # Security Warning
46    ///
47    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
48    /// Applications MUST validate URLs before fetching to prevent SSRF attacks.
49    pub new_feed_url: Option<Url>,
50    /// Podcast subtitle (itunes:subtitle)
51    pub subtitle: Option<String>,
52    /// Podcast summary (itunes:summary)
53    pub summary: Option<String>,
54    /// Block flag: 1 = blocked ("yes"), 0 = not blocked ("no" or absent)
55    ///
56    /// Normalized from itunes:block: "yes" → 1, any other value → 0.
57    pub block: Option<u8>,
58}
59
60/// iTunes podcast metadata for episodes
61///
62/// Contains episode-level iTunes namespace metadata from the `itunes:` prefix.
63///
64/// # Examples
65///
66/// ```
67/// use feedparser_rs::ItunesEntryMeta;
68///
69/// let mut episode = ItunesEntryMeta::default();
70/// episode.duration = Some("1:00:00".to_string());
71/// episode.episode = Some("42".to_string());
72/// episode.season = Some("3".to_string());
73/// episode.episode_type = Some("full".to_string());
74///
75/// assert_eq!(episode.duration.as_deref(), Some("1:00:00"));
76/// ```
77#[derive(Debug, Clone, Default)]
78#[non_exhaustive]
79pub struct ItunesEntryMeta {
80    /// Episode title override (itunes:title)
81    pub title: Option<String>,
82    /// Episode author (itunes:author)
83    pub author: Option<String>,
84    /// Episode duration as raw string (itunes:duration)
85    ///
86    /// Preserved verbatim from the feed: "3600", "60:00", "1:00:00", "1:23:45", etc.
87    pub duration: Option<String>,
88    /// Explicit content flag for this episode
89    pub explicit: Option<bool>,
90    /// Episode-specific artwork URL (itunes:image href)
91    pub image: Option<Url>,
92    /// Episode number as raw string (itunes:episode)
93    pub episode: Option<String>,
94    /// Season number as raw string (itunes:season)
95    pub season: Option<String>,
96    /// Episode type: "full", "trailer", or "bonus"
97    pub episode_type: Option<String>,
98    /// Episode subtitle (itunes:subtitle)
99    pub subtitle: Option<String>,
100    /// Episode summary (itunes:summary)
101    pub summary: Option<String>,
102}
103
104/// iTunes podcast owner information
105///
106/// Contact information for the podcast owner (itunes:owner).
107///
108/// # Examples
109///
110/// ```
111/// use feedparser_rs::ItunesOwner;
112///
113/// let mut owner = ItunesOwner::default();
114/// owner.name = Some("Jane Doe".to_string());
115/// owner.email = Some("jane@example.com".to_string());
116///
117/// assert_eq!(owner.name.as_deref(), Some("Jane Doe"));
118/// ```
119#[derive(Debug, Clone, Default)]
120#[non_exhaustive]
121pub struct ItunesOwner {
122    /// Owner's name (itunes:name)
123    pub name: Option<String>,
124    /// Owner's email address (itunes:email)
125    pub email: Option<String>,
126}
127
128/// iTunes category with optional subcategory
129///
130/// Categories follow Apple's podcast category taxonomy.
131///
132/// # Examples
133///
134/// ```
135/// use feedparser_rs::ItunesCategory;
136///
137/// let mut category = ItunesCategory::new("Technology");
138/// category.subcategory = Some("Software How-To".to_string());
139///
140/// assert_eq!(category.text, "Technology");
141/// ```
142#[derive(Debug, Clone)]
143#[non_exhaustive]
144pub struct ItunesCategory {
145    /// Category name (text attribute)
146    pub text: String,
147    /// Optional subcategory (nested itunes:category text attribute)
148    pub subcategory: Option<String>,
149}
150
151impl ItunesCategory {
152    /// Creates a `ItunesCategory` from its required `text`; every other field is empty.
153    ///
154    /// # Examples
155    ///
156    /// ```
157    /// use feedparser_rs::ItunesCategory;
158    ///
159    /// let category = ItunesCategory::new("Technology");
160    /// assert_eq!(category.text, "Technology");
161    /// ```
162    #[must_use]
163    pub fn new(text: impl Into<String>) -> Self {
164        Self {
165            text: text.into(),
166            subcategory: None,
167        }
168    }
169}
170
171/// Podcast 2.0 metadata
172///
173/// Modern podcast namespace extensions from `https://podcastindex.org/namespace/1.0`
174///
175/// # Examples
176///
177/// ```
178/// use feedparser_rs::PodcastMeta;
179///
180/// let mut podcast = PodcastMeta::default();
181/// podcast.guid = Some("9b024349-ccf0-5f69-a609-6b82873eab3c".to_string());
182///
183/// assert!(podcast.guid.is_some());
184/// ```
185#[derive(Debug, Clone, Default)]
186#[non_exhaustive]
187pub struct PodcastMeta {
188    /// Transcript URLs (podcast:transcript)
189    pub transcripts: Vec<PodcastTranscript>,
190    /// Funding/donation links (podcast:funding)
191    pub funding: Vec<PodcastFunding>,
192    /// People associated with podcast (podcast:person)
193    pub persons: Vec<PodcastPerson>,
194    /// Permanent podcast GUID (podcast:guid)
195    pub guid: Option<String>,
196    /// Value-for-value payment information (podcast:value)
197    pub value: Option<PodcastValue>,
198    /// Content medium type (podcast:medium)
199    pub medium: Option<String>,
200    /// Ownership transfer lock (podcast:locked text content: "yes" or "no")
201    pub locked: Option<String>,
202    /// Email of the lock owner (podcast:locked owner attribute)
203    pub locked_owner: Option<String>,
204    /// Geographic location (podcast:location)
205    pub location: Option<PodcastLocation>,
206    /// Related feed references (podcast:podroll)
207    pub podroll: Vec<PodcastRemoteItem>,
208    /// Text records (podcast:txt)
209    pub txt: Vec<PodcastTxt>,
210    /// Update frequency schedule (podcast:updateFrequency)
211    pub update_frequency: Option<PodcastUpdateFrequency>,
212    /// Follow links (podcast:follow)
213    pub follow: Vec<PodcastFollow>,
214    /// Chat room references (podcast:chat)
215    pub chat: Vec<PodcastChat>,
216    /// Whether the podcast uses Podping for update notifications
217    /// (podcast:podping `usesPodping` attribute)
218    pub podping_uses_podping: Option<bool>,
219}
220
221/// Podcast 2.0 value element for monetization
222///
223/// Implements value-for-value payment model using cryptocurrency and streaming payments.
224/// Used for podcast monetization via Lightning Network, Hive, and other payment methods.
225///
226/// Namespace: `https://podcastindex.org/namespace/1.0`
227///
228/// # Examples
229///
230/// ```
231/// use feedparser_rs::{PodcastValue, PodcastValueRecipient};
232///
233/// let mut value = PodcastValue::default();
234/// value.type_ = "lightning".to_string();
235/// value.method = "keysend".to_string();
236/// value.suggested = Some("0.00000005000".to_string());
237/// let mut host = PodcastValueRecipient::default();
238/// host.name = Some("Host".to_string());
239/// host.type_ = "node".to_string();
240/// host.address = "03ae9f91a0cb8ff43840e3c322c4c61f019d8c1c3cea15a25cfc425ac605e61a4a".to_string();
241/// host.split = 90;
242/// host.fee = Some(false);
243/// let mut producer = PodcastValueRecipient::default();
244/// producer.name = Some("Producer".to_string());
245/// producer.type_ = "node".to_string();
246/// producer.address = "02d5c1bf8b940dc9cadca86d1b0a3c37fbe39cee4c7e839e33bef9174531d27f52".to_string();
247/// producer.split = 10;
248/// producer.fee = Some(false);
249/// value.recipients = vec![host, producer];
250/// value.time_splits = vec![];
251///
252/// assert_eq!(value.type_, "lightning");
253/// assert_eq!(value.recipients.len(), 2);
254/// ```
255#[derive(Debug, Clone, Default, PartialEq)]
256#[non_exhaustive]
257pub struct PodcastValue {
258    /// Payment type (type attribute): "lightning", "hive", etc.
259    pub type_: String,
260    /// Payment method (method attribute): "keysend" for Lightning Network
261    pub method: String,
262    /// Suggested payment amount (suggested attribute)
263    ///
264    /// Format depends on payment type. For Lightning, this is typically satoshis.
265    pub suggested: Option<String>,
266    /// List of payment recipients with split percentages
267    pub recipients: Vec<PodcastValueRecipient>,
268    /// Time-bounded payment splits for pre-recorded remote content
269    /// (podcast:valueTimeSplit)
270    ///
271    /// A self-closing `<podcast:valueTimeSplit/>` carries no children worth
272    /// keeping and is silently dropped rather than producing an empty entry.
273    pub time_splits: Vec<PodcastValueTimeSplit>,
274}
275
276/// Value recipient for payment splitting
277///
278/// Defines a single recipient in the value-for-value payment model.
279/// Each recipient receives a percentage (split) of the total payment.
280///
281/// # Examples
282///
283/// ```
284/// use feedparser_rs::PodcastValueRecipient;
285///
286/// let mut recipient = PodcastValueRecipient::default();
287/// recipient.name = Some("Podcast Host".to_string());
288/// recipient.type_ = "node".to_string();
289/// recipient.address = "03ae9f91a0cb8ff43840e3c322c4c61f019d8c1c3cea15a25cfc425ac605e61a4a".to_string();
290/// recipient.split = 95;
291/// recipient.fee = Some(false);
292///
293/// assert_eq!(recipient.split, 95);
294/// assert_eq!(recipient.fee, Some(false));
295/// ```
296#[derive(Debug, Clone, Default, PartialEq, Eq)]
297#[non_exhaustive]
298pub struct PodcastValueRecipient {
299    /// Recipient's name (name attribute)
300    pub name: Option<String>,
301    /// Recipient type (type attribute): "node" for Lightning Network nodes
302    pub type_: String,
303    /// Payment address (address attribute)
304    ///
305    /// For Lightning: node public key (hex-encoded)
306    /// For other types: appropriate address format
307    ///
308    /// # Security Warning
309    ///
310    /// This address comes from untrusted feed input. Applications MUST validate
311    /// addresses before sending payments to prevent sending funds to wrong recipients.
312    pub address: String,
313    /// Payment split percentage (split attribute)
314    ///
315    /// Can be absolute percentage (1-100) or relative value that's normalized.
316    /// Total of all splits should equal 100 for percentage-based splits.
317    pub split: u32,
318    /// Whether this is a fee recipient (fee attribute)
319    ///
320    /// Fee recipients are paid before regular splits are calculated.
321    pub fee: Option<bool>,
322}
323
324/// Podcast 2.0 value time split for pre-recorded remote content
325///
326/// Represents a `<podcast:valueTimeSplit>` element, which routes
327/// value-for-value payments for a specific time range of an episode to its
328/// own set of recipients and/or to a remote item (e.g. a licensed music
329/// track).
330///
331/// # Examples
332///
333/// ```
334/// use feedparser_rs::PodcastValueTimeSplit;
335///
336/// let mut split = PodcastValueTimeSplit::default();
337/// split.start_time = 60.0;
338/// split.duration = 30.0;
339///
340/// assert_eq!(split.start_time, 60.0);
341/// assert_eq!(split.remote_percentage, 100.0);
342/// ```
343#[derive(Debug, Clone, PartialEq)]
344#[non_exhaustive]
345pub struct PodcastValueTimeSplit {
346    /// Start time in seconds within the episode (startTime attribute)
347    pub start_time: f64,
348    /// Duration in seconds of this split (duration attribute)
349    pub duration: f64,
350    /// Start time within the remote item, in seconds (remoteStartTime attribute)
351    ///
352    /// Defaults to `0.0` when absent or unparseable.
353    pub remote_start_time: f64,
354    /// Percentage of the payment routed to this split (remotePercentage attribute)
355    ///
356    /// Defaults to `100.0` per the podcast namespace spec when absent or
357    /// unparseable, and is clamped to the 0.0-100.0 range.
358    pub remote_percentage: f64,
359    /// Payment recipients for this split (podcast:valueRecipient children)
360    pub recipients: Vec<PodcastValueRecipient>,
361    /// Remote item this split routes payment to, if any (podcast:remoteItem child)
362    ///
363    /// Only the first `podcast:remoteItem` encountered in the split is kept.
364    pub remote_item: Option<PodcastRemoteItem>,
365}
366
367impl Default for PodcastValueTimeSplit {
368    fn default() -> Self {
369        Self {
370            start_time: 0.0,
371            duration: 0.0,
372            remote_start_time: 0.0,
373            remote_percentage: 100.0,
374            recipients: Vec::new(),
375            remote_item: None,
376        }
377    }
378}
379
380/// Podcast 2.0 transcript
381///
382/// Links to transcript files in various formats.
383///
384/// # Examples
385///
386/// ```
387/// use feedparser_rs::PodcastTranscript;
388///
389/// let mut transcript = PodcastTranscript::new("https://example.com/transcript.txt".into());
390/// transcript.transcript_type = Some("text/plain".into());
391/// transcript.language = Some("en".to_string());
392/// transcript.rel = None;
393///
394/// assert_eq!(transcript.url, "https://example.com/transcript.txt");
395/// ```
396#[derive(Debug, Clone, PartialEq, Eq)]
397#[non_exhaustive]
398pub struct PodcastTranscript {
399    /// Transcript URL (url attribute)
400    ///
401    /// # Security Warning
402    ///
403    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
404    /// Applications MUST validate URLs before fetching to prevent SSRF attacks.
405    pub url: Url,
406    /// MIME type (type attribute): "text/plain", "text/html", "application/json", etc.
407    pub transcript_type: Option<MimeType>,
408    /// Language code (language attribute): "en", "es", etc.
409    pub language: Option<String>,
410    /// Relationship (rel attribute): "captions" or empty
411    pub rel: Option<String>,
412}
413
414impl PodcastTranscript {
415    /// Creates a `PodcastTranscript` from its required `url`; every other field is empty.
416    ///
417    /// # Examples
418    ///
419    /// ```
420    /// use feedparser_rs::PodcastTranscript;
421    ///
422    /// let transcript = PodcastTranscript::new("https://example.com/t.vtt".into());
423    /// assert!(transcript.language.is_none());
424    /// ```
425    #[must_use]
426    pub const fn new(url: Url) -> Self {
427        Self {
428            url,
429            transcript_type: None,
430            language: None,
431            rel: None,
432        }
433    }
434}
435
436/// Podcast 2.0 funding information
437///
438/// Links for supporting the podcast financially.
439///
440/// # Examples
441///
442/// ```
443/// use feedparser_rs::PodcastFunding;
444///
445/// let mut funding = PodcastFunding::new("https://example.com/donate".into());
446/// funding.message = Some("Support our show!".to_string());
447///
448/// assert_eq!(funding.url, "https://example.com/donate");
449/// ```
450#[derive(Debug, Clone)]
451#[non_exhaustive]
452pub struct PodcastFunding {
453    /// Funding URL (url attribute)
454    ///
455    /// # Security Warning
456    ///
457    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
458    /// Applications MUST validate URLs before fetching to prevent SSRF attacks.
459    pub url: Url,
460    /// Optional message/call-to-action (text content)
461    pub message: Option<String>,
462}
463
464impl PodcastFunding {
465    /// Creates a `PodcastFunding` from its required `url`; every other field is empty.
466    ///
467    /// # Examples
468    ///
469    /// ```
470    /// use feedparser_rs::PodcastFunding;
471    ///
472    /// let funding = PodcastFunding::new("https://example.com/donate".into());
473    /// assert!(funding.message.is_none());
474    /// ```
475    #[must_use]
476    pub const fn new(url: Url) -> Self {
477        Self { url, message: None }
478    }
479}
480
481/// Podcast 2.0 person
482///
483/// Information about hosts, guests, or other people associated with the podcast.
484///
485/// # Examples
486///
487/// ```
488/// use feedparser_rs::PodcastPerson;
489///
490/// let mut host = PodcastPerson::new("John Doe");
491/// host.role = Some("host".to_string());
492/// host.group = None;
493/// host.img = Some("https://example.com/john.jpg".into());
494/// host.href = Some("https://example.com/john".into());
495///
496/// assert_eq!(host.name, "John Doe");
497/// assert_eq!(host.role.as_deref(), Some("host"));
498/// ```
499#[derive(Debug, Clone, PartialEq, Eq)]
500#[non_exhaustive]
501pub struct PodcastPerson {
502    /// Person's name (text content)
503    pub name: String,
504    /// Role: "host", "guest", "editor", etc. (role attribute)
505    pub role: Option<String>,
506    /// Group name (group attribute)
507    pub group: Option<String>,
508    /// Image URL (img attribute)
509    ///
510    /// # Security Warning
511    ///
512    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
513    /// Applications MUST validate URLs before fetching to prevent SSRF attacks.
514    pub img: Option<Url>,
515    /// Personal URL/homepage (href attribute)
516    ///
517    /// # Security Warning
518    ///
519    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
520    /// Applications MUST validate URLs before fetching to prevent SSRF attacks.
521    pub href: Option<Url>,
522}
523
524impl PodcastPerson {
525    /// Creates a `PodcastPerson` from its required `name`; every other field is empty.
526    ///
527    /// # Examples
528    ///
529    /// ```
530    /// use feedparser_rs::PodcastPerson;
531    ///
532    /// let person = PodcastPerson::new("Jane Doe");
533    /// assert_eq!(person.name, "Jane Doe");
534    /// ```
535    #[must_use]
536    pub fn new(name: impl Into<String>) -> Self {
537        Self {
538            name: name.into(),
539            role: None,
540            group: None,
541            img: None,
542            href: None,
543        }
544    }
545}
546
547/// Podcast 2.0 chapters information
548///
549/// Links to chapter markers for time-based navigation within an episode.
550/// Namespace: `https://podcastindex.org/namespace/1.0`
551///
552/// # Examples
553///
554/// ```
555/// use feedparser_rs::PodcastChapters;
556///
557/// let mut chapters = PodcastChapters::default();
558/// chapters.url = "https://example.com/chapters.json".into();
559/// chapters.type_ = "application/json+chapters".into();
560///
561/// assert_eq!(chapters.url, "https://example.com/chapters.json");
562/// ```
563#[derive(Debug, Clone, Default, PartialEq, Eq)]
564#[non_exhaustive]
565pub struct PodcastChapters {
566    /// Chapters file URL (url attribute)
567    ///
568    /// # Security Warning
569    ///
570    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
571    /// Applications MUST validate URLs before fetching to prevent SSRF attacks.
572    pub url: Url,
573    /// MIME type (type attribute): "application/json+chapters" or "application/xml+chapters"
574    pub type_: MimeType,
575}
576
577/// Podcast 2.0 soundbite (shareable clip)
578///
579/// Marks a portion of the audio for social sharing or highlights.
580/// Namespace: `https://podcastindex.org/namespace/1.0`
581///
582/// # Examples
583///
584/// ```
585/// use feedparser_rs::PodcastSoundbite;
586///
587/// let mut soundbite = PodcastSoundbite::default();
588/// soundbite.start_time = 120.5;
589/// soundbite.duration = 30.0;
590/// soundbite.title = Some("Great quote".to_string());
591///
592/// assert_eq!(soundbite.start_time, 120.5);
593/// assert_eq!(soundbite.duration, 30.0);
594/// ```
595#[derive(Debug, Clone, Default, PartialEq)]
596#[non_exhaustive]
597pub struct PodcastSoundbite {
598    /// Start time in seconds (startTime attribute)
599    pub start_time: f64,
600    /// Duration in seconds (duration attribute)
601    pub duration: f64,
602    /// Optional title/description (text content)
603    pub title: Option<String>,
604}
605
606/// Podcast 2.0 alternate enclosure source
607///
608/// A single source URI within a `podcast:alternateEnclosure` element.
609#[derive(Debug, Clone, Default, PartialEq, Eq)]
610#[non_exhaustive]
611pub struct PodcastAlternateEnclosureSource {
612    /// Source URI (uri attribute, required)
613    ///
614    /// # Security Warning
615    ///
616    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
617    /// Applications MUST validate URLs before fetching to prevent SSRF attacks.
618    pub uri: Url,
619    /// Optional MIME type override (contentType attribute)
620    pub content_type: Option<MimeType>,
621}
622
623/// Podcast 2.0 integrity verification for alternate enclosures
624///
625/// Cryptographic integrity check for enclosure sources.
626#[derive(Debug, Clone, Default, PartialEq, Eq)]
627#[non_exhaustive]
628pub struct PodcastIntegrity {
629    /// Integrity type (type attribute): "sri" or "pgp-signature"
630    pub type_: String,
631    /// Integrity value: the element text, else the `value` attribute used by the
632    /// self-closing form of the Podcast 2.0 spec.
633    pub value: String,
634}
635
636/// Podcast 2.0 alternate enclosure
637///
638/// An alternate version of the main episode audio/video in a different format or quality.
639///
640/// Namespace: `https://podcastindex.org/namespace/1.0`
641#[derive(Debug, Clone, Default, PartialEq)]
642#[non_exhaustive]
643pub struct PodcastAlternateEnclosure {
644    /// MIME type (type attribute, required)
645    pub type_: MimeType,
646    /// File size in bytes (length attribute)
647    pub length: Option<u64>,
648    /// Bitrate in kbps (bitrate attribute)
649    pub bitrate: Option<f64>,
650    /// Video height in pixels (height attribute)
651    pub height: Option<u32>,
652    /// Language code (lang attribute)
653    pub lang: Option<String>,
654    /// Title (title attribute)
655    pub title: Option<String>,
656    /// Relationship (rel attribute): "default", "alternate", etc.
657    pub rel: Option<String>,
658    /// Codecs string (codecs attribute)
659    pub codecs: Option<String>,
660    /// Whether this is the default enclosure (default attribute)
661    pub default: Option<bool>,
662    /// Source URIs for this enclosure
663    pub sources: Vec<PodcastAlternateEnclosureSource>,
664    /// Integrity verification
665    pub integrity: Option<PodcastIntegrity>,
666}
667
668/// Podcast 2.0 geographic location
669///
670/// Location information for a podcast or episode.
671///
672/// Namespace: `https://podcastindex.org/namespace/1.0`
673#[derive(Debug, Clone, Default, PartialEq, Eq)]
674#[non_exhaustive]
675pub struct PodcastLocation {
676    /// Human-readable location name (text content)
677    pub name: String,
678    /// Geographic coordinates (geo attribute): "geo:37.786971,-122.399677"
679    pub geo: Option<String>,
680    /// OpenStreetMap reference (osm attribute): "R113314"
681    pub osm: Option<String>,
682}
683
684/// Podcast 2.0 remote item reference
685///
686/// A reference to a remote podcast feed or episode, used within `podcast:podroll`.
687#[derive(Debug, Clone, Default, PartialEq, Eq)]
688#[non_exhaustive]
689pub struct PodcastRemoteItem {
690    /// Feed GUID (feedGuid attribute)
691    pub feed_guid: Option<String>,
692    /// Feed URL (feedUrl attribute)
693    ///
694    /// # Security Warning
695    ///
696    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
697    pub feed_url: Option<Url>,
698    /// Item GUID (itemGuid attribute)
699    pub item_guid: Option<String>,
700    /// Content medium type (medium attribute)
701    pub medium: Option<String>,
702    /// Display title (title attribute)
703    pub title: Option<String>,
704}
705
706/// Podcast 2.0 social interaction
707///
708/// Links a podcast episode to a social media thread.
709///
710/// Namespace: `https://podcastindex.org/namespace/1.0`
711#[derive(Debug, Clone, Default, PartialEq, Eq)]
712#[non_exhaustive]
713pub struct PodcastSocialInteract {
714    /// Social thread URI (uri attribute, required)
715    ///
716    /// # Security Warning
717    ///
718    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
719    pub uri: Url,
720    /// Social protocol (protocol attribute): "activitypub", "twitter", etc.
721    pub protocol: Option<String>,
722    /// Account identifier (accountId attribute)
723    pub account_id: Option<String>,
724    /// Account URL (accountUrl attribute)
725    ///
726    /// # Security Warning
727    ///
728    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
729    pub account_url: Option<Url>,
730    /// Priority (priority attribute, lower = higher priority)
731    pub priority: Option<u32>,
732}
733
734/// Podcast 2.0 text record
735///
736/// Arbitrary text metadata with an optional purpose tag.
737///
738/// Namespace: `https://podcastindex.org/namespace/1.0`
739#[derive(Debug, Clone, Default, PartialEq, Eq)]
740#[non_exhaustive]
741pub struct PodcastTxt {
742    /// Purpose of the text (purpose attribute)
743    pub purpose: Option<String>,
744    /// Text content
745    pub value: String,
746}
747
748/// Podcast 2.0 update frequency
749///
750/// Indicates how often a podcast publishes new episodes.
751///
752/// Namespace: `https://podcastindex.org/namespace/1.0`
753#[derive(Debug, Clone, Default, PartialEq, Eq)]
754#[non_exhaustive]
755pub struct PodcastUpdateFrequency {
756    /// iCalendar RRULE string (rrule attribute)
757    pub rrule: Option<String>,
758    /// Whether the podcast is complete (complete attribute)
759    pub complete: Option<bool>,
760    /// Start date in ISO 8601 (dtstart attribute)
761    pub dtstart: Option<String>,
762    /// Human-readable label (text content)
763    pub label: Option<String>,
764}
765
766/// Podcast 2.0 follow link
767///
768/// A URL and optional platform for following the podcast.
769///
770/// Namespace: `https://podcastindex.org/namespace/1.0`
771#[derive(Debug, Clone, Default, PartialEq, Eq)]
772#[non_exhaustive]
773pub struct PodcastFollow {
774    /// Follow URL (url attribute, required)
775    ///
776    /// # Security Warning
777    ///
778    /// This URL comes from untrusted feed input and has NOT been validated for SSRF.
779    pub url: Url,
780    /// Platform name (platform attribute)
781    pub platform: Option<String>,
782}
783
784/// Podcast 2.0 chat room reference
785///
786/// Points to a chat server/room associated with the podcast or episode
787/// (podcast:chat), e.g. Matrix or XMPP.
788///
789/// Namespace: `https://podcastindex.org/namespace/1.0`
790///
791/// # Examples
792///
793/// ```
794/// use feedparser_rs::PodcastChat;
795///
796/// let mut chat = PodcastChat::default();
797/// chat.server = "matrix.example.com".to_string();
798/// chat.protocol = "matrix".to_string();
799/// chat.account_id = Some("@podcast:example.com".to_string());
800/// chat.space = None;
801///
802/// assert_eq!(chat.server, "matrix.example.com");
803/// ```
804#[derive(Debug, Clone, Default, PartialEq, Eq)]
805#[non_exhaustive]
806pub struct PodcastChat {
807    /// Chat server address (server attribute, required)
808    pub server: String,
809    /// Chat protocol (protocol attribute, required): "matrix", "xmpp", etc.
810    pub protocol: String,
811    /// Account identifier on the chat server (accountId attribute)
812    pub account_id: Option<String>,
813    /// Space identifier, for protocols that group rooms (space attribute)
814    pub space: Option<String>,
815}
816
817/// Podcast 2.0 metadata for episodes
818///
819/// Container for entry-level podcast metadata.
820///
821/// # Examples
822///
823/// ```
824/// use feedparser_rs::PodcastEntryMeta;
825///
826/// let mut podcast = PodcastEntryMeta::default();
827/// assert!(podcast.transcript.is_empty());
828/// assert!(podcast.chapters.is_none());
829/// assert!(podcast.soundbite.is_empty());
830/// ```
831#[derive(Debug, Clone, Default, PartialEq)]
832#[non_exhaustive]
833pub struct PodcastEntryMeta {
834    /// Transcript URLs (podcast:transcript)
835    pub transcript: Vec<PodcastTranscript>,
836    /// Chapter markers (podcast:chapters)
837    pub chapters: Option<PodcastChapters>,
838    /// Shareable soundbites (podcast:soundbite)
839    pub soundbite: Vec<PodcastSoundbite>,
840    /// People associated with this episode (podcast:person)
841    pub persons: Vec<PodcastPerson>,
842    /// Content medium type (podcast:medium)
843    pub medium: Option<String>,
844    /// Season number (podcast:season number attribute)
845    pub season: Option<String>,
846    /// Episode number (podcast:episode number attribute)
847    pub episode: Option<String>,
848    /// Alternate enclosures (podcast:alternateEnclosure)
849    pub alternate_enclosures: Vec<PodcastAlternateEnclosure>,
850    /// Value-for-value payment information (podcast:value)
851    ///
852    /// Item-level `<podcast:value>` is where time-bounded payment splits
853    /// (`podcast:valueTimeSplit`) are expected to appear in practice, since
854    /// they redistribute payment during playback of a specific episode.
855    ///
856    /// `None` both when `<podcast:value>` is absent and when it is present
857    /// but self-closing (`<podcast:value/>`) — a self-closing `podcast:value`
858    /// is skipped entirely (attributes included), matching how self-closing
859    /// `podcast:valueTimeSplit` is handled. If multiple `<podcast:value>`
860    /// elements appear in the same `<item>` (invalid per spec, which allows
861    /// at most one), the last one parsed wins.
862    pub value: Option<PodcastValue>,
863    /// Geographic location (podcast:location)
864    pub location: Option<PodcastLocation>,
865    /// Social interaction threads (podcast:socialInteract)
866    pub social_interact: Vec<PodcastSocialInteract>,
867    /// Text records (podcast:txt)
868    pub txt: Vec<PodcastTxt>,
869    /// Follow links (podcast:follow)
870    pub follow: Vec<PodcastFollow>,
871    /// Chat room references (podcast:chat)
872    pub chat: Vec<PodcastChat>,
873}
874
875/// Parse iTunes explicit flag from various string representations
876///
877/// Maps "yes"/"true"/"explicit" to `Some(true)`.
878/// Maps "no"/"false"/"clean" and absent values to `None` (per Python feedparser compatibility).
879///
880/// Case-insensitive matching.
881///
882/// # Arguments
883///
884/// * `s` - Explicit flag string
885///
886/// # Examples
887///
888/// ```
889/// use feedparser_rs::parse_explicit;
890///
891/// assert_eq!(parse_explicit("yes"), Some(true));
892/// assert_eq!(parse_explicit("YES"), Some(true));
893/// assert_eq!(parse_explicit("true"), Some(true));
894/// assert_eq!(parse_explicit("explicit"), Some(true));
895///
896/// assert_eq!(parse_explicit("no"), None);
897/// assert_eq!(parse_explicit("false"), None);
898/// assert_eq!(parse_explicit("clean"), None);
899///
900/// assert_eq!(parse_explicit("unknown"), None);
901/// ```
902pub fn parse_explicit(s: &str) -> Option<bool> {
903    let s = s.trim();
904    if s.eq_ignore_ascii_case("yes")
905        || s.eq_ignore_ascii_case("true")
906        || s.eq_ignore_ascii_case("explicit")
907    {
908        Some(true)
909    } else {
910        None
911    }
912}
913
914#[cfg(test)]
915mod tests {
916    use super::*;
917
918    #[test]
919    fn test_parse_explicit_true_variants() {
920        assert_eq!(parse_explicit("yes"), Some(true));
921        assert_eq!(parse_explicit("YES"), Some(true));
922        assert_eq!(parse_explicit("Yes"), Some(true));
923        assert_eq!(parse_explicit("true"), Some(true));
924        assert_eq!(parse_explicit("TRUE"), Some(true));
925        assert_eq!(parse_explicit("explicit"), Some(true));
926        assert_eq!(parse_explicit("EXPLICIT"), Some(true));
927    }
928
929    #[test]
930    fn test_parse_explicit_false_variants_return_none() {
931        // "no"/"false"/"clean" → None (Python feedparser compat: only "yes" is truthy)
932        assert_eq!(parse_explicit("no"), None);
933        assert_eq!(parse_explicit("NO"), None);
934        assert_eq!(parse_explicit("No"), None);
935        assert_eq!(parse_explicit("false"), None);
936        assert_eq!(parse_explicit("FALSE"), None);
937        assert_eq!(parse_explicit("clean"), None);
938        assert_eq!(parse_explicit("CLEAN"), None);
939    }
940
941    #[test]
942    fn test_parse_explicit_whitespace() {
943        assert_eq!(parse_explicit("  yes  "), Some(true));
944        assert_eq!(parse_explicit("  no  "), None);
945    }
946
947    #[test]
948    fn test_parse_explicit_unknown() {
949        assert_eq!(parse_explicit("unknown"), None);
950        assert_eq!(parse_explicit("maybe"), None);
951        assert_eq!(parse_explicit(""), None);
952        assert_eq!(parse_explicit("1"), None);
953    }
954
955    #[test]
956    fn test_itunes_feed_meta_default() {
957        let meta = ItunesFeedMeta::default();
958        assert!(meta.author.is_none());
959        assert!(meta.owner.is_none());
960        assert!(meta.categories.is_empty());
961        assert!(meta.explicit.is_none());
962        assert!(meta.image.is_none());
963        assert!(meta.keywords.is_empty());
964        assert!(meta.podcast_type.is_none());
965        assert!(meta.complete.is_none());
966        assert!(meta.new_feed_url.is_none());
967    }
968
969    #[test]
970    fn test_itunes_entry_meta_default() {
971        let meta = ItunesEntryMeta::default();
972        assert!(meta.title.is_none());
973        assert!(meta.author.is_none());
974        assert!(meta.duration.is_none());
975        assert!(meta.explicit.is_none());
976        assert!(meta.image.is_none());
977        assert!(meta.episode.is_none());
978        assert!(meta.season.is_none());
979        assert!(meta.episode_type.is_none());
980    }
981
982    #[test]
983    fn test_itunes_entry_meta_string_fields() {
984        let meta = ItunesEntryMeta {
985            duration: Some("1:23:45".to_string()),
986            episode: Some("42".to_string()),
987            season: Some("3".to_string()),
988            ..Default::default()
989        };
990        assert_eq!(meta.duration.as_deref(), Some("1:23:45"));
991        assert_eq!(meta.episode.as_deref(), Some("42"));
992        assert_eq!(meta.season.as_deref(), Some("3"));
993    }
994
995    #[test]
996    fn test_itunes_owner_default() {
997        let owner = ItunesOwner::default();
998        assert!(owner.name.is_none());
999        assert!(owner.email.is_none());
1000    }
1001
1002    #[expect(
1003        clippy::redundant_clone,
1004        reason = "the test checks that the clone equals the original"
1005    )]
1006    #[test]
1007    fn test_itunes_category_clone() {
1008        let category = ItunesCategory {
1009            text: "Technology".to_string(),
1010            subcategory: Some("Software".to_string()),
1011        };
1012        let cloned = category.clone();
1013        assert_eq!(cloned.text, "Technology");
1014        assert_eq!(cloned.subcategory.as_deref(), Some("Software"));
1015    }
1016
1017    #[test]
1018    fn test_podcast_meta_default() {
1019        let meta = PodcastMeta::default();
1020        assert!(meta.transcripts.is_empty());
1021        assert!(meta.funding.is_empty());
1022        assert!(meta.persons.is_empty());
1023        assert!(meta.guid.is_none());
1024        assert!(meta.location.is_none());
1025        assert!(meta.podroll.is_empty());
1026        assert!(meta.txt.is_empty());
1027        assert!(meta.update_frequency.is_none());
1028        assert!(meta.follow.is_empty());
1029        assert!(meta.chat.is_empty());
1030        assert!(meta.podping_uses_podping.is_none());
1031    }
1032
1033    #[test]
1034    fn test_podcast_entry_meta_new_fields_default() {
1035        let meta = PodcastEntryMeta::default();
1036        assert!(meta.alternate_enclosures.is_empty());
1037        assert!(meta.location.is_none());
1038        assert!(meta.social_interact.is_empty());
1039        assert!(meta.txt.is_empty());
1040        assert!(meta.follow.is_empty());
1041        assert!(meta.chat.is_empty());
1042    }
1043
1044    #[test]
1045    fn test_podcast_chat_default() {
1046        let chat = PodcastChat::default();
1047        assert!(chat.server.is_empty());
1048        assert!(chat.protocol.is_empty());
1049        assert!(chat.account_id.is_none());
1050        assert!(chat.space.is_none());
1051    }
1052
1053    #[test]
1054    fn test_podcast_value_time_split_default() {
1055        let split = PodcastValueTimeSplit::default();
1056        assert!((split.start_time - 0.0).abs() < f64::EPSILON);
1057        assert!((split.duration - 0.0).abs() < f64::EPSILON);
1058        assert!((split.remote_start_time - 0.0).abs() < f64::EPSILON);
1059        assert!((split.remote_percentage - 100.0).abs() < f64::EPSILON);
1060        assert!(split.recipients.is_empty());
1061        assert!(split.remote_item.is_none());
1062    }
1063
1064    #[test]
1065    fn test_podcast_location_default() {
1066        let loc = PodcastLocation::default();
1067        assert!(loc.name.is_empty());
1068        assert!(loc.geo.is_none());
1069        assert!(loc.osm.is_none());
1070    }
1071
1072    #[test]
1073    fn test_podcast_social_interact_default() {
1074        let si = PodcastSocialInteract::default();
1075        assert!(si.uri.is_empty());
1076        assert!(si.protocol.is_none());
1077        assert!(si.account_id.is_none());
1078        assert!(si.account_url.is_none());
1079        assert!(si.priority.is_none());
1080    }
1081
1082    #[test]
1083    fn test_podcast_txt_default() {
1084        let txt = PodcastTxt::default();
1085        assert!(txt.purpose.is_none());
1086        assert!(txt.value.is_empty());
1087    }
1088
1089    #[test]
1090    fn test_podcast_update_frequency_default() {
1091        let uf = PodcastUpdateFrequency::default();
1092        assert!(uf.rrule.is_none());
1093        assert!(uf.complete.is_none());
1094        assert!(uf.dtstart.is_none());
1095        assert!(uf.label.is_none());
1096    }
1097
1098    #[test]
1099    fn test_podcast_follow_default() {
1100        let f = PodcastFollow::default();
1101        assert!(f.url.is_empty());
1102        assert!(f.platform.is_none());
1103    }
1104
1105    #[test]
1106    fn test_podcast_remote_item_default() {
1107        let item = PodcastRemoteItem::default();
1108        assert!(item.feed_guid.is_none());
1109        assert!(item.feed_url.is_none());
1110        assert!(item.item_guid.is_none());
1111        assert!(item.medium.is_none());
1112        assert!(item.title.is_none());
1113    }
1114
1115    #[test]
1116    fn test_podcast_alternate_enclosure_default() {
1117        let ae = PodcastAlternateEnclosure::default();
1118        assert!(ae.type_.is_empty());
1119        assert!(ae.length.is_none());
1120        assert!(ae.bitrate.is_none());
1121        assert!(ae.sources.is_empty());
1122        assert!(ae.integrity.is_none());
1123    }
1124
1125    #[expect(
1126        clippy::redundant_clone,
1127        reason = "the test checks that the clone equals the original"
1128    )]
1129    #[test]
1130    fn test_podcast_transcript_clone() {
1131        let transcript = PodcastTranscript {
1132            url: "https://example.com/transcript.txt".to_string().into(),
1133            transcript_type: Some("text/plain".to_string().into()),
1134            language: Some("en".to_string()),
1135            rel: None,
1136        };
1137        let cloned = transcript.clone();
1138        assert_eq!(cloned.url, "https://example.com/transcript.txt");
1139        assert_eq!(cloned.transcript_type.as_deref(), Some("text/plain"));
1140    }
1141
1142    #[expect(
1143        clippy::redundant_clone,
1144        reason = "the test checks that the clone equals the original"
1145    )]
1146    #[test]
1147    fn test_podcast_funding_clone() {
1148        let funding = PodcastFunding {
1149            url: "https://example.com/donate".to_string().into(),
1150            message: Some("Support us!".to_string()),
1151        };
1152        let cloned = funding.clone();
1153        assert_eq!(cloned.url, "https://example.com/donate");
1154        assert_eq!(cloned.message.as_deref(), Some("Support us!"));
1155    }
1156
1157    #[expect(
1158        clippy::redundant_clone,
1159        reason = "the test checks that the clone equals the original"
1160    )]
1161    #[test]
1162    fn test_podcast_person_clone() {
1163        let person = PodcastPerson {
1164            name: "John Doe".to_string(),
1165            role: Some("host".to_string()),
1166            group: None,
1167            img: Some("https://example.com/john.jpg".to_string().into()),
1168            href: Some("https://example.com".to_string().into()),
1169        };
1170        let cloned = person.clone();
1171        assert_eq!(cloned.name, "John Doe");
1172        assert_eq!(cloned.role.as_deref(), Some("host"));
1173    }
1174
1175    #[test]
1176    fn test_podcast_chapters_default() {
1177        let chapters = PodcastChapters::default();
1178        assert!(chapters.url.is_empty());
1179        assert!(chapters.type_.is_empty());
1180    }
1181
1182    #[expect(
1183        clippy::redundant_clone,
1184        reason = "the test checks that the clone equals the original"
1185    )]
1186    #[test]
1187    fn test_podcast_chapters_clone() {
1188        let chapters = PodcastChapters {
1189            url: "https://example.com/chapters.json".to_string().into(),
1190            type_: "application/json+chapters".to_string().into(),
1191        };
1192        let cloned = chapters.clone();
1193        assert_eq!(cloned.url, "https://example.com/chapters.json");
1194        assert_eq!(cloned.type_, "application/json+chapters");
1195    }
1196
1197    #[test]
1198    fn test_podcast_soundbite_default() {
1199        let soundbite = PodcastSoundbite::default();
1200        assert!((soundbite.start_time - 0.0).abs() < f64::EPSILON);
1201        assert!((soundbite.duration - 0.0).abs() < f64::EPSILON);
1202        assert!(soundbite.title.is_none());
1203    }
1204
1205    #[expect(
1206        clippy::redundant_clone,
1207        reason = "the test checks that the clone equals the original"
1208    )]
1209    #[test]
1210    fn test_podcast_soundbite_clone() {
1211        let soundbite = PodcastSoundbite {
1212            start_time: 120.5,
1213            duration: 30.0,
1214            title: Some("Great quote".to_string()),
1215        };
1216        let cloned = soundbite.clone();
1217        assert!((cloned.start_time - 120.5).abs() < f64::EPSILON);
1218        assert!((cloned.duration - 30.0).abs() < f64::EPSILON);
1219        assert_eq!(cloned.title.as_deref(), Some("Great quote"));
1220    }
1221
1222    #[test]
1223    fn test_podcast_entry_meta_default() {
1224        let meta = PodcastEntryMeta::default();
1225        assert!(meta.transcript.is_empty());
1226        assert!(meta.chapters.is_none());
1227        assert!(meta.soundbite.is_empty());
1228        assert!(meta.persons.is_empty());
1229        assert!(meta.medium.is_none());
1230    }
1231
1232    #[test]
1233    fn test_itunes_feed_meta_new_fields() {
1234        let meta = ItunesFeedMeta {
1235            complete: Some("Yes".to_string()),
1236            new_feed_url: Some("https://example.com/new-feed.xml".to_string().into()),
1237            ..Default::default()
1238        };
1239
1240        assert_eq!(meta.complete.as_deref(), Some("Yes"));
1241        assert_eq!(
1242            meta.new_feed_url.as_deref(),
1243            Some("https://example.com/new-feed.xml")
1244        );
1245    }
1246
1247    #[test]
1248    fn test_podcast_value_default() {
1249        let value = PodcastValue::default();
1250        assert!(value.type_.is_empty());
1251        assert!(value.method.is_empty());
1252        assert!(value.suggested.is_none());
1253        assert!(value.recipients.is_empty());
1254        assert!(value.time_splits.is_empty());
1255    }
1256
1257    #[test]
1258    fn test_podcast_value_lightning() {
1259        let value = PodcastValue {
1260            type_: "lightning".to_string(),
1261            method: "keysend".to_string(),
1262            suggested: Some("0.00000005000".to_string()),
1263            recipients: vec![
1264                PodcastValueRecipient {
1265                    name: Some("Host".to_string()),
1266                    type_: "node".to_string(),
1267                    address: "03ae9f91a0cb8ff43840e3c322c4c61f019d8c1c3cea15a25cfc425ac605e61a4a"
1268                        .to_string(),
1269                    split: 90,
1270                    fee: Some(false),
1271                },
1272                PodcastValueRecipient {
1273                    name: Some("Producer".to_string()),
1274                    type_: "node".to_string(),
1275                    address: "02d5c1bf8b940dc9cadca86d1b0a3c37fbe39cee4c7e839e33bef9174531d27f52"
1276                        .to_string(),
1277                    split: 10,
1278                    fee: Some(false),
1279                },
1280            ],
1281            time_splits: vec![],
1282        };
1283
1284        assert_eq!(value.type_, "lightning");
1285        assert_eq!(value.method, "keysend");
1286        assert_eq!(value.suggested.as_deref(), Some("0.00000005000"));
1287        assert_eq!(value.recipients.len(), 2);
1288        assert_eq!(value.recipients[0].split, 90);
1289        assert_eq!(value.recipients[1].split, 10);
1290    }
1291
1292    #[test]
1293    fn test_podcast_value_recipient_default() {
1294        let recipient = PodcastValueRecipient::default();
1295        assert!(recipient.name.is_none());
1296        assert!(recipient.type_.is_empty());
1297        assert!(recipient.address.is_empty());
1298        assert_eq!(recipient.split, 0);
1299        assert!(recipient.fee.is_none());
1300    }
1301
1302    #[test]
1303    fn test_podcast_value_recipient_with_fee() {
1304        let recipient = PodcastValueRecipient {
1305            name: Some("Hosting Provider".to_string()),
1306            type_: "node".to_string(),
1307            address: "02d5c1bf8b940dc9cadca86d1b0a3c37fbe39cee4c7e839e33bef9174531d27f52"
1308                .to_string(),
1309            split: 5,
1310            fee: Some(true),
1311        };
1312
1313        assert_eq!(recipient.name.as_deref(), Some("Hosting Provider"));
1314        assert_eq!(recipient.split, 5);
1315        assert_eq!(recipient.fee, Some(true));
1316    }
1317
1318    #[test]
1319    fn test_podcast_value_recipient_without_name() {
1320        let recipient = PodcastValueRecipient {
1321            name: None,
1322            type_: "node".to_string(),
1323            address: "03ae9f91a0cb8ff43840e3c322c4c61f019d8c1c3cea15a25cfc425ac605e61a4a"
1324                .to_string(),
1325            split: 100,
1326            fee: Some(false),
1327        };
1328
1329        assert!(recipient.name.is_none());
1330        assert_eq!(recipient.split, 100);
1331    }
1332
1333    #[test]
1334    fn test_podcast_value_multiple_recipients() {
1335        let mut value = PodcastValue {
1336            type_: "lightning".to_string(),
1337            method: "keysend".to_string(),
1338            suggested: None,
1339            recipients: Vec::new(),
1340            time_splits: vec![],
1341        };
1342
1343        // Add multiple recipients
1344        for i in 1..=5 {
1345            value.recipients.push(PodcastValueRecipient {
1346                name: Some(format!("Recipient {i}")),
1347                type_: "node".to_string(),
1348                address: format!("address_{i}"),
1349                split: 20,
1350                fee: Some(false),
1351            });
1352        }
1353
1354        assert_eq!(value.recipients.len(), 5);
1355        assert_eq!(value.recipients.iter().map(|r| r.split).sum::<u32>(), 100);
1356    }
1357
1358    #[test]
1359    fn test_podcast_value_hive() {
1360        let value = PodcastValue {
1361            type_: "hive".to_string(),
1362            method: "direct".to_string(),
1363            suggested: Some("1.00000".to_string()),
1364            recipients: vec![PodcastValueRecipient {
1365                name: Some("@username".to_string()),
1366                type_: "account".to_string(),
1367                address: "username".to_string(),
1368                split: 100,
1369                fee: Some(false),
1370            }],
1371            time_splits: vec![],
1372        };
1373
1374        assert_eq!(value.type_, "hive");
1375        assert_eq!(value.method, "direct");
1376    }
1377
1378    #[test]
1379    fn test_podcast_meta_with_value() {
1380        let mut meta = PodcastMeta::default();
1381        assert!(meta.value.is_none());
1382
1383        meta.value = Some(PodcastValue {
1384            type_: "lightning".to_string(),
1385            method: "keysend".to_string(),
1386            suggested: Some("0.00000005000".to_string()),
1387            recipients: vec![],
1388            time_splits: vec![],
1389        });
1390
1391        assert!(meta.value.is_some());
1392        assert_eq!(meta.value.as_ref().unwrap().type_, "lightning");
1393    }
1394
1395    #[expect(
1396        clippy::redundant_clone,
1397        reason = "the test checks that the clone equals the original"
1398    )]
1399    #[test]
1400    fn test_podcast_value_clone() {
1401        let value = PodcastValue {
1402            type_: "lightning".to_string(),
1403            method: "keysend".to_string(),
1404            suggested: Some("0.00000005000".to_string()),
1405            recipients: vec![PodcastValueRecipient {
1406                name: Some("Host".to_string()),
1407                type_: "node".to_string(),
1408                address: "abc123".to_string(),
1409                split: 100,
1410                fee: Some(false),
1411            }],
1412            time_splits: vec![],
1413        };
1414
1415        let cloned = value.clone();
1416        assert_eq!(cloned.type_, "lightning");
1417        assert_eq!(cloned.recipients.len(), 1);
1418        assert_eq!(cloned.recipients[0].name.as_deref(), Some("Host"));
1419    }
1420}