blob: aba66e35e64b2c4e158584814c44e45f336381e9 (
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
39
40
41
|
require 'json'
input = File.open(ARGV[0]) do |file|
JSON.load(file)
end
filtered = input.select do |cardJson|
cardJson["object"] == "card" &&
# It needs to have a downloadable image
cardJson.count("image_uris") &&
# Make sure we can support the card layout
["normal", "leveler", "saga"].include?(cardJson["layout"]) &&
# We only support modern and m15 frames
["2015", "2003"].include?(cardJson["frame"]) &&
# Digital cards look slightly different so ignore them
!cardJson["digital"] &&
# Only use english printings
cardJson["lang"] == "en" &&
# Currently not supporting silver bordered cards
cardJson["border_color"] != "silver" &&
# It is hard to read the name of a planeswalker
!cardJson["type_line"].include?("Planeswalker") &&
# This cuts out checklists and special tokens
cardJson["type_line"] != "Card" &&
# Amonkhet invocations are impossible
cardJson["set"] != "mp2" &&
# Unknown Event is not a real thing huh
cardJson["set"] != "da1"
end.map do |cardJson|
{
"id" => cardJson["id"],
"name" => cardJson["name"],
"imageUri" => cardJson["image_uris"]["png"],
"frame" => cardJson["frame"],
"artist" => cardJson["artist"]
}
end
File.open(ARGV[1], 'w') do |file|
JSON.dump(filtered, file)
end
|