Fix: minor fixes
This commit is contained in:
parent
a7de875f12
commit
e311576f50
10
src/main.rs
10
src/main.rs
@ -11,6 +11,8 @@ struct Config {
|
|||||||
url: String,
|
url: String,
|
||||||
author: String,
|
author: String,
|
||||||
path: String,
|
path: String,
|
||||||
|
version: String,
|
||||||
|
description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -24,10 +26,9 @@ struct Toot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn download_media(url: String, path: String) {
|
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 mut file = reqwest::blocking::get(url.clone()).unwrap();
|
||||||
let filename = Path::new(&url).file_name().unwrap().to_str().unwrap();
|
let filename = Path::new(&url).file_name().unwrap().to_str().unwrap();
|
||||||
println!("file: {:?}", file);
|
|
||||||
let mut out = File::create(format!("{}/{}", path, filename)).unwrap();
|
let mut out = File::create(format!("{}/{}", path, filename)).unwrap();
|
||||||
copy(&mut file, &mut out).expect("Error copying file");
|
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(),
|
url: "https://mastodon.bofhers.es/tags/micropost.rss".to_string(),
|
||||||
author: "oscarmlage".to_string(),
|
author: "oscarmlage".to_string(),
|
||||||
path: "temp/".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 rss = reqwest::blocking::get(config.url).unwrap().bytes();
|
||||||
let rss2 = rss.unwrap();
|
let rss2 = rss.unwrap();
|
||||||
let channel = Channel::read_from(&rss2[..]).unwrap();
|
let channel = Channel::read_from(&rss2[..]).unwrap();
|
||||||
@ -54,7 +58,7 @@ fn main() {
|
|||||||
let dt = item.pub_date.as_ref().unwrap();
|
let dt = item.pub_date.as_ref().unwrap();
|
||||||
let datetime = chrono::DateTime::parse_from_rfc2822(dt.as_str()).unwrap();
|
let datetime = chrono::DateTime::parse_from_rfc2822(dt.as_str()).unwrap();
|
||||||
let title = datetime.format("%Y%m%d-%H%M").to_string();
|
let title = datetime.format("%Y%m%d-%H%M").to_string();
|
||||||
println!("{:?}", title);
|
println!("➡️ {:?}", title);
|
||||||
let mut toot = Toot{
|
let mut toot = Toot{
|
||||||
title: title.to_string(),
|
title: title.to_string(),
|
||||||
date: datetime.to_string(),
|
date: datetime.to_string(),
|
||||||
|
Loading…
Reference in New Issue
Block a user