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

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

@ -1,7 +1,6 @@
mod error;
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::service::ServiceName;
use hydrus_api::wrapper::tag::Tag;
@ -10,40 +9,37 @@ use pixiv_rs::PixivClient;
use rustnao::{Handler, HandlerBuilder, Sauce};
use std::fs;
use std::path::PathBuf;
use structopt::clap::AppSettings;
use structopt::StructOpt;
use tempdir::TempDir;
use tokio::time::{Duration, Instant};
#[derive(StructOpt, Debug)]
#[structopt()]
#[structopt(settings = &[AppSettings::AllowLeadingHyphen])]
struct Opt {
/// Tags used to search for files
#[structopt(short, long)]
tags: Vec<String>,
/// The saucenao api key
#[structopt(long)]
#[structopt(long, env)]
saucenao_key: String,
/// The hydrus client api key
#[structopt(long)]
#[structopt(long, env)]
hydrus_key: String,
/// 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,
/// The tag service the tags will be assigned to
#[structopt(long, default_value = "my tags")]
tag_service: String,
/// Searches in the inbox instead
#[structopt(long)]
inbox: bool,
/// Tag that is assigned to files that have been processed
#[structopt(long)]
finish_tag: Option<String>,
/// Tags used to search for files
#[structopt(short, long)]
tags: Vec<String>,
}
#[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 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 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 sleep_duration = Duration::from_secs(6);

Loading…
Cancel
Save