Last active
March 9, 2020 14:04
-
-
Save stompro/547976ad9cdd650989f1efe9d25b2cbc to your computer and use it in GitHub Desktop.
Clear no-content cover art entries from memcached
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 | |
#memcdump --servers=localhost |fgrep 'ac.jacket' | sort | xargs memccat --servers=localhost $1 | fgrep nocontent | wc | |
#$KEYS=$(memcdump --servers=localhost |fgrep 'ac.jacket') | |
for KEY in $(memcdump --servers=localhost |fgrep 'ac.jacket') | |
do | |
if [[ $(memccat --servers=localhost $KEY) =~ "nocontent" ]] | |
then | |
echo $KEY - ${BASH_REMATCH[0]} | |
(memcrm --servers=localhost $KEY) | |
else | |
echo nomatch | |
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 | |
### Look for cover art that is set to no-content, clear the cache for those entries, re-request cover art | |
### a certain number of time to try and work around Feb/March 2020 content cafe issues. | |
#Run this on your memcached server | |
# Edit script to point to your catalog | |
NUMTRIES=6 | |
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
Here is one way to test to see what Content Cafe is returning. | |
This does sequential requests for a given ISBN and shows the size and return code. | |
You need to put in your own username and password for content cafe. | |
while [ true ]; do curl -s -o /dev/null -w "%{http_code} %{size_download} %{content_type}\n" 'http://images.btol.com/ContentCafe/Jacket.aspx?UserID=xxxxxx&Password=yyyyyyy&NotFound=T&Size=L&Value=9781250179760'; date; done | |
our results look like the following, notice that the image size bounces between 2723 and 42435, which is the correct image and the no-content image. | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:30 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:30 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:30 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:30 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:30 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:31 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:31 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:31 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:31 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:31 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:31 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:32 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:32 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:32 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:32 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:32 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:32 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:33 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:33 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:33 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:33 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:33 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:33 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:34 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:34 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:34 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:34 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:34 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:34 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:35 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:35 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:35 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:35 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:35 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:36 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:36 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:36 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:36 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:36 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:37 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:37 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:37 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:37 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:37 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:38 CST 2020 | |
200 2723 image/jpeg | |
Tue Mar 3 14:00:38 CST 2020 | |
200 42435 image/jpeg | |
Tue Mar 3 14:00:38 CST 2020 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment