TheMathemagicians/sevenkeys/main.go

44 lines
1003 B
Go
Raw Normal View History

2024-04-04 13:55:12 +00:00
package main
import (
2024-05-21 11:17:50 +00:00
"log"
2024-05-21 11:24:16 +00:00
"sevenkeys/database"
"sevenkeys/scryfall/methods"
2024-04-04 13:55:12 +00:00
)
2024-05-21 11:19:01 +00:00
const CACHE_DIR string = "cache"
const SET_ICON_CACHE_DIR string = CACHE_DIR + "/seticons/"
const SET_ICON_FILE_EXTENSION string = ".svg"
const ALL_CARDS_CACHE_FILENAME = CACHE_DIR + "/all-cards.json"
2024-05-21 11:17:50 +00:00
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
2024-04-04 13:55:12 +00:00
func main() {
2024-05-21 11:24:16 +00:00
log.Println("Connecting to database...")
db := database.GetDatabaseFromConfig("config.json")
log.Println("Connected.")
log.Println("Downloading set data from Scryfall...")
sets, err := methods.GetSets()
check(err)
log.Println("Downloaded set data.")
// Create cache dir
// Create icon cache dir
// Loop through sets, import set data into database and download icons
// TODO: Only download icon if we don't already have the file
// Check whether card data has been updated since last download
// If yes, redownload and recache the bulk data
// Unmarshal cached file into Golang struct
// Import cards into database
2024-04-04 13:55:12 +00:00
}