#!/usr/bin/env ruby
# Little tool to look for your works in PAX: http://www.redbubble.com/mosaic
#
# To make it work you'll need:
#
# 1) A working copy of ruby .
# 2) A copy of the image_data.js file from PAX.
# 3) A file called works.txt, generated using my getrbart utility:
#
#
# With those files, and this script, in the same directory, just run
# this script and, if you've got works in PAX, a list of their URLs
# will be the resulting output.
#
# By Dave Pearson
# Need json parser.
require 'json'
# Get a list of the IDs of all works in the PAX
def pax_works
work_ids = []
JSON.parse( IO.read( "image_data.js" ).gsub!( /^var imageData = /, "" ) ).each do |line|
line.each do |work|
work_ids << work[ 1 ].match( /\/(\d+)$/ )[ 1 ]
end
end
work_ids
end
# Get a list of the IDs of all my works on RedBubble
def my_works
work_ids = []
IO.readlines( "works.txt" ).each do |work|
work_ids << work.match( /^(\d+)/ )[ 1 ]
end
work_ids
end
# Show all works in both lists.
( pax_works & my_works ).each {|id| puts "http://www.redbubble.com/works/show/#{id}" }