Skip to content

Instantly share code, notes, and snippets.

@urre
Created June 19, 2014 09:06
Show Gist options
  • Save urre/605f1ad403020d30443d to your computer and use it in GitHub Desktop.
Save urre/605f1ad403020d30443d to your computer and use it in GitHub Desktop.
Fetch image urls from unsplash.com
#!/bin/bash
# **************************************************************************************
#
# Fetch image urls from Unsplash.com
# by @urre
#
# **************************************************************************************
# JSON with 100 images from unsplash.com
JSON_URL="http://unsplash.com/api/read/json?num=100?callback=?"
# Download the file
curl -s -X GET $JSON_URL > feed.txt
# Remove all back slashes
sed 's/\\//g' feed.txt > feed_clean.txt
# Get all Tumblr images only
grep -o 'http://[^"]*' feed_clean.txt > results.txt
grep "\.tumblr\.com" results.txt > unsplash.txt
# Get 1280px sizes instead of standard 500px
sed -i -e 's/_500/_1280/g' unsplash.txt
# Remove smaller sizes
sed -i -e '/_500/d' unsplash.txt
sed -i -e '/_400/d' unsplash.txt
sed -i -e '/_250/d' unsplash.txt
sed -i -e '/_100/d' unsplash.txt
sed -i -e '/_75sq/d' unsplash.txt
# Cleanup
rm -rf unsplash.txt-e
rm -rf results.txt
rm -rf feed_clean.txt
rm -rf feed.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment