44 lines
1003 B
Go
44 lines
1003 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"sevenkeys/database"
|
|
"sevenkeys/scryfall/methods"
|
|
)
|
|
|
|
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"
|
|
|
|
func check(err error) {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
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
|
|
}
|