Cleaned up the table printout.

master
parent effb8e83ce
commit 3f6be2b2be

@ -4,6 +4,9 @@
# rarities for all NFTs of a collection (must be fully minted). # rarities for all NFTs of a collection (must be fully minted).
########## Configurable Variables ########## ########## Configurable Variables ##########
# Where to save the json files #
# File location: (folder) #
directory="~" #
# #
# How long to wait for a response # # How long to wait for a response #
# Curl timeout: (seconds) # # Curl timeout: (seconds) #
@ -13,7 +16,7 @@
# Delay: (seconds) # # Delay: (seconds) #
delay=2 # delay=2 #
# #
# How many checks to do sequentially # # How many checks to do between sleeps #
# Count: (number) # # Count: (number) #
sequential=2 # sequential=2 #
# #
@ -32,6 +35,7 @@ max=0
cur=0 cur=0
moonrank="https://moonrank.app/collection/" moonrank="https://moonrank.app/collection/"
trap ctrl_c INT
function ctrl_c() { function ctrl_c() {
tput cnorm tput cnorm
echo "${rst}${red}CTRL+C Detected, exiting.${rst}" echo "${rst}${red}CTRL+C Detected, exiting.${rst}"
@ -74,22 +78,64 @@ function appendjson() {
} }
function pad() { function pad() {
seq -s " " $1 | tr -d "[:digit:]" [ $1 -ne 0 ] && seq -s " " $1 | tr -d "[:digit:]"
} }
function tableheader() { function isodd(){
datasize=8 local num=$1
[ ${#nftname} -gt $datasize ] && let datasize="${#nftname}-${datasize}" [ $num -eq 0 ] && return 0
echo -en " NFT ID " [ $num -lt 0 ] && let num="num*-1"
local a=0;local b=0
let a="num/2"
let b="(num-1)/2"
[ $a -eq $b ] && return 1
return 0
}
function tableheader() {
[ $didheader -eq 2 ] && return 1
didheader=0
local namelen=${#nftname}
isodd $namelen
local odd=$?
if [[ $namelen -gt 7 ]]; then
let prepost="namelen-7"
let prepost="prepost/2"
elif [[ $namelen -lt 7 ]]; then
let prepost="7-namelen"
let prepost="prepost/2"
else
prepost=0
fi
for i in `seq 2`; do
[ $didheader -eq 0 ] && echo -n " "
pad $prepost
[ $prepost -ne 0 ] && echo -n " "
echo -n "NFT ID"
[ $odd -eq 0 ] && let prepost="prepost+1"
pad $prepost
[ $prepost -eq 0 ] && echo -en "\t"
echo -en "\tNFT Rarity Rank"
[ $didheader -eq 0 ] && echo -en "\t\t"
[ $didheader -eq 1 ] && echo
let didheader="didheader+1"
done
tablecolumn=1
} }
# $1=column1/3 $2=column2/4 $3=column1/2or3/4 function tablerow() {
function tablebody() { if [[ $tablecolumn -eq 1 ]]; then
continue echo -en " ${nftname}\t ${rarity}"
tablecolumn=2
else
echo -e "\t\t ${nftname}\t ${rarity}"
tablecolumn=1
fi
} }
####### START
yn=n yn=n
while [[ $yn == n ]]; do while [[ $yn == n ]]; do
echo -en "\nPlease enter the moonrank collection ID: ${cyn}" echo -en "\nPlease enter the moonrank collection ID: ${cyn}"
@ -109,13 +155,16 @@ echo -e "\nFound the ${bld}${name}${rst} collection of ${bld}${count}${rst} NFTs
max=`echo ${count} | tr -d ,` max=`echo ${count} | tr -d ,`
[ $zeroindexed == "yes" ] && let max="max-1" || cur=1 [ $zeroindexed == "yes" ] && let max="max-1" || cur=1
echo -e "\n"
didheader=0 didheader=0
thisseq=0 thisseq=0
echo -e "NFT ID\tRarity" getrarity
tableheader
while [[ $cur -le $max ]]; do while [[ $cur -le $max ]]; do
getrarity getrarity
tablerow
appendjson "${nftname}" ${rarity} appendjson "${nftname}" ${rarity}
echo -e "${nftname}\t${rarity}"
let cur="cur+1" let cur="cur+1"
let thisseq="thisseq+1" let thisseq="thisseq+1"
[ $thisseq -eq $sequential ] && thisseq=0 && sleep $delay [ $thisseq -eq $sequential ] && thisseq=0 && sleep $delay
@ -123,8 +172,8 @@ done
json="${json}}" json="${json}}"
echo "$json" > ~/${collection}-rarity.json echo "$json" > ${directory}/${collection}-rarity.json
echo -e "\nThe .json file for the ${name} NFT collection has been saved to ~/${collection}-rarity.json\n" echo -e "\nThe .json file for the ${name} NFT collection has been saved to ${directory}/${collection}-rarity.json\n"

Loading…
Cancel
Save