Add Scryfall image URL field to database

This commit is contained in:
The Magician 2024-08-19 16:20:33 +01:00
parent 793fb28d38
commit b61929a178
5 changed files with 17 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
penny_dreadful_downloader/legality_data/ penny_dreadful_downloader/legality_data/
a_scanner_dorkly/.venv/ a_scanner_dorkly/.venv/
scantap/images/ scantap/images/
sevenkeys/sevenkeys
MTG-Card-Identifier_v5.pdf MTG-Card-Identifier_v5.pdf
info.txt info.txt

View File

@ -11,6 +11,7 @@ type CardPrinting struct {
IsFoil bool IsFoil bool
IsPromo bool IsPromo bool
CollectorNumber string CollectorNumber string
ImageUrl string
Language string Language string
} }
@ -22,8 +23,9 @@ func InsertCardPrinting(db *sql.DB, cardPrinting CardPrinting) error {
IsFoil, IsFoil,
IsPromo, IsPromo,
CollectorNumber, CollectorNumber,
ImageUrl,
Language) Language)
VALUES (?, ?, ?, ?, ?, ?, ?);` VALUES (?, ?, ?, ?, ?, ?, ?, ?);`
insert, err := db.Prepare(query) insert, err := db.Prepare(query)
defer insert.Close() defer insert.Close()
@ -31,7 +33,7 @@ func InsertCardPrinting(db *sql.DB, cardPrinting CardPrinting) error {
return err return err
} }
_, err = insert.Exec(cardPrinting.Id, cardPrinting.Name, cardPrinting.SetCode, cardPrinting.IsFoil, cardPrinting.IsPromo, cardPrinting.CollectorNumber, cardPrinting.Language) _, err = insert.Exec(cardPrinting.Id, cardPrinting.Name, cardPrinting.SetCode, cardPrinting.IsFoil, cardPrinting.IsPromo, cardPrinting.CollectorNumber, cardPrinting.ImageUrl, cardPrinting.Language)
if err != nil { if err != nil {
return err return err
} }

View File

@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS CardPrinting (
IsFoil BOOLEAN NOT NULL, IsFoil BOOLEAN NOT NULL,
IsPromo BOOLEAN NOT NULL, IsPromo BOOLEAN NOT NULL,
CollectorNumber VARCHAR(10) NOT NULL, CollectorNumber VARCHAR(10) NOT NULL,
ImageUrl VARCHAR(100) NOT NULL,
Language VARCHAR(3) NOT NULL Language VARCHAR(3) NOT NULL
); );

View File

@ -9,5 +9,6 @@ type Card struct {
NonFoil bool `json:"nonfoil"` NonFoil bool `json:"nonfoil"`
Promo bool `json:"promo"` Promo bool `json:"promo"`
CollectorNumber string `json:"collector_number"` CollectorNumber string `json:"collector_number"`
ImageUris map[string]string `json:"image_uris"`
Language string `json:"lang"` Language string `json:"lang"`
} }

View File

@ -124,6 +124,7 @@ func getCardPrintings(card scryfall.Card) []database.CardPrinting {
IsFoil: true, IsFoil: true,
IsPromo: card.Promo, IsPromo: card.Promo,
CollectorNumber: card.CollectorNumber, CollectorNumber: card.CollectorNumber,
ImageUrl: card.ImageUris["png"],
Language: card.Language, Language: card.Language,
}) })
} }