diff --git a/src/feed.rs b/src/feed.rs index 670bae2..db17b29 100644 --- a/src/feed.rs +++ b/src/feed.rs @@ -55,9 +55,9 @@ impl Feed { /// Append `item` to the feed `channel` pub fn push(&mut self, torrent: Torrent) { - let info_hash = torrent.info_hash.as_string(); self.buffer.push_str(&format!( - "{info_hash}{}{}", + "{}{}{}", + &torrent.info_hash, escape( &torrent .name @@ -65,7 +65,7 @@ impl Feed { .map(|b| b.to_string()) .unwrap_or("?".into()) // @TODO ), - self.canonical.link(&info_hash) + self.canonical.link(&torrent.info_hash) )); self.buffer.push_str(""); diff --git a/src/main.rs b/src/main.rs index eec7e3b..afb5869 100644 --- a/src/main.rs +++ b/src/main.rs @@ -82,7 +82,7 @@ fn index( files: torrent.files(), indexed: torrent.time.format(&meta.format_time).to_string(), magnet: torrent.magnet(meta.trackers.as_ref()), - scrape: scrape::get(scrape, torrent.info_hash.0), + scrape: scrape::get(scrape, torrent.id.0), size: torrent.size as usize, // required by `filesizeformat` impl torrent }), @@ -141,7 +141,7 @@ fn info( .map(|f| { let p = f.path(); F { - href: public.href(&torrent.info_hash.as_string(), &p), + href: public.href(&torrent.info_hash, &p), path: p, size: f.length as usize, // required by `filesizeformat` impl } diff --git a/src/torrent.rs b/src/torrent.rs index f944a77..cf7a668 100644 --- a/src/torrent.rs +++ b/src/torrent.rs @@ -16,7 +16,8 @@ pub struct Torrent { pub created_by: Option, pub creation_date: Option>, pub files: Option>, - pub info_hash: Id20, + pub id: Id20, + pub info_hash: String, pub is_private: bool, pub length: Option, pub name: Option, @@ -32,7 +33,8 @@ impl Torrent { let i: TorrentMetaV1Owned = torrent_metainfo::torrent_from_bytes(bytes).map_err(|e| e.to_string())?; Ok(Torrent { - info_hash: i.info_hash, + id: i.info_hash, + info_hash: i.info_hash.as_string(), announce: i.announce.map(|a| a.to_string()), comment: i.comment.map(|c| c.to_string()), created_by: i.created_by.map(|c| c.to_string()), @@ -79,7 +81,7 @@ impl Torrent { } pub fn magnet(&self, trackers: Option<&Vec>) -> String { - let mut b = format!("magnet:?xt=urn:btih:{}", self.info_hash.as_string()); + let mut b = format!("magnet:?xt=urn:btih:{}", self.info_hash); if let Some(ref n) = self.name { b.push_str("&dn="); b.push_str(&urlencoding::encode(n))