should be done

This commit is contained in:
2024-11-11 18:38:55 +01:00
parent 34fd8930ec
commit 3a51e92518
6 changed files with 173 additions and 62 deletions

View File

@ -6,8 +6,6 @@ use std::{
};
use urlencoding;
const IS_DEV: bool = true;
fn generate_file(website_name: &str) {
let mut client = Client::connect("host=192.168.0.10 port=28945 user=hentai password=h99nqaNPhpfbuuhCDwQXLpZAnoVTjSQP7taoqmQhpzc2rPLVC4JUAKxAHfuuhuU9", NoTls).unwrap();
let output = client
@ -29,7 +27,7 @@ fn generate_file(website_name: &str) {
};
let output = client
.query("SELECT * FROM get_urls_and_paths($1));", &[&website_name])
.query("SELECT * FROM get_urls_and_paths($1);", &[&website_name])
.unwrap();
for row in output {
@ -81,22 +79,19 @@ fn import_file(filename: &str) {
let reader_iter = BufReader::new(file).lines();
let mut client = Client::connect("host=192.168.0.10 port=28945 user=hentai password=h99nqaNPhpfbuuhCDwQXLpZAnoVTjSQP7taoqmQhpzc2rPLVC4JUAKxAHfuuhuU9", NoTls).unwrap();
let mut other_file = match File::create("Hallo.txt") {
let mut other_file = match File::create("Fucked.txt") {
Ok(file) => file,
Err(error) => {
let message = error.to_string();
panic!("Problem opening the file: {message}");
}
};
writeln!(other_file, "# Them are hella fucked").unwrap();
if IS_DEV {
let _ = client.execute("CALL create_tables();", &[]);
}
writeln!(other_file, "Them are hella fucked").unwrap();
for line in reader_iter {
let line = line.unwrap();
if line.contains("#") {
writeln!(other_file, "{}", line).unwrap();
continue;
}
@ -104,15 +99,34 @@ fn import_file(filename: &str) {
let result: i32 = output.get(0);
if result == 1 {
dbg!(&line);
writeln!(other_file, "{}", line).unwrap();
}
}
}
fn add_artist(url: &str) {
dbg!(url);
todo!()
fn add_url(url: &str) {
let mut client = Client::connect("host=192.168.0.10 port=28945 user=hentai password=h99nqaNPhpfbuuhCDwQXLpZAnoVTjSQP7taoqmQhpzc2rPLVC4JUAKxAHfuuhuU9", NoTls).unwrap();
let output = client.query_one("SELECT insert_url($1);", &[&url]).unwrap();
let result: i32 = output.get(0);
if result == 1 {
panic!("HELP!!!");
}
}
fn add_artist_with_custom_name(url: &str, artist_name: &str) {
let mut client = Client::connect("host=192.168.0.10 port=28945 user=hentai password=h99nqaNPhpfbuuhCDwQXLpZAnoVTjSQP7taoqmQhpzc2rPLVC4JUAKxAHfuuhuU9", NoTls).unwrap();
let output = client
.query_one(
"SELECT insert_url_with_custom_artist($1, $2);",
&[&url, &artist_name],
)
.unwrap();
let result: i32 = output.get(0);
if result == 1 {
panic!("HELP!!!");
}
}
fn main() {
@ -126,7 +140,8 @@ fn main() {
"generate" => generate_file(value),
"convert" => convert_folders(value),
"import" => import_file(value),
"add" => add_artist(value),
"add_url" => add_url(value),
"add_custom_name" => add_artist_with_custom_name(value, args[3].as_str()),
_ => panic!("Invalid argument"),
}
}