Created
July 13, 2017 16:14
-
-
Save DR-DinoMight/e581474819fa7bf91b683cb6134f8a86 to your computer and use it in GitHub Desktop.
xbox api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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