Last active
December 20, 2015 02:39
-
-
Save scarolan/6057617 to your computer and use it in GitHub Desktop.
Grabs image thumbnails from Flickr's API, then uses @heptal's most excellent "image" function to convert them into images in your terminal. If you want to search Flickr for multiple tags simply enclose them in quotes. ImageMagick and Python are required to use this.
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 | |
# Set a higher ulimit so we don't segfault | |
ulimit -s 32768 | |
search_string=$1 | |
search_string=${search_string// /%20} | |
# Courtesy of heptal's Console Colors | |
# https://gist.github.com/heptal/6052573 | |
function image() { | |
convert "$1" -resize "$2" txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/(\w,\w,\w),\w/\1/g;/mage/d'|awk '{print $1,$2}'|python -c "import sys;f=sys.stdin.read().split('\n');f=filter(None,f);print 'tput rev;'+''.join([''.join(map(str,('echo;' if x.split(' ')[0].split(',')[0] is '0' else '','tput setaf '+str(sum(p*q for p,q in zip([36,6,1],[int(min(int(c),254)/42.5) for c in x.split(' ')[1].split(',')]))+16)+';echo -n \" \";'))) for x in f])+'echo;tput sgr0'"|bash | |
} | |
# Rotate through the current set of images, then try to grab some more! | |
while true; do | |
for url in $(curl -s http://api.flickr.com/services/feeds/photos_public.gne?tags=$search_string | grep -o 'href="http://farm[^"]*"' | sed 's/href="//' | sed 's/"//' | sed 's/b.jpg/t.jpg/'); do | |
image $url 75 | |
sleep 30 | |
clear | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment