commit
747ada4db3
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
i=1
|
||||
rep=$1 # how many submissions to generate
|
||||
maxsubs=52089873 #sets the default maximum bound of submission depth
|
||||
# It's recommended to set the max subs yourself, as there isn't a good
|
||||
# way to poll the website and check for that.
|
||||
|
||||
minsubs=0 #sets the default minimum bound of submission depth
|
||||
minsubarg=$2
|
||||
echo "===FA.SH: The Random FA Sub Generator==="
|
||||
|
||||
if [[ -z "$rep" ]]; then
|
||||
echo "///"
|
||||
echo "How many submissions to pull? (Default: 1)"
|
||||
echo "///"
|
||||
read rep
|
||||
else
|
||||
echo "debug: sub argument already provided."
|
||||
fi
|
||||
|
||||
echo "debug: amount of submissions requested: $rep"
|
||||
if [[ -z "$minsubarg" ]]; then
|
||||
echo "debug: no minimum sub id given"
|
||||
else
|
||||
echo "debug: minimum sub id: $minsubarg"
|
||||
fi
|
||||
|
||||
if [[ -z "$rep" ]]; then # bugfix for no arguments / null read.
|
||||
rep=1
|
||||
fi
|
||||
|
||||
echo "debug: max sub id: $maxsubs"
|
||||
|
||||
if [[ $minsubarg -gt $minsubs ]]; then
|
||||
minsubs=$minsubarg
|
||||
else
|
||||
minsubs=$minsubs
|
||||
fi
|
||||
|
||||
echo "debug: min sub id: $minsubs"
|
||||
|
||||
repeat=1
|
||||
|
||||
while [ $repeat -eq 1 ]
|
||||
do
|
||||
|
||||
while [ $i -le $rep ]
|
||||
do
|
||||
ranid=$(shuf -i $minsubs-$maxsubs -n1)
|
||||
if grep -w $ranid already-checked.txt; then #check if it's been seen before, re-roll without iterating the loop and check again.
|
||||
echo "😿 Already presented $ranid , re-rolling."
|
||||
else
|
||||
# curl the url if it's not in the list already
|
||||
# see if it errors out for not existing in the database.
|
||||
# Idea: store the curl result in standard output as is, and query it for different results.)
|
||||
result=$(curl -s --stderr - https://www.furaffinity.net/view/$ranid)
|
||||
|
||||
#echo "DEBUG: CURL TEST == $result"
|
||||
|
||||
if grep -q "not in our database" <<< "$result"; then
|
||||
echo "$ranid does not exist, logged and re-rolling. ($i of $rep)"
|
||||
echo "$ranid" >> already-checked.txt
|
||||
sleep 0.5
|
||||
elif grep -q "pending deletion" <<< "$result"; then
|
||||
echo "$ranid is pending deletion, logged and re-rolling. ($i of $rep)"
|
||||
echo "$ranid" >> already-checked.txt
|
||||
sleep 0.5
|
||||
# if it passes the second test, run the main script.
|
||||
else
|
||||
# Only upticks the counter on a hit.
|
||||
xdg-open https://furaffinity.net/view/$ranid 2> /dev/null
|
||||
echo "$ranid" >> already-checked.txt
|
||||
echo "🔫 New Submission! $ranid ($i of $rep)"
|
||||
counts=$(wc already-checked.txt | awk '{print $1}')
|
||||
|
||||
sleep 0.5 #to avoid site throttling.
|
||||
((i++))
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
echo "viewed $counts pages so far."
|
||||
read -r -p "😼 Do you want to go another $rep? (Y/n): " answer
|
||||
case $answer in
|
||||
[Yy]* ) echo "Going for another round!"; i=0;;
|
||||
[Nn]* ) ((repeat--)); echo "Ok, bye!";;
|
||||
* ) echo "Going for another round!"; i=0;;
|
||||
esac
|
||||
done
|
Loading…
Reference in New Issue