- Added Danbooru support
- Added Moebooru (konachan and yande.re) support
This commit is contained in:
parent
5bf31504c7
commit
11ce6fa401
26
README.md
26
README.md
@ -16,18 +16,16 @@ scripts for downloading and tagging images from booru websites
|
||||
|
||||
`torsocks` if you're downloading through tor
|
||||
|
||||
```
|
||||
./gelbdl.sh [-t] [-s]
|
||||
Simply make a files.txt inside a folder and paste all your links, then run this script to download them all!
|
||||
-h shows this help message
|
||||
-t downloads using tor (requires torsocks)
|
||||
-s sets the delay after each request, defaults to 1
|
||||
```
|
||||
## Scripts:
|
||||
|
||||
```
|
||||
./gelbtag.sh [-t] [-s]
|
||||
Tags existing pictures inside a folder
|
||||
-h shows this help message
|
||||
-t downloads using tor (requires torsocks)
|
||||
-s sets the delay after each request, defaults to 1
|
||||
```
|
||||
`gelbdl.sh` downloads and tags files from every gelbooru link in files.txt
|
||||
|
||||
`gelbtag.sh` hashes and looks up every image in a folder on gelbooru
|
||||
|
||||
`dandl.sh` downloads and tags files from every danbooru link in files.txt
|
||||
|
||||
`dantag.sh` hashes and looks up every image in a folder on danbooru
|
||||
|
||||
`moedl.sh` downloads and tags files from moebooru imageboard (think konachan and yande.re) links in files.txt
|
||||
|
||||
`moetag.sh` hashes and looks up every image in a folder (provided you specify the booru)
|
69
dandl.sh
Executable file
69
dandl.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
USE_TOR=false
|
||||
DELAY=1
|
||||
|
||||
function usage {
|
||||
echo "./$(basename $0) [-t] [-s]"
|
||||
echo "Mass downloader for Danbooru"
|
||||
echo "Simply make a files.txt inside a folder and paste all your links, then run this script to download them all!"
|
||||
echo " -h shows this help message"
|
||||
echo " -t downloads using tor (requires torsocks)"
|
||||
echo " -s sets the delay after each request, defaults to 1"
|
||||
}
|
||||
|
||||
# list of arguments expected in the input
|
||||
optstring=":hts:"
|
||||
|
||||
while getopts ${optstring} arg; do
|
||||
case ${arg} in
|
||||
h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
t)
|
||||
USE_TOR=true
|
||||
echo -n "Using Tor with IP: "
|
||||
torsocks curl ip.me
|
||||
;;
|
||||
s)
|
||||
DELAY="${OPTARG}"
|
||||
;;
|
||||
:)
|
||||
echo "$0: Must supply an argument to -$OPTARG." >&2
|
||||
exit 1
|
||||
;;
|
||||
?)
|
||||
echo "Invalid option: -${OPTARG}."
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
while read f; do
|
||||
echo "$f"
|
||||
# MODIFY URL TO API CALL
|
||||
JSON_URL=`echo $f | sed "s/\?q.*//g"`
|
||||
# DOWNLOAD JSON
|
||||
if $USE_TOR; then
|
||||
JSON=`torsocks curl -s "$JSON_URL.json"`
|
||||
else
|
||||
JSON=`curl -s "$JSON_URL.json"`
|
||||
fi
|
||||
# STORE FILE URL AND TAGS INTO VARIABLES
|
||||
FILE_URL=`echo $JSON | jq -r '."file_url"'`
|
||||
FILE_TAGS=`echo $JSON | jq -r '."tag_string"' | sed 's/\ /,/g'`
|
||||
FILE_MD5=`echo $JSON | jq -r '.md5'`
|
||||
FILE_EXT=`echo $JSON | jq -r '.file_ext'`
|
||||
FILE="$FILE_MD5.$FILE_EXT"
|
||||
# DOWNLOAD FILE
|
||||
if $USE_TOR; then
|
||||
torsocks curl -O -J "$FILE_URL"
|
||||
else
|
||||
curl -O -J "$FILE_URL"
|
||||
fi
|
||||
# ADD TAGS TO NEW IMAGE
|
||||
setfattr -n user.xdg.tags -v "$FILE_TAGS" "$FILE"
|
||||
# DELAY BEFORE NEXT FETCH
|
||||
sleep $DELAY
|
||||
done < files.txt
|
60
dantag.sh
Normal file
60
dantag.sh
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
USE_TOR=false
|
||||
DELAY=1
|
||||
SEARCH_URL="https://danbooru.donmai.us/posts.json?tags=md5"
|
||||
|
||||
function usage {
|
||||
echo "./$(basename $0) [-t] [-s]"
|
||||
echo "Mass tagger for Danbooru"
|
||||
echo "Tags existing pictures inside a folder"
|
||||
echo " -h shows this help message"
|
||||
echo " -t downloads using tor (requires torsocks)"
|
||||
echo " -s sets the delay after each request, defaults to 1"
|
||||
}
|
||||
|
||||
# list of arguments expected in the input
|
||||
optstring=":hts:"
|
||||
|
||||
while getopts ${optstring} arg; do
|
||||
case ${arg} in
|
||||
h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
t)
|
||||
USE_TOR=true
|
||||
echo -n "Using Tor with IP: "
|
||||
torsocks curl ip.me
|
||||
;;
|
||||
s)
|
||||
DELAY="${OPTARG}"
|
||||
;;
|
||||
:)
|
||||
echo "$0: Must supply an argument to -$OPTARG." >&2
|
||||
exit 1
|
||||
;;
|
||||
?)
|
||||
echo "Invalid option: -${OPTARG}."
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for FILE in *; do
|
||||
echo "$FILE"
|
||||
# GET MD5 HASH
|
||||
FILE_MD5=`md5sum "$FILE" | awk '{print $1}'`
|
||||
# DOWNLOAD JSON
|
||||
if $USE_TOR; then
|
||||
JSON=`torsocks curl -s "$SEARCH_URL:$FILE_MD5"`
|
||||
else
|
||||
JSON=`curl -s "$SEARCH_URL:$FILE_MD5"`
|
||||
fi
|
||||
# STORE TAGS INTO VARIABLES
|
||||
FILE_TAGS=`echo $JSON | jq -r '.[] | ."tag_string"' | sed 's/\ /,/g'`
|
||||
# ADD TAGS TO IMAGE
|
||||
setfattr -n user.xdg.tags -v "$FILE_TAGS" "$FILE"
|
||||
# DELAY BEFORE NEXT FETCH
|
||||
sleep $DELAY
|
||||
done
|
@ -5,6 +5,7 @@ DELAY=1
|
||||
|
||||
function usage {
|
||||
echo "./$(basename $0) [-t] [-s]"
|
||||
echo "Mass downloader for Gelbooru"
|
||||
echo "Simply make a files.txt inside a folder and paste all your links, then run this script to download them all!"
|
||||
echo " -h shows this help message"
|
||||
echo " -t downloads using tor (requires torsocks)"
|
||||
|
@ -5,6 +5,7 @@ DELAY=1
|
||||
|
||||
function usage {
|
||||
echo "./$(basename $0) [-t] [-s]"
|
||||
echo "Mass tagger for Gelbooru"
|
||||
echo "Tags existing pictures inside a folder"
|
||||
echo " -h shows this help message"
|
||||
echo " -t downloads using tor (requires torsocks)"
|
||||
|
70
moedl.sh
Normal file
70
moedl.sh
Normal file
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
USE_TOR=false
|
||||
DELAY=1
|
||||
|
||||
function usage {
|
||||
echo "./$(basename $0) [-t] [-s]"
|
||||
echo "Mass downloader for moebooru imageboards (think konachan and yande.re)"
|
||||
echo "Simply make a files.txt inside a folder and paste all your links, then run this script to download them all!"
|
||||
echo " -h shows this help message"
|
||||
echo " -t downloads using tor (requires torsocks)"
|
||||
echo " -s sets the delay after each request, defaults to 1"
|
||||
}
|
||||
|
||||
# list of arguments expected in the input
|
||||
optstring=":hts:"
|
||||
|
||||
while getopts ${optstring} arg; do
|
||||
case ${arg} in
|
||||
h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
t)
|
||||
USE_TOR=true
|
||||
echo -n "Using Tor with IP: "
|
||||
torsocks curl ip.me
|
||||
;;
|
||||
s)
|
||||
DELAY="${OPTARG}"
|
||||
;;
|
||||
:)
|
||||
echo "$0: Must supply an argument to -$OPTARG." >&2
|
||||
exit 1
|
||||
;;
|
||||
?)
|
||||
echo "Invalid option: -${OPTARG}."
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
while read f; do
|
||||
echo "$f"
|
||||
# get ID from the URL
|
||||
URL=`echo $f | sed 's/\// /g' | awk '{print $2}'`
|
||||
IMAGE_ID=`echo $f | sed 's/\// /g' | awk '{print $5}'`
|
||||
# DOWNLOAD JSON
|
||||
if $USE_TOR; then
|
||||
JSON=`torsocks curl -s "https://$URL/post.json?tags=id:$IMAGE_ID"`
|
||||
else
|
||||
JSON=`curl -s "https://$URL/post.json?tags=id:$IMAGE_ID"`
|
||||
fi
|
||||
# STORE FILE URL AND TAGS INTO VARIABLES
|
||||
FILE_URL=`echo $JSON | jq -r '.[] | ."file_url"'`
|
||||
FILE_TAGS=`echo $JSON | jq -r '.[] | ."tags"' | sed 's/\ /,/g'`
|
||||
FILE=`echo $JSON | jq -r '.[] | ."file_url"' | sed 's/\// /g' | awk '{print $5}'`
|
||||
FILE_WITHSPACE=`echo $JSON | jq -r '.[] | ."file_url"' | sed 's/\// /g' | awk '{print $5}' | sed 's/\%20/ /g'`
|
||||
# DOWNLOAD FILE
|
||||
if $USE_TOR; then
|
||||
torsocks curl -O -J "$FILE_URL"
|
||||
else
|
||||
curl -O -J "$FILE_URL"
|
||||
fi
|
||||
# ADD TAGS TO NEW IMAGE
|
||||
setfattr -n user.xdg.tags -v "$FILE_TAGS" "$FILE"
|
||||
mv "$FILE" "$FILE_WITHSPACE"
|
||||
# DELAY BEFORE NEXT FETCH
|
||||
sleep $DELAY
|
||||
done < files.txt
|
79
moetag.sh
Executable file
79
moetag.sh
Executable file
@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
|
||||
USE_TOR=false
|
||||
DELAY=1
|
||||
REQ_URL=""
|
||||
|
||||
function usage {
|
||||
echo "./$(basename $0) [-t] [-s]"
|
||||
echo "Mass tagger for moebooru imageboards"
|
||||
echo "Tags existing pictures inside a folder"
|
||||
echo " -h shows this help message"
|
||||
echo " -t downloads using tor (requires torsocks)"
|
||||
echo " -s sets the delay after each request, defaults to 1"
|
||||
echo " -k uses konachan API for tagging"
|
||||
echo " -y uses yande.re API for tagging"
|
||||
echo " -c uses (CUSTOM.URL) API for tagging"
|
||||
}
|
||||
|
||||
# list of arguments expected in the input
|
||||
optstring=":hts:kyc:"
|
||||
|
||||
while getopts ${optstring} arg; do
|
||||
case ${arg} in
|
||||
h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
t)
|
||||
USE_TOR=true
|
||||
echo -n "Using Tor with IP: "
|
||||
torsocks curl ip.me
|
||||
;;
|
||||
k)
|
||||
REQ_URL="https://konachan.com/post.json?tags=md5:"
|
||||
echo "Using konachan API for tagging"
|
||||
;;
|
||||
y)
|
||||
REQ_URL="https://yande.re/post.json?tags=md5:"
|
||||
echo "Using yande.re API for tagging"
|
||||
;;
|
||||
c)
|
||||
REQ_URL="https://$OPTARG/post.json?tags=md5:"
|
||||
;;
|
||||
s)
|
||||
DELAY="${OPTARG}"
|
||||
;;
|
||||
:)
|
||||
echo "$0: Must supply an argument to -$OPTARG." >&2
|
||||
exit 1
|
||||
;;
|
||||
?)
|
||||
echo "Invalid option: -${OPTARG}."
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$REQ_URL" ]]; then
|
||||
echo "No imageboard selected. Exiting."
|
||||
exit
|
||||
fi
|
||||
|
||||
for FILE in *; do
|
||||
echo "$FILE"
|
||||
# GET MD5 HASH
|
||||
FILE_MD5=`md5sum "$FILE" | awk '{print $1}'`
|
||||
# DOWNLOAD JSON
|
||||
if $USE_TOR; then
|
||||
JSON=`torsocks curl -s "$REQ_URL$FILE_MD5"`
|
||||
else
|
||||
JSON=`curl -s "$REQ_URL$FILE_MD5"`
|
||||
fi
|
||||
# STORE TAGS INTO VARIABLES
|
||||
FILE_TAGS=`echo $JSON | jq -r '.[] | ."tags"' | sed 's/\ /,/g'`
|
||||
# ADD TAGS TO IMAGE
|
||||
setfattr -n user.xdg.tags -v "$FILE_TAGS" "$FILE"
|
||||
# DELAY BEFORE NEXT FETCH
|
||||
sleep $DELAY
|
||||
done
|
Loading…
Reference in New Issue
Block a user