Skip to content

Instantly share code, notes, and snippets.

@sikachu
Last active July 9, 2017 18:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sikachu/bd57194442b01c9b143d to your computer and use it in GitHub Desktop.
Save sikachu/bd57194442b01c9b143d to your computer and use it in GitHub Desktop.
Pretty print PlayStation Store listing
require "open-uri"
require "json"
API_URL = "https://store.playstation.com/chihiro-api/viewfinder/US/en/19/STORE-MSF77008-SUMMERSALEPSVGG?size=100&gkb=1&geoCountry=US"
STORE_URL = "https://store.playstation.com/#!/en-us/cid=%s"
data = JSON.parse(open(API_URL).read)
games = []
data["links"].each do |game|
name = game["name"]
id = game["id"]
name_with_link = "[#{name}](#{STORE_URL % id})"
normal_price = game["default_sku"]["display_price"]
discounted_price = game["default_sku"]["rewards"].last["display_price"]
plus_discounted_price = game["default_sku"]["rewards"].last["bonus_display_price"]
games << [nil, name_with_link, normal_price, discounted_price, plus_discounted_price, nil].
join("|")
end
puts "|Title|Normal Price|Discounted Price|PS+ Price|"
puts "|-----|-----------:|---------------:|--------:|"
games.sort_by(&:downcase).each { |game| puts game }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment