Created
February 28, 2023 14:35
-
-
Save stompro/909380a82a08463087433b58ea15d75e to your computer and use it in GitHub Desktop.
Clear jacket art from Evergreen Memcache
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 | |
## Script clears entrys and tries to re-fetch the cover art. Runs slow. | |
## Enter your server address below. | |
NUMTRIES=2 | |
for KEY in $(memcdump --servers=localhost |fgrep 'ac.jacket') | |
do | |
if [[ $(memccat --servers=localhost $KEY) =~ "nocontent" ]] | |
then | |
echo | |
echo $KEY - ${BASH_REMATCH[0]} | |
(memcrm --servers=localhost $KEY) | |
if [[ $KEY =~ .*_([0-9]+)$ ]] | |
then | |
recid=${BASH_REMATCH[1]} | |
echo $recid record id | |
tries=0 | |
while [[ TRUE ]] | |
do | |
(( tries++ )) | |
res=$(curl -s -o /dev/null -w "%{http_code} %{size_download} %{content_type}\n" https://egcatalog.larl.org/opac/extras/ac/jacket/small/r/$recid) | |
if [[ $res =~ ^200 ]] | |
then | |
echo Good image found - $res | |
break | |
elif [[ $tries -gt $NUMTRIES ]] | |
then | |
echo Attempt done - clearing memcached - $res - $KEY | |
(memcrm --servers=localhost $KEY) | |
break | |
else | |
echo $res | |
echo no image found, clear memcached and try again - try $tries | |
(memcrm --servers=localhost $KEY) | |
#sleep 0.3 | |
fi | |
done | |
fi | |
else | |
echo Content found or no record | |
fi | |
done |
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 | |
## Script that just clears entries and doesn't try and re-request. Runs much faster. | |
NUMTRIES=2 | |
for KEY in $(memcdump --servers=localhost |fgrep 'ac.jacket') | |
do | |
if [[ $(memccat --servers=localhost $KEY) =~ "nocontent" ]] | |
then | |
echo | |
echo $KEY - ${BASH_REMATCH[0]} | |
(memcrm --servers=localhost $KEY) | |
else | |
echo Content found or no record | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment