Last active
June 18, 2017 05:11
-
-
Save seigler/6ebb7033ca0c9c01e23aa64b255d8ce3 to your computer and use it in GitHub Desktop.
Hashtag photo collector
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 | |
urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } | |
json=$(mktemp) | |
hashtag="firstdashwallet" | |
regex="X[a-zA-Z0-9]{33}" | |
twurl "/1.1/search/tweets.json?q=%23$hashtag+filter:images&result_type=recent&count=100&tweet_mode=extended" > ${json} | |
while true; do | |
count=`cat ${json} | jq ".statuses | length"` | |
(( "$count" )) || break | |
echo "Found $count more tweets" | |
cat ${json} | jq -r ".statuses[] | (.full_text | match(\"$regex\").string) + \" \" + .entities.media[]?.media_url" >> addresses.txt | |
cat ${json} | jq -r ".statuses[] | if (.full_text | test(\"$regex\")) then .entities.media[]?.media_url else empty end" | wget -nc -q --show-progress -i - | |
nexturl=`cat ${json} | jq -r ".search_metadata.next_results"` | |
nexturl=`urldecode $nexturl` | |
twurl "/1.1/search/tweets.json$nexturl&tweet_mode=extended" > ${json} | |
done | |
rm ${json} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You will have to set up
twurl
and installjq
first, but afterwards, this script will download all the photos matching a certain hashtag and a certain regular expression. It saves the photos withwget
to the local folder.