Compare commits
No commits in common. "2bd746c31a2f83a8b24cd11ee976fe90015866da" and "8a9a3174abd0393f40e95545d4d7af51c40cf5c3" have entirely different histories.
2bd746c31a
...
8a9a3174ab
2 changed files with 5 additions and 20 deletions
|
@ -25,7 +25,7 @@ pub(super) async fn format_status(
|
||||||
time_prefix = time_prefix,
|
time_prefix = time_prefix,
|
||||||
timestamp = status.created_at.with_timezone(&Local).format("%H:%M"),
|
timestamp = status.created_at.with_timezone(&Local).format("%H:%M"),
|
||||||
ancestor_prefix = ancestor_prefix,
|
ancestor_prefix = ancestor_prefix,
|
||||||
status = apply_block_quote(depth, parse_html(&status.content).trim()),
|
status = apply_block_quote(depth, (&status.content).trim()),
|
||||||
attachments = format_attachments(depth, &status.media_attachments)
|
attachments = format_attachments(depth, &status.media_attachments)
|
||||||
);
|
);
|
||||||
let Response { json, .. } = client.get_status_context(status.id.clone(), None).await?;
|
let Response { json, .. } = client.get_status_context(status.id.clone(), None).await?;
|
||||||
|
|
23
src/main.rs
23
src/main.rs
|
@ -1,4 +1,4 @@
|
||||||
use anyhow::{Context, Result};
|
use anyhow::Result;
|
||||||
use chrono::{DateTime, Local, Utc};
|
use chrono::{DateTime, Local, Utc};
|
||||||
use clap::{arg, command, Parser};
|
use clap::{arg, command, Parser};
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
|
@ -9,7 +9,6 @@ use megalodon::{
|
||||||
response::Response,
|
response::Response,
|
||||||
Megalodon,
|
Megalodon,
|
||||||
};
|
};
|
||||||
use tokio::fs::try_exists;
|
|
||||||
use tokio_stream::{iter, StreamExt};
|
use tokio_stream::{iter, StreamExt};
|
||||||
|
|
||||||
use std::{env, fs::File, io::prelude::*};
|
use std::{env, fs::File, io::prelude::*};
|
||||||
|
@ -122,23 +121,9 @@ async fn main() -> Result<()> {
|
||||||
reversed.reverse();
|
reversed.reverse();
|
||||||
|
|
||||||
if let Some(output_dir) = output_dir {
|
if let Some(output_dir) = output_dir {
|
||||||
let output = format!("{}/{}.md", output_dir.trim_end_matches("/"), date);
|
let output = format!("{}{}.md", output_dir, date);
|
||||||
let mut f = match try_exists(&output).await {
|
let mut f = File::options().append(true).open(&output)?;
|
||||||
Ok(exists) if exists => {
|
f.write_all(&reversed.join("\n\n").as_bytes())?;
|
||||||
debug!("Appending {}", output);
|
|
||||||
File::options().append(true).open(&output)?
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
debug!("Writing {}", output);
|
|
||||||
File::options()
|
|
||||||
.create(true)
|
|
||||||
.append(true)
|
|
||||||
.open(&output)
|
|
||||||
.with_context(|| format!("Failed to create {}", output))?
|
|
||||||
}
|
|
||||||
};
|
|
||||||
f.write_all(&reversed.join("\n\n").as_bytes())
|
|
||||||
.with_context(|| format!("Failed to write all to {}", output))?;
|
|
||||||
println!("Appended matching posts to {}.", output);
|
println!("Appended matching posts to {}.", output);
|
||||||
} else {
|
} else {
|
||||||
println!("{}", reversed.join("\n\n"));
|
println!("{}", reversed.join("\n\n"));
|
||||||
|
|
Loading…
Reference in a new issue