From c83ce5a0944fe254c996f77bd13e133c272d3cc9 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Mon, 7 Sep 2026 13:26:00 +0100 Subject: merge fetched RSS namespaces as much as possible and warn about conflicts to stderr --- src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 2f1435b..1cc6c5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,6 +58,27 @@ fn generate_channel(urls: Vec, config: Config) -> Channel { let mut channel = make_new_empty_channel(config); block_on(async { retrieve(urls.iter().map(AsRef::as_ref)).await.for_each(|c| { + for (prefix, uri) in c.namespace { + let existing_namespace = channel.namespace.iter().find(|(p, u)| p == prefix); + if let Some(existing_namespace) = existing_namespace { + if existing_namespace.1.trim().len() == 0 { + existing_namespace.1 = uri; + } else if uri.len() > 0 { + eprintln!( + "Warning: channel {0} has namespace xmlns:{1}=\"{2}\", but the aggregated feed already has xmlns:{1}=\"{3}\". Ignoring.", + c.link, + prefix, + existing_namespace.1, + uri); + } else { + eprintln!( + "Appending namespace xmlns:{0}=\"{1}\" from channel {2}.", + prefix, + uri, + c.link); + channel.namespace.insert(prefix, uri); + } + } channel.items.append(&mut items_with_source(c)); future::ready(()) }).await; -- cgit v1.2.3