From 4bc851544831e37b6173d0ad05806fd841e216fb Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 4 Nov 2024 20:42:36 -0500 Subject: Re-attempt 10 times, some tweaks to OCR, pre-filter card pool --- cards_filter.rb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cards_filter.rb (limited to 'cards_filter.rb') diff --git a/cards_filter.rb b/cards_filter.rb new file mode 100644 index 0000000..aba66e3 --- /dev/null +++ b/cards_filter.rb @@ -0,0 +1,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 -- cgit 1.4.1