fa.sh - First pass on latest Submission ID Fetch.

main
Sleeping Crows 2023-11-27 12:19:57 -05:00
parent 4970cfd415
commit 243ca1d059
1 changed files with 16 additions and 3 deletions

View File

@ -1,8 +1,7 @@
#!/bin/bash
i=1
rep=$1 # how many submissions to generate
#To Do: use Curl to scrape furaffinity.net's main page and find a way to parse down to the first submission found.
maxsubs=52089873 #sets the default maximum bound of submission depth
maxsubs=52089873 #sets the default maximum bound of submission depth, should be left here if the max bound can't be updated for whatever reason.
# It's recommended to set the max subs yourself, as there isn't a good
# way to poll the website and check for that.
@ -64,6 +63,21 @@ fi
done
# Note: curl Doesn't seem to care if the cookies file is missing, probably don't need to add case statements. yay?
# Pull the main page of FA to get the latest Submission ID.
echo "debug: Pulling furaffinity.net index page for latest Sub ID."
mainpagefetch=$(curl -b "./cookies.txt" -s --stderr - https://www.furaffinity.net/)
# find the first figure id field and cut it down before changing maxsubs.
maxsubidparse=$(grep -m1 -Po 'figure id="\K[^"]*' <<< "$mainpagefetch" | cut -c 5-)
echo "debug: $maxsubidparse"
if [[ -n "$maxsubidparse" ]]; then
echo "debug: Latest Known Sub ID Was $maxsubidparse"
maxsubs=$maxsubidparse
else
echo "debug: couldn't get latest known Sub ID, falling back to hardcoded Sub ID."
fi
echo "debug: amount of submissions requested: $rep"
if [[ -z "$minsubarg" ]]; then
echo "debug: no minimum sub id given"
@ -100,7 +114,6 @@ do
# curl the url if it's not in the list already
# see if it errors out for not existing in the database.
result=$(curl -b "./cookies.txt" -s --stderr - https://www.furaffinity.net/view/$ranid)
header=
title=$(grep -m 1 "title" <<< "$result" | cut -c 12- | rev | cut -c 35- | rev)
if grep -q "not in our database" <<< "$result"; then
echo "($i of $rep) $ranid does not exist, logged and re-rolling."