Skip to content

Instantly share code, notes, and snippets.

@colindean
Created September 8, 2014 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colindean/1920b57246ddbe2f7260 to your computer and use it in GitHub Desktop.
Save colindean/1920b57246ddbe2f7260 to your computer and use it in GitHub Desktop.
List Industry Identifiers from Google Books API
#!/usr/bin/env ruby
# first arg must be a file in the format
#
# name identifier
#
# where name is just something for you and the identifier is an ISBN-10, ISBN-13,
# or something else that Google's API understands.
require 'json'
require 'open-uri'
GOOGLE_API_BASE='https://www.googleapis.com/books/v1/volumes?q=%s'
input = ARGV[0]
puts "Processing #{input}"
lines = File.open(input).readlines
lines.each do |line|
name, isbn13 = line.split
puts name
puts "isbn13: " + isbn13
data = JSON.parse(open(GOOGLE_API_BASE % isbn13).read)
data["items"].each do |item|
puts item["volumeInfo"]["industryIdentifiers"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment