Skip to content

Instantly share code, notes, and snippets.

@mizzunet
Last active March 16, 2022 08:15
Show Gist options
  • Save mizzunet/139e695ce6b7081f43614f73f0cc94b0 to your computer and use it in GitHub Desktop.
Save mizzunet/139e695ce6b7081f43614f73f0cc94b0 to your computer and use it in GitHub Desktop.
Find fastest instance
#!/bin/bash
echo -n "Possible Values: invidious nitter bibliogram teddit wikiless scribe simplyTranslate lingva searx whoogle rimgo" \n
instances="$@"
listurl="https://raw.githubusercontent.com/tillcash/libredirect/master/src/instances/data.json"
tmpfile="/tmp/output"
# Download list
if test -f data.json; then
echo \n data.json already exists\n, using it \n
else
echo \n data.json not found! \n Downloading list of servers \n
curl -O "$listurl"
fi
for instance in $instances
do
echo > $tmpfile
echo "+++++++++++++"
echo $instance
echo "+++++++++++++"
for server in $(jq .$instance.normal[] data.json | sed 's/"//g' | sed 's/https:\/\///g')
do
time=$(curl -s -w '%{time_total}\n' -o /dev/null "$server")
echo "$time" $server >> $tmpfile
done
sed -i -r '/^\s*$/d' $tmpfile
sort -n $tmpfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment