diff --git a/src/main.rs b/src/main.rs index 8aa2da6..804c25a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,6 @@ mod trackers; use anyhow::Result; use config::Config; use debug::Debug; -use format::Format; use index::Index; use librqbit::{ AddTorrent, AddTorrentOptions, AddTorrentResponse, ByteBufOwned, ConnectionOptions, @@ -250,7 +249,7 @@ async fn main() -> Result<()> { rss.push( k, v.name().unwrap_or(k), - v.size().map(|l| l.bytes()), + rss::item_description(v.size(), v.list()), Some(&v.time.to_rfc2822()), )? } @@ -317,23 +316,23 @@ fn list(info: &TorrentMetaV1Info, limit: usize) -> Option, list: Option<&Vec<(String, u64)>>) -> Option { + if size.is_none() && list.is_none() { + return None; + } + let mut b = Vec::with_capacity(list.map(|l| l.len()).unwrap_or_default() + 1); + if let Some(s) = size { + use crate::format::Format; + b.push(s.bytes()) + } + if let Some(l) = list { + for (path, size) in l { + b.push(format!("* {path}: {size}")) + } + } + Some(b.join("
\n")) +} + fn escape(subject: &str) -> String { subject .replace('&', "&")