11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/psn_trophies.rb', line 11
def trophies(profile_id)
check_profile_id(profile_id)
body = get_body("http://us.playstation.com/playstation/psn/profile/#{profile_id}/get_ordered_trophies_data",
"http://us.playstation.com/publictrophy/index.htm?onlinename=#{profile_id}/trophies")
games = []
doc = Nokogiri::HTML.fragment(body)
doc.css('.slotcontent').each do |container|
logo = container.at_css('.titlelogo img')["src"]
title = container.at_css('.gameTitleSortField').content
progress = container.at_css('.gameProgressSortField').content
trophies = container.at_css('.gameTrophyCountSortField').content.strip
games << PlayedGame.new(:image_url => logo, :title => title, :progress => progress, :trophy_count => trophies)
end
games
end
|