Modify Makefile to use unified importer
This commit is contained in:
parent
787794ac97
commit
fd4c2048e1
|
@ -1,9 +1,7 @@
|
||||||
createdb:
|
createdb:
|
||||||
mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/createdb.sql
|
mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/createdb.sql
|
||||||
importsets: createdb
|
import: createdb
|
||||||
go run cmd/importsets/main.go
|
go run main.go
|
||||||
importcards: importsets
|
|
||||||
go run cmd/importcards/main.go
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/removedb.sql
|
mysql --user=root --password=$(shell pass show sevenkeys/mysql) <sql/removedb.sql
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"sevenkeys/database"
|
|
||||||
"sevenkeys/database/operations"
|
|
||||||
"sevenkeys/scryfall/methods"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
log.Println("Downloading set data from Scryfall...")
|
|
||||||
sets, err := methods.GetSets()
|
|
||||||
check(err)
|
|
||||||
log.Println("Downloaded set data.")
|
|
||||||
|
|
||||||
log.Println("Connecting to database...")
|
|
||||||
db := database.GetDatabaseFromConfig("config.json")
|
|
||||||
log.Println("Connected.")
|
|
||||||
|
|
||||||
for _, set := range sets {
|
|
||||||
// We're only interested in paper cards, so skip importing
|
|
||||||
// any sets that were only released in a video game
|
|
||||||
if set.Digital {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("Importing set: " + set.Name)
|
|
||||||
err = operations.InsertOrUpdateSet(db, set)
|
|
||||||
check(err)
|
|
||||||
|
|
||||||
response, err := http.Get(set.IconSvgUri)
|
|
||||||
log.Println("Downloading logo for set: " + set.Name)
|
|
||||||
defer response.Body.Close()
|
|
||||||
check(err)
|
|
||||||
|
|
||||||
iconFilename := ICON_CACHE_DIR + set.Code + FILE_EXTENSION_SVG
|
|
||||||
iconFile, err := os.Create(iconFilename)
|
|
||||||
check(err)
|
|
||||||
|
|
||||||
io.Copy(iconFile, response.Body)
|
|
||||||
log.Println("Finished importing set: " + set.Name)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue