mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-22 03:05:32 +02:00
refactor: extract archive core crate
This commit is contained in:
parent
0b2afe6398
commit
3cf2c9cd3a
14 changed files with 34 additions and 13 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
|
@ -93,8 +93,20 @@ name = "archivr-cli"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"archivr-core",
|
||||
"chrono",
|
||||
"clap",
|
||||
"regex",
|
||||
"rusqlite",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "archivr-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
"hex",
|
||||
"regex",
|
||||
"rusqlite",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"crates/archivr-core",
|
||||
"crates/archivr-cli",
|
||||
]
|
||||
resolver = "2"
|
||||
|
|
|
|||
|
|
@ -8,12 +8,10 @@ name = "archivr"
|
|||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
archivr-core = { path = "../archivr-core" }
|
||||
anyhow.workspace = true
|
||||
chrono.workspace = true
|
||||
clap.workspace = true
|
||||
hex.workspace = true
|
||||
regex.workspace = true
|
||||
rusqlite.workspace = true
|
||||
serde_json.workspace = true
|
||||
sha3.workspace = true
|
||||
uuid.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use anyhow::{Context, Result};
|
||||
use archivr_core::{database, downloader, twitter::parse_tweet_id};
|
||||
use chrono::Local;
|
||||
use clap::{Parser, Subcommand};
|
||||
use serde_json::json;
|
||||
|
|
@ -9,11 +10,6 @@ use std::{
|
|||
process,
|
||||
};
|
||||
|
||||
mod database;
|
||||
mod downloader;
|
||||
mod hash;
|
||||
mod twitter;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
|
|
@ -87,8 +83,6 @@ enum Source {
|
|||
Other,
|
||||
}
|
||||
|
||||
use crate::twitter::parse_tweet_id;
|
||||
|
||||
fn expand_shorthand_to_url(path: &str, source: &Source) -> String {
|
||||
if *source == Source::X && (path.starts_with("tweet:media:") || path.starts_with("x:media:")) {
|
||||
if let Some(tweet_id) = path.split(':').next_back().and_then(parse_tweet_id) {
|
||||
|
|
|
|||
14
crates/archivr-core/Cargo.toml
Normal file
14
crates/archivr-core/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "archivr-core"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
chrono.workspace = true
|
||||
hex.workspace = true
|
||||
regex.workspace = true
|
||||
rusqlite.workspace = true
|
||||
serde_json.workspace = true
|
||||
sha3.workspace = true
|
||||
uuid.workspace = true
|
||||
|
|
@ -10,9 +10,7 @@ use std::{
|
|||
sync::OnceLock,
|
||||
};
|
||||
|
||||
use crate::twitter::parse_tweet_id;
|
||||
|
||||
use super::store;
|
||||
use crate::{downloader::store, twitter::parse_tweet_id};
|
||||
|
||||
/// Extracts a tweet ID from an archivr path like `"tweet:123"` by taking the
|
||||
/// last colon-separated segment and validating it as a numeric ID.
|
||||
4
crates/archivr-core/src/lib.rs
Normal file
4
crates/archivr-core/src/lib.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
pub mod database;
|
||||
pub mod downloader;
|
||||
pub mod hash;
|
||||
pub mod twitter;
|
||||
Loading…
Add table
Add a link
Reference in a new issue