diff --git a/Hallo.txt b/Hallo.txt new file mode 100644 index 0000000..10edabe --- /dev/null +++ b/Hallo.txt @@ -0,0 +1,102 @@ +# Them are hella fucked +https://kemono.su/patreon/user/7631527 # 1pala +https://kemono.su/patreon/user/2553129 # 3000KRW +https://kemono.su/fantia/user/33396 # 89189 +https://kemono.su/patreon/user/9919437 # afrobull +https://kemono.su/patreon/user/64056488 # aimii # Gofile/Mega +https://kemono.su/fanbox/user/79889714 # aimii # Gofile/Mega +https://kemono.su/patreon/user/79103965 # airexelart +https://kemono.su/patreon/user/47823294 # aizalter +https://kemono.su/patreon/user/916405 # akomni # Mega/Bowlroll +https://kemono.su/fanbox/user/355065 # asanagi +https://kemono.su/patreon/user/68007805 # astolfofofofo +https://kemono.su/fanbox/user/246189 # atya +https://kemono.su/fantia/user/3959 # bee +https://kemono.su/fanbox/user/39123643 # belko +https://kemono.su/fanbox/user/9016 # bginga +https://kemono.su/fantia/user/2279 # blendy +https://kemono.su/patreon/user/23156942 # bulgings # Gofile/Mega +https://kemono.su/fantia/user/83679 # canan +https://kemono.su/fanbox/user/115051 # custom_udon +https://kemono.su/patreon/user/3161935 # derpixon # Twitter/rule34video/Newgrounds +https://kemono.su/patreon/user/881792 # diives +https://kemono.su/fanbox/user/848240 # dikko +https://kemono.su/fanbox/user/76971870 # f2k2 +https://kemono.su/fanbox/user/18542541 # gensui +https://kemono.su/patreon/user/42571183 # gonorego18 +https://kemono.su/patreon/user/2963401 # greatm8 # Gdrive/Mega/Dropbox/Catbox +https://kemono.su/patreon/user/16112298 # gweda +https://kemono.su/patreon/user/27143068 # h-tmimi_mimi +https://kemono.su/fanbox/user/6570768 # haku3490 +https://kemono.su/patreon/user/51087112 # hoay +https://kemono.su/fanbox/user/7662302 # hoay +https://kemono.su/fanbox/user/641955 # horosuke +https://kemono.su/fanbox/user/70050825 # houk1se1 +https://kemono.su/fanbox/user/24164271 # ie +https://kemono.su/fanbox/user/82713435 # initial_a +https://kemono.su/fantia/user/7 # jack_dempa +https://kemono.su/fantia/user/7281 # jaxmmd +https://kemono.su/fanbox/user/3039847 # jefflink0113 +https://kemono.su/patreon/user/17913091 # jtveemo +https://kemono.su/patreon/user/16092177 # jxh33 +https://kemono.su/patreon/user/19627910 # kamuo +https://kemono.su/fanbox/user/273185 # kase_daiki # Rule34 +https://kemono.su/patreon/user/75612846 # koi_s3 +https://kemono.su/fanbox/user/5037829 # kouseki +https://kemono.su/fanbox/user/35317214 # kow +https://kemono.su/fanbox/user/1472682 # lingonberry67 +https://kemono.su/fanbox/user/30057736 # lolibicciisland +https://kemono.su/fanbox/user/59147542 # lolikaku +https://kemono.su/fanbox/user/58854726 # lolinyan +https://kemono.su/patreon/user/15873007 # lvl3toaster +https://kemono.su/patreon/user/31211919 # mafavam +https://kemono.su/fanbox/user/17151277 # mamimi +https://kemono.su/patreon/user/12281898 # mana +https://kemono.su/fanbox/user/4107959 # mantis-x +https://kemono.su/patreon/user/3295915 # maplestar +https://kemono.su/fanbox/user/11851339 # meme432 +https://kemono.su/fanbox/user/60070044 # miyako-omty +https://kemono.su/patreon/user/7117825 # mofumerchant +https://kemono.su/patreon/user/46694450 # moloko_o0 +https://kemono.su/fanbox/user/3316400 # msmspc +https://kemono.su/patreon/user/35150295 # nagoonimation +https://kemono.su/fanbox/user/59470435 # najar +https://kemono.su/fantia/user/44506 # naomin +https://kemono.su/fanbox/user/68174048 # neet-23-neet3 +https://kemono.su/patreon/user/11039562 # neko_nsfw +https://kemono.su/fanbox/user/83425233 # nekoma +https://kemono.su/fanbox/user/104409 # nekoworks +https://kemono.su/fantia/user/26637 # ngon +https://kemono.su/fantia/user/8565 # norigoro # Rule34 (nori_gorou) +https://kemono.su/patreon/user/76363800 # pinksama +https://kemono.su/fanbox/user/17312525 # poper +https://kemono.su/fanbox/user/19417472 # poriuretandayo +https://kemono.su/patreon/user/12440319 # ratatatat74 +https://kemono.su/fanbox/user/25724486 # sakamata +https://kemono.su/patreon/user/21597627 # shikou +https://kemono.su/fanbox/user/17829534 # shinkiart +https://kemono.su/patreon/user/8693043 # shirakami +https://kemono.su/fanbox/user/49759620 # simao +https://kemono.su/fanbox/user/11229342 # sincostan # Rule34 (sincos) +https://kemono.su/fanbox/user/9459043 # siu +https://kemono.su/fanbox/user/49494721 # soso +https://kemono.su/fanbox/user/59115126 # suicakoubou +https://kemono.su/patreon/user/219523 # suoiresnu +https://kemono.su/patreon/user/84051096 # t1kosewad +https://kemono.su/fantia/user/13743 # taka84 +https://kemono.su/fantia/user/104882 # tararatarako +https://kemono.su/patreon/user/58918584 # tararatarako +https://kemono.su/patreon/user/11558931 # thenaysayer34 +https://kemono.su/fanbox/user/34834956 # thenaysayer34 +https://kemono.su/patreon/user/5564244 # theobrobine +https://kemono.su/patreon/user/755183 # thiccwithaq +https://kemono.su/fanbox/user/5694 # tn_0926 +https://kemono.su/fanbox/user/96824586 # tutuj +https://kemono.su/fanbox/user/12713181 # utatanelolicoco +https://kemono.su/patreon/user/6906148 # vgerotica +https://kemono.su/patreon/user/49965584 # vicineko +https://kemono.su/patreon/user/7093152 # waero +https://kemono.su/patreon/user/2605299 # waterring +https://kemono.su/gumroad/user/7902156048183 # yapi +https://kemono.su/patreon/user/8931030 # yapi +https://kemono.su/patreon/user/4747714 # yeero diff --git a/gallery-dl /archive-gofile.sqlite3 b/gallery-dl /archive-gofile.sqlite3 deleted file mode 100644 index 765615e..0000000 Binary files a/gallery-dl /archive-gofile.sqlite3 and /dev/null differ diff --git a/gallery-dl /log.txt b/gallery-dl /log.txt deleted file mode 100644 index de41886..0000000 --- a/gallery-dl /log.txt +++ /dev/null @@ -1,14 +0,0 @@ -[gallery-dl][debug] Starting DownloadJob for 'https://gofile.io/d/hN07YD' -[gofile][debug] Using GofileFolderExtractor for 'https://gofile.io/d/hN07YD' -[gofile][debug] Creating temporary account -[urllib3.connectionpool][debug] Starting new HTTPS connection (1): api.gofile.io:443 -[urllib3.connectionpool][debug] https://api.gofile.io:443 "POST /accounts HTTP/1.1" 200 178 -[gofile][debug] Fetching website token -[urllib3.connectionpool][debug] Starting new HTTPS connection (1): gofile.io:443 -[urllib3.connectionpool][debug] https://gofile.io:443 "GET /dist/js/alljs.js HTTP/1.1" 200 231673 -[urllib3.connectionpool][debug] https://api.gofile.io:443 "GET /contents/hN07YD?wt=4fd6sg89d7s6 HTTP/1.1" 200 6112 -[gofile][debug] Using download archive './gallery-dl/archive-gofile.sqlite3' -[urllib3.connectionpool][debug] Starting new HTTPS connection (1): cold7.gofile.io:443 -[urllib3.connectionpool][debug] https://cold7.gofile.io:443 "GET /download/web/f66fbcd6-aad8-4428-8201-ab034f3564a4/%5B4K%5DTW%20Taker%20POV2.mp4 HTTP/1.1" 200 1060624712 -[urllib3.connectionpool][debug] Starting new HTTPS connection (1): store4.gofile.io:443 -[urllib3.connectionpool][debug] https://store4.gofile.io:443 "GET /download/web/4a6dafff-5ad3-4fca-befa-0e19f6d3414e/%5BHD%5DTW%20Taker%20POV2.mp4 HTTP/1.1" 200 515225167 diff --git a/gallery-dl.sh b/gallery-dl.sh index 1d04296..9d76cb0 100755 --- a/gallery-dl.sh +++ b/gallery-dl.sh @@ -3,49 +3,57 @@ IGREEN="\033[0;92m" # Intense Green IYELLOW="\033[0;93m" # Intense Yellow NO_COLOR="\033[0m" # Text Reset - -# trap interrupt_function INT -# -# interrupt_function() { -# rm -f to_download_*.txt -# exit 1 -# } +IN_FILE="$1_generated.txt" +SUCCESS_FILE="$1_success.txt" +FAIL_FILE="$1_failed.txt" +BOOL_SUCCESS=0 if [[ $(hostname) == \s\a\t\a\n ]]; then [[ -d ./Artists ]] || mkdir ./Artists rm -rf ./gallery-dl/*.sqlite3 ./gallery-dl/log.txt ./Artists/* || exit 1 fi -input_file="$1.links" +download() { + # echo "url: $1" + # echo "path: $2" -if [[ ! -f $input_file ]]; then - echo -e "${IYELLOW}$input_file doesn't exist${NO_COLOR}" - exit 1 + 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" + + if [ $(echo $?) == 0 ]; then + echo "$1" >> "$SUCCESS_FILE" + break + fi + echo -e "${IYELLOW}download failed${NO_COLOR}" + + if [ $(ping -qc 3 v4.ip.hopeless-cloud.xyz > /dev/null 2>&1) != 0 ]; then + echo -e "${IYELLOW}no internet${NO_COLOR}" + exit 1 + elif [ $(ping -qc 3 v6.ip.hopeless-cloud.xyz > /dev/null 2>&1) != 0 ]; then + echo -e "${IYELLOW}no internet${NO_COLOR}" + exit 1 + fi + echo -e "${IGREEN}has internet${NO_COLOR}" + done + + echo "$1" >> "$FAIL_FILE" +} + +cargo run -- generate "$1" + +if [[ -f $FAIL_FILE ]]; then + [[ -f "${FAIL_FILE}.old" ]] && rm -f "${FAIL_FILE}.old" + mv "$FAIL_FILE" "${FAIL_FILE}.old" fi -cp $input_file to_download_$1.txt +while IFS= read -r line; do + url=$(echo "$line" | awk '{print $1}') + path=$(echo "$line" | awk '{print $3}') -for ((n=0;n<5;n++)); do - gallery-dl --config ./gallery-dl/config.json --input-file-delete to_download_$1.txt + download $url $path - if [ ! -s to_download_$1.txt ]; then - echo -e "${IGREEN}file empty${NO_COLOR}" - rm to_download_$1.txt - break - fi - echo -e "${IYELLOW}file not empty${NO_COLOR}" + exit +done < "$IN_FILE" - if [ $(ping -qc 3 hopeless-cloud.xyz > /dev/null 2>&1) ]; then - echo -e "${IYELLOW}no internet${NO_COLOR}" - exit 1 - fi - echo -e "${IGREEN}has internet${NO_COLOR}" -done - -# [[ $(hostname) != \s\a\t\a\n ]] && cp ./gallery-dl/archive-${$1,,}.sqlite3 /data/backup - -if [ -s to_download_$1.txt ]; then - exit 1 - # exit with some kind of error - # service should then send error and fitting message to ntfy -fi +[[ $(hostname) != \s\a\t\a\n ]] && cp ./gallery-dl/archive-${$1,,}.sqlite3 /data/backup diff --git a/gallery-dl /config.json b/gallery-dl/config.json similarity index 100% rename from gallery-dl /config.json rename to gallery-dl/config.json diff --git a/src/main.rs b/src/main.rs index 0c5ec14..b5fab12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"), } }