Compare commits
No commits in common. "f76b7194ca8dd21c46a0b52a5d8eb2354c44b3e7" and "e311576f5090c27e5ac35ced63da0d91f00fd812" have entirely different histories.
f76b7194ca
...
e311576f50
@ -9,6 +9,3 @@ edition = "2021"
|
||||
reqwest = { version = "0.11.12", features = ["blocking"] }
|
||||
rss = "2.0.1"
|
||||
chrono = "0.4.23"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0.40"
|
||||
toml = "0.4.2"
|
||||
|
2
Makefile
2
Makefile
@ -2,9 +2,7 @@ bash:
|
||||
docker-compose run --rm dev
|
||||
|
||||
build:
|
||||
clear
|
||||
cargo build
|
||||
|
||||
run:
|
||||
clear
|
||||
cargo run
|
||||
|
39
src/main.rs
39
src/main.rs
@ -6,10 +6,7 @@ use std::io::Write;
|
||||
use std::io::copy;
|
||||
use rss::Channel;
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
use toml;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug)]
|
||||
struct Config {
|
||||
url: String,
|
||||
author: String,
|
||||
@ -18,23 +15,6 @@ struct Config {
|
||||
description: String,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn default() -> Config {
|
||||
Config {
|
||||
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(),
|
||||
}
|
||||
}
|
||||
pub fn parse(&mut self, config_file: String) -> Config {
|
||||
let i = std::fs::read_to_string(config_file).expect("Error reading the file");
|
||||
let myconfig: Self = toml::from_str(&i).unwrap();
|
||||
myconfig
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Toot {
|
||||
title: String,
|
||||
@ -59,14 +39,15 @@ fn write_to_disk(toot: &Toot, path: String, title: String) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Default config file
|
||||
let default_config = ".config/masto-rss/masto-rss.ini";
|
||||
let home = std::env::var("HOME").unwrap();
|
||||
let cfg = format!("{}/{}", home, default_config);
|
||||
// Read the config file
|
||||
let mut default_config = Config::default();
|
||||
let config = default_config.parse(cfg.to_string());
|
||||
|
||||
// Configure RSS url, author and path where the .md will be stored
|
||||
let config = Config {
|
||||
// url: "https://mastodon.bofhers.es/@oscarmlage.rss",
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user