Fix: minor fixes

main
Óscar M. Lage 2022-11-18 19:59:28 +01:00
parent a7de875f12
commit e311576f50
1 changed files with 7 additions and 3 deletions

View File

@ -11,6 +11,8 @@ struct Config {
url: String,
author: String,
path: String,
version: String,
description: String,
}
#[derive(Debug)]
@ -24,10 +26,9 @@ struct Toot {
}
fn download_media(url: String, path: String) {
print!("Downloading media images: {:?}", url);
println!(" - Downloading media images: {:?}", url);
let mut file = reqwest::blocking::get(url.clone()).unwrap();
let filename = Path::new(&url).file_name().unwrap().to_str().unwrap();
println!("file: {:?}", file);
let mut out = File::create(format!("{}/{}", path, filename)).unwrap();
copy(&mut file, &mut out).expect("Error copying file");
}
@ -44,7 +45,10 @@ fn main() {
url: "https://mastodon.bofhers.es/tags/micropost.rss".to_string(),
author: "oscarmlage".to_string(),
path: "temp/".to_string(),
version: "0.0.1".to_string(),
description: "Just another tool to convert RSS from Mastodon to Markdown".to_string(),
};
println!("\n✨ masto-rss v.{} - {}\n", config.version, config.description);
let rss = reqwest::blocking::get(config.url).unwrap().bytes();
let rss2 = rss.unwrap();
let channel = Channel::read_from(&rss2[..]).unwrap();
@ -54,7 +58,7 @@ fn main() {
let dt = item.pub_date.as_ref().unwrap();
let datetime = chrono::DateTime::parse_from_rfc2822(dt.as_str()).unwrap();
let title = datetime.format("%Y%m%d-%H%M").to_string();
println!("{:?}", title);
println!("➡️ {:?}", title);
let mut toot = Toot{
title: title.to_string(),
date: datetime.to_string(),