Update to latest hydrus-api version and fix hyphens in tags

Signed-off-by: trivernis <trivernis@protonmail.com>
main
trivernis 3 years ago
parent f4b3f154e9
commit f3d99030b8
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="DISABLE" />
<option name="description" value="" />
</component>
</project>

63
Cargo.lock generated

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "addr2line" name = "addr2line"
version = "0.15.2" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd"
dependencies = [ dependencies = [
"gimli", "gimli",
] ]
@ -60,9 +60,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.60" version = "0.3.61"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282" checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cc", "cc",
@ -141,6 +141,19 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"time",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.33.3" version = "2.33.3"
@ -456,9 +469,9 @@ dependencies = [
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.24.0" version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
[[package]] [[package]]
name = "h2" name = "h2"
@ -586,10 +599,11 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "hydrus-api" name = "hydrus-api"
version = "0.3.5" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c3d77ead8850900dd72e8be8ae06d068408310ceb75876ef81ad06f9ca12d5b" checksum = "ce38cc8d4f48084f33168b7e6366647e3d6528f44ff2b8e5a83168102e88f94f"
dependencies = [ dependencies = [
"chrono",
"log", "log",
"mime", "mime",
"reqwest 0.11.4", "reqwest 0.11.4",
@ -598,7 +612,7 @@ dependencies = [
[[package]] [[package]]
name = "hydrus-pixiv-tagger" name = "hydrus-pixiv-tagger"
version = "0.1.2" version = "0.2.0"
dependencies = [ dependencies = [
"env_logger", "env_logger",
"hydrus-api", "hydrus-api",
@ -937,6 +951,25 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg 1.0.1",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg 1.0.1",
]
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
version = "1.13.0" version = "1.13.0"
@ -949,9 +982,9 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.25.3" version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7" checksum = "c55827317fb4c08822499848a14237d2874d6f139828893017237e7ab93eb386"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -1508,9 +1541,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.64" version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" checksum = "28c5e91e4240b46c4c19219d6cc84784444326131a4210f496f948d5cc827a29"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -1558,9 +1591,9 @@ dependencies = [
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad"
dependencies = [ dependencies = [
"libc", "libc",
"winapi 0.3.9", "winapi 0.3.9",

@ -1,6 +1,6 @@
[package] [package]
name = "hydrus-pixiv-tagger" name = "hydrus-pixiv-tagger"
version = "0.1.2" version = "0.2.0"
edition = "2018" edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
description = "Automatically tag hydrus file by using pixiv and saucenao" description = "Automatically tag hydrus file by using pixiv and saucenao"
@ -12,7 +12,7 @@ repository = "https://github.com/Trivernis/hydrus-pixiv-tagger"
[dependencies] [dependencies]
pixiv-rs = "0.1.0" pixiv-rs = "0.1.0"
hydrus-api = "0.3.5" hydrus-api = "0.4.0"
rustnao = "0.2" rustnao = "0.2"
structopt = "0.3.22" structopt = "0.3.22"
tempdir = "0.3.7" tempdir = "0.3.7"

@ -1,7 +1,6 @@
mod error; mod error;
use crate::error::Result; use crate::error::Result;
use hydrus_api::api_core::searching_and_fetching_files::FileSearchLocation;
use hydrus_api::wrapper::hydrus_file::HydrusFile; use hydrus_api::wrapper::hydrus_file::HydrusFile;
use hydrus_api::wrapper::service::ServiceName; use hydrus_api::wrapper::service::ServiceName;
use hydrus_api::wrapper::tag::Tag; use hydrus_api::wrapper::tag::Tag;
@ -10,40 +9,37 @@ use pixiv_rs::PixivClient;
use rustnao::{Handler, HandlerBuilder, Sauce}; use rustnao::{Handler, HandlerBuilder, Sauce};
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use structopt::clap::AppSettings;
use structopt::StructOpt; use structopt::StructOpt;
use tempdir::TempDir; use tempdir::TempDir;
use tokio::time::{Duration, Instant}; use tokio::time::{Duration, Instant};
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt()] #[structopt(settings = &[AppSettings::AllowLeadingHyphen])]
struct Opt { struct Opt {
/// Tags used to search for files
#[structopt(short, long)]
tags: Vec<String>,
/// The saucenao api key /// The saucenao api key
#[structopt(long)] #[structopt(long, env)]
saucenao_key: String, saucenao_key: String,
/// The hydrus client api key /// The hydrus client api key
#[structopt(long)] #[structopt(long, env)]
hydrus_key: String, hydrus_key: String,
/// The url to the hydrus client api /// The url to the hydrus client api
#[structopt(long, default_value = "http://127.0.0.1:45869")] #[structopt(long, default_value = "http://127.0.0.1:45869", env)]
hydrus_url: String, hydrus_url: String,
/// The tag service the tags will be assigned to /// The tag service the tags will be assigned to
#[structopt(long, default_value = "my tags")] #[structopt(long, default_value = "my tags")]
tag_service: String, tag_service: String,
/// Searches in the inbox instead
#[structopt(long)]
inbox: bool,
/// Tag that is assigned to files that have been processed /// Tag that is assigned to files that have been processed
#[structopt(long)] #[structopt(long)]
finish_tag: Option<String>, finish_tag: Option<String>,
/// Tags used to search for files
#[structopt(short, long)]
tags: Vec<String>,
} }
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
@ -60,15 +56,11 @@ async fn main() {
let hydrus = Hydrus::new(Client::new(opt.hydrus_url, opt.hydrus_key)); let hydrus = Hydrus::new(Client::new(opt.hydrus_url, opt.hydrus_key));
let pixiv = PixivClient::new(); let pixiv = PixivClient::new();
let search_location = if opt.inbox {
FileSearchLocation::Inbox
} else {
FileSearchLocation::Archive
};
let tags = opt.tags.into_iter().map(Tag::from).collect(); let tags = opt.tags.into_iter().map(Tag::from).collect();
let service = ServiceName(opt.tag_service); let service = ServiceName(opt.tag_service);
let files = hydrus.search(search_location, tags).await.unwrap(); let files = hydrus.search(tags).await.unwrap();
log::info!("Found {} files", files.len());
let tmpdir = TempDir::new("hydrus-files").unwrap(); let tmpdir = TempDir::new("hydrus-files").unwrap();
let sleep_duration = Duration::from_secs(6); let sleep_duration = Duration::from_secs(6);

Loading…
Cancel
Save