Skip to content

Latest commit

 

History

History
127 lines (104 loc) · 5.74 KB

README.md

File metadata and controls

127 lines (104 loc) · 5.74 KB

changebrackets

This is a public repo for our project that uses angle brackets to monitor environmental change, including the scripts we use harvest image metadata, display a slideshow on a web page, download images, and compile movies. We've also included our sign designs.

SCRIPTS

These are a couple Ruby scripts we use to help automate the process of getting information about tag usage and making timelapse movies from the images. You don't need to know Ruby to use them, but you should be comfortable with running scripts from the command line. These instructions presume you're runnign some flavor of *nix, but all the underlying libraries are available for Windows so these scripts should work there too.

REQUIREMENTS

INSTALL

git clone https://github.com/nerdsfornature/changebrackets.git
cd changebrackets
bundle

fireslurp.rb

This Ruby script harvests image metadata from social media photos using your tags and stores them in local CSV files or a Google Spreadsheet. Run ruby fireslurp.rb --help to see all the options, but basic usage looks like this:

# Save info about Twitter photos for two tags to a Google Spreadsheet
bundle exec ruby fireslurp.rb \
  --twitter-key=xxx \
  --twitter-secret=yyy \
  --google-application-credentials=/path/to/your/key.json \
  --google-spreadsheet-id=1234abcd \
  morganfire01 morganfire02

# Save info about photos for two tags using config from a YAML file
bundle exec ruby fireslurp.rb -c fireslurp.yaml morganfire01 morganfire02

The last option using a config file is probably the easiest way to go. fireslurp.yaml provides an example for the config file. The Google Spreadsheet ID is just the unique part of your Google Spreadsheet URL, so if the URL when you're editing it looks like https://docs.google.com/spreadsheets/d/1HF1fEF4j69Ny6ng9TZYNLYnnRb4J6mPCqmckyOrsomI/edit, then the ID is 1HF1fEF4j69Ny6ng9TZYNLYnnRb4J6mPCqmckyOrsomI. Now here's the tricky part: in order to write to a Google Spreadsheet, you'll need to do these annoying things:

  1. Set up a project in the Google Developer Console and create a Service Account. Painful (but functional) instructions at https://developers.google.com/identity/protocols/OAuth2ServiceAccount. You don't need to delegate domain-wide authority, but you do need to hold on to that JSON key file you generate as a part of creating the service account
  2. In the Google Developer Console, enable the Drive API.
  3. Share your spreadsheet with the service account's email address and grant it editing permissions.
  4. Specify the path to that JSON key file you downloaded as an ENV variable named GOOGLE_APPLICATION_CREDENTIALS, in your configureation YAML, or using --google-application-credentials

Note that this script only retrieves info about recent photos, so it should be run at least daily, more often if your tags get a lot of use. We recommend cron or launchd.

moviemaker.rb

Downloads the image files referenced in a Google Spreadsheet made by fireslurp.rb, aligns them using TimeLapser, and stitches them into an animated GIF using ImageMagick. This is really just a little bit of logic on top of some basic shell commands, which should be pretty obvious in the script. Note that you can force it to download the files to a particular folder using the -f flag, and skip the relatively slow processes of downloading and alignment.

# Basic usage
bundle exec ruby moviemaker.rb -c fireslurp.yaml morganfire01

# Download all the image files to a folder named myfolder
bundle exec ruby moviemaker.rb -c fireslurp.yaml -f myfolder morganfire01

# Skip download, just do the alignment based on files in myfolder, and make the movie
bundle exec ruby moviemaker.rb -c fireslurp.yaml -f myfolder --skip-download morganfire01

CHANGEOMATIC

This is a little jQuery-based tool that sort of does what fireslurp does in the browser by pulling in photo data and creating a slideshow. It will only retrieve photos from Flickr and Instagram due to the limitations of Twitter's API in a strictly client-side context like this.

Using Google Spreadsheet

It can also read data from a Google Spreadsheet made by fireslurp, which is one way of getting around the Twitter thing, though doing so requires that you publish your Google Spreadsheet.

Your spreadsheet must meet the following requirements:

  1. If there's more than one sheet, the one containing the photo data must be named Data
  2. It must have columns just like those made by fireslurp.rb, which means it has the following columns as the first row, in this order:
  3. provider
  4. tag
  5. datetime
  6. username
  7. usable_tag
  8. image_url
  9. url
  10. image_url_s
  11. image_url_m
  12. license
  13. title

REQUIREMENTS

USAGE

See changeomatic.example.html