tiny progress
This commit is contained in:
@ -6,6 +6,7 @@ NO_COLOR="\033[0m" # Text Reset
|
|||||||
IN_FILE="$1_generated.txt"
|
IN_FILE="$1_generated.txt"
|
||||||
SUCCESS_FILE="$1_success.txt"
|
SUCCESS_FILE="$1_success.txt"
|
||||||
FAIL_FILE="$1_failed.txt"
|
FAIL_FILE="$1_failed.txt"
|
||||||
|
SUCCESS="false"
|
||||||
|
|
||||||
if [[ $(hostname) == \s\a\t\a\n ]]; then
|
if [[ $(hostname) == \s\a\t\a\n ]]; then
|
||||||
[[ -d ./Artists ]] || mkdir ./Artists
|
[[ -d ./Artists ]] || mkdir ./Artists
|
||||||
@ -17,11 +18,11 @@ download() {
|
|||||||
# echo "path: $2"
|
# echo "path: $2"
|
||||||
|
|
||||||
for ((n=0;n<5;n++)); do
|
for ((n=0;n<5;n++)); do
|
||||||
#echo "gallery-dl --config ./gallery-dl/config.json --directory $2 $1"
|
|
||||||
gallery-dl --config ./gallery-dl/config.json --directory "$2" "$1"
|
gallery-dl --config ./gallery-dl/config.json --directory "$2" "$1"
|
||||||
|
|
||||||
if [ $(echo $?) == 0 ]; then
|
if [ $(echo $?) == 0 ]; then
|
||||||
echo "$1" >> "$SUCCESS_FILE"
|
echo "$1" >> "$SUCCESS_FILE"
|
||||||
|
$SUCCESS="true"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
echo -e "${IYELLOW}download failed${NO_COLOR}"
|
echo -e "${IYELLOW}download failed${NO_COLOR}"
|
||||||
@ -35,8 +36,10 @@ download() {
|
|||||||
fi
|
fi
|
||||||
echo -e "${IGREEN}has internet${NO_COLOR}"
|
echo -e "${IGREEN}has internet${NO_COLOR}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "$1" >> "$FAIL_FILE"
|
if [ $SUCCESS != \t\r\u\e ]; then
|
||||||
|
echo "$1" >> "$FAIL_FILE"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cargo run -- generate "$1"
|
cargo run -- generate "$1"
|
||||||
@ -53,6 +56,6 @@ while IFS= read -r line; do
|
|||||||
download $url $path
|
download $url $path
|
||||||
done < "$IN_FILE"
|
done < "$IN_FILE"
|
||||||
|
|
||||||
[[ -s $FAIL_FILE ]] && curl -d 'bruh' ntfy.hopeless-cloud.xyz/Hentai
|
# [[ -s $FAIL_FILE ]] && curl -d 'bruh' ntfy.hopeless-cloud.xyz/Hentai
|
||||||
|
|
||||||
[[ $(hostname) != \s\a\t\a\n ]] && cp ./gallery-dl/archive-${1,,}.sqlite3 /data/backup
|
[[ $(hostname) != \s\a\t\a\n ]] && cp ./gallery-dl/archive-${1,,}.sqlite3 /data/backup
|
||||||
|
32
src/main.rs
32
src/main.rs
@ -20,10 +20,10 @@ fn run_as_cli() {
|
|||||||
let mut client = Client::connect("host=192.168.0.10 port=28945 user=hentai password=h99nqaNPhpfbuuhCDwQXLpZAnoVTjSQP7taoqmQhpzc2rPLVC4JUAKxAHfuuhuU9", NoTls).unwrap();
|
let mut client = Client::connect("host=192.168.0.10 port=28945 user=hentai password=h99nqaNPhpfbuuhCDwQXLpZAnoVTjSQP7taoqmQhpzc2rPLVC4JUAKxAHfuuhuU9", NoTls).unwrap();
|
||||||
let mut option: String = String::new();
|
let mut option: String = String::new();
|
||||||
|
|
||||||
loop {
|
show_usage();
|
||||||
show_usage();
|
println!("Please input any of these options or type \'exit\' to leave");
|
||||||
println!("Please input any of these options or type \'exit\' to leave");
|
|
||||||
|
|
||||||
|
loop {
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.read_line(&mut option)
|
.read_line(&mut option)
|
||||||
.expect("Failed to read input");
|
.expect("Failed to read input");
|
||||||
@ -39,7 +39,7 @@ fn run_as_cli() {
|
|||||||
"add_custom_name" => add_artist_with_custom_name(&mut client, None),
|
"add_custom_name" => add_artist_with_custom_name(&mut client, None),
|
||||||
"exit" => break,
|
"exit" => break,
|
||||||
_ => {
|
_ => {
|
||||||
println!("Invalid option!");
|
eprintln!("Invalid option!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ fn run_with_input(arguments: Vec<String>) {
|
|||||||
let values: Vec<String> = vec![arguments[2].clone(), arguments[3].clone()];
|
let values: Vec<String> = vec![arguments[2].clone(), arguments[3].clone()];
|
||||||
add_artist_with_custom_name(&mut client, Option::Some(values))
|
add_artist_with_custom_name(&mut client, Option::Some(values))
|
||||||
}
|
}
|
||||||
_ => panic!("Invalid argument"),
|
_ => eprintln!("Invalid argument"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,15 +85,17 @@ fn generate_file(client: &mut postgres::Client, website: Option<String>) {
|
|||||||
|
|
||||||
let result: bool = output.get(0);
|
let result: bool = output.get(0);
|
||||||
if result == false {
|
if result == false {
|
||||||
panic!("Invalid website_name");
|
eprintln!("Invalid website_name");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let filename = format!("{website_name}_generated.txt");
|
let filename = format!("{website_name}_generated.txt");
|
||||||
let mut file = match File::create(filename) {
|
let mut file = match File::create_new(filename) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
let message = error.to_string();
|
let message = error.to_string();
|
||||||
panic!("Problem opening the file: {message}");
|
eprintln!("Problem creating the file: {message}");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,11 +124,12 @@ fn convert_folders(client: &mut postgres::Client, path: Option<String>) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let filename: &str = "convert_folders.log";
|
let filename: &str = "convert_folders.log";
|
||||||
let mut log_file = match File::create(filename) {
|
let mut log_file = match File::create_new(filename) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
let message = error.to_string();
|
let message = error.to_string();
|
||||||
panic!("Problem opening the file: {message}");
|
eprintln!("Problem creating the file: {message}");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -169,11 +172,12 @@ fn import_file(client: &mut postgres::Client, file: Option<String>) {
|
|||||||
let input_file = File::open(filename).unwrap();
|
let input_file = File::open(filename).unwrap();
|
||||||
let reader_iter = BufReader::new(input_file).lines();
|
let reader_iter = BufReader::new(input_file).lines();
|
||||||
|
|
||||||
let mut fucked_file = match File::create("Fucked.txt") {
|
let mut fucked_file = match File::create_new("Fucked.txt") {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
let message = error.to_string();
|
let message = error.to_string();
|
||||||
panic!("Problem opening the file: {message}");
|
eprintln!("Problem creating the file: {message}");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
writeln!(fucked_file, "Them are hella fucked").unwrap();
|
writeln!(fucked_file, "Them are hella fucked").unwrap();
|
||||||
@ -210,7 +214,7 @@ fn add_url(client: &mut postgres::Client, uri: Option<String>) {
|
|||||||
|
|
||||||
let result: i32 = output.get(0);
|
let result: i32 = output.get(0);
|
||||||
if result == 1 {
|
if result == 1 {
|
||||||
panic!("HELP!!!");
|
eprintln!("Database didn\'t like your input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +247,7 @@ fn add_artist_with_custom_name(client: &mut postgres::Client, uri_and_artist: Op
|
|||||||
|
|
||||||
let result: i32 = output.get(0);
|
let result: i32 = output.get(0);
|
||||||
if result == 1 {
|
if result == 1 {
|
||||||
panic!("HELP!!!");
|
eprintln!("Database didn\'t like your input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user