Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DR-DinoMight/e581474819fa7bf91b683cb6134f8a86 to your computer and use it in GitHub Desktop.
Save DR-DinoMight/e581474819fa7bf91b683cb6134f8a86 to your computer and use it in GitHub Desktop.
xbox api
require "xbox-api"
require 'time'
require "byebug"
client = XboxApi::Client.new("xxx")
puts 'Xbox gamer tag?'
name = gets
user = client.gamer(name.chomp)
items = user.xboxonegames[:titles]
items360 = user.xbox360games[:titles]
games = []
items.each do |game|
next unless game[:titleType] == "DGame"
time = Time.parse(game[:lastUnlock]) if game[:lastUnlock] != nil
games << game[:name] + ", #{time}"
end
puts ''
puts 'Xbox One Game, Last Played'
games.sort.each do |game|
puts game
end
games = []
items360.each do |game|
next unless game[:titleType] == 1
time = Time.parse(game[:lastPlayed]) if game[:lastPlayed] != nil
games << game[:name] + ", #{time}"
end
puts ''
puts 'Xbox 360 Game, Last Played'
games.sort.each do |game|
puts game
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment