Created
March 28, 2024 13:52
-
-
Save dbiesecke/459a937dc29b5cc47da03220a9cbb768 to your computer and use it in GitHub Desktop.
Check NZB Indexer API keys for Caps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function curlwithcode() { | |
code=0 | |
# Run curl in a separate command, capturing output of -w "%{http_code}" into statuscode | |
# and sending the content to a file with -o >(cat >/tmp/curl_body) | |
statuscode=$(curl -w "%{http_code}" \ | |
-o >(cat >/tmp/curl_body) \ | |
"$@" | |
) || code="$?" | |
echo "$statuscode $@" | |
return $statuscode | |
# body="$(cat /tmp/curl_body)" | |
# echo "statuscode : $statuscode" | |
# echo "exitcode : $code" | |
# echo "body : $body" | |
} | |
function check() { | |
URL=$1 | |
API=$2 | |
if [ -z "$API" ];then | |
echo '<url-base> <apikey>\n api.dognzb.cr 070dcbbfd04bd9e844c21d6e6ae435ea\n' | |
return 127 | |
fi | |
NURL="https://$URL/api?t=caps&id=$2&o=json" | |
#CHECK=$(curlwithcode "$NURL") | |
#if [ "$CHECK" = "200" ];then | |
# echo $CHECK | |
#else | |
# echo "failed - $CHECK\n" | |
#fi | |
LIMIT=$(curl -sSL "$NURL") | |
# | jq -r '.limits | ."@attributes".max' | |
#echo "$NURL" | |
echo "$URL $API " $(echo $LIMIT | jq -r '.limits | ."@attributes".max') | |
} | |
check "$@" | |
#check https://api.dognzb.cr 070dcbbfd04bd9e844c21d6e6ae435ea | |
#check curl 'https://api.dognzb.cr/api?t=caps&id=070dcbbfd04bd9e844c21d6e6ae435ea&o=json' | jq '.limits | ."@attributes".max' | more | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment