Created
February 20, 2017 01:02
-
-
Save dmgig/483da07b9d110263e3cabb53a3b0b19c to your computer and use it in GitHub Desktop.
Randomly tweet items from an archive.org collection
This file contains hidden or 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 | |
# use the archive.org api and 't' tool to tweet random items from an archive.org collection | |
# you'll need two programs preinstalled: | |
# t: A command-line power tool for Twitter. https://github.com/sferik/t | |
# jq: A lightweight and flexible command-line JSON processor. https://stedolan.github.io/jq/ | |
COLLECTION='my_collection' | |
ROWS=1000 | |
ALTVURL='https://archive.org/advancedsearch.php?q=collection:'$COLLECTION'&fl\[\]=identifier,title&rows='$ROWS'&output=json' | |
JSON=$(curl -s $ALTVURL) | |
SHOWCNT=$( echo $JSON | jq .response.numFound ) | |
EPISODE=$( jot -r 1 0 $SHOWCNT ) | |
TITLE=$( echo $JSON | jq .response.docs[$EPISODE].title | sed -e 's/^"//' -e 's/"$//' ) | |
IDENT=$( echo $JSON | jq .response.docs[$EPISODE].identifier | sed -e 's/^"//' -e 's/"$//' ) | |
t update "$TITLE https://archive.org/details/$IDENT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment