blob: c70fcff67123272133dd0ab492f7117095967071 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
require 'json'
require 'nokogiri'
require 'open-uri'
require 'yaml'
config = YAML.load(open(ARGV[0]))
usernames = config["usernames"]
achieves = usernames.map do |username|
page = Nokogiri::HTML(open("https://steamcommunity.com/id/#{username}/games/?tab=all"))
script = page.css(".responsive_page_template_content script").text[18..-1]
data = JSON.parse(script[0..script.index(";\r\n\t\t")-1])
ids = data.map { |d| d["appid"] }
ids.map do |id|
achsp = Nokogiri::HTML(open("https://steamcommunity.com/id/#{username}/stats/#{id}/"))
achsp.css(".achieveTxt .achieveUnlockTime + h3").map { |d| d.text }
end
end.flatten
if File.exists?(config["achievements"])
already = File.read(config["achievements"]).split("\n")
all_achieves = achieves + already
else
all_achieves = achieves
end
all_achieves.sort!
all_achieves.uniq!
if config.key? "blacklist"
blacklist = File.read(config["blacklist"]).split("\n")
all_achieves.reject! { |l| blacklist.include? l }
end
File.open(config["achievements"], "w") do |f|
f << all_achieves.join("\n")
end
|