`lein fetch`: Downloading image fails for a lot of cards
I've set up a local instance yesterday (which worked very well and was precisely documented!), but lein fetch could not download all the card images from NRDB. Suspecting network issues at first, I've retried both yesterday and today, but the card count stays at 942:
Have art for 942/1860 cards. Downloading 918 missing images...
Downloading: The Foundry: Refining the Process ( https://netrunnerdb.com/card_image//06021.png )
Downloading: Enhanced Login Protocol ( https://netrunnerdb.com/card_image//06022.png )
Downloading: Heinlein Grid ( https://netrunnerdb.com/card_image//06023.png )
No image for card 06021 The Foundry: Refining the Process
No image for card 06022 Enhanced Login Protocol
No image for card 06023 Heinlein Grid
[...]
Indeed, these images can not be found. It seems like NRDB uses JPEGs for the website and https://github.com/NetrunnerDB/netrunnerdb/pull/432 sounds like this is the newer approach. The following change results in all images being downloaded successfully:
diff --git a/src/clj/tasks/nrdb.clj b/src/clj/tasks/nrdb.clj
index 28b8849c0..f57dcdb34 100644
--- a/src/clj/tasks/nrdb.clj
+++ b/src/clj/tasks/nrdb.clj
@@ -10,7 +10,7 @@
(def ^:const base-url "https://raw.githubusercontent.com/NoahTheDuke/netrunner-data/master/edn/raw_data.edn")
;; XXX - NRDB has two slashes currently in the card image download url
-(def ^:const nrdb-image-url "https://netrunnerdb.com/card_image//")
+(def ^:const nrdb-image-url "https://netrunnerdb.com/card_image//large/")
(defn download-edn-data
[localpath]
@@ -35,12 +35,12 @@
(defn- card-image-file
"Returns the path to a card's image as a File"
[code]
- (io/file "resources" "public" "img" "cards" (str code ".png")))
+ (io/file "resources" "public" "img" "cards" (str code ".jpg")))
(defn- download-card-image
"Download a single card image from NRDB"
[{:keys [code title]}]
- (let [url (str nrdb-image-url code ".png")]
+ (let [url (str nrdb-image-url code ".jpg")]
(println "Downloading: " title "\t\t(" url ")")
(http/get url {:as :byte-array :timeout 120000}
(fn [{:keys [status body error]}]
Is this the way to go? If yes, I can make the additional changes to use JPEGs in the UI as well and create a PR.
@NoahTheDuke and I were debating this problem when I made the original changes. I believe the preferred solution was to update NRDB to have the correct images.
@jwarwick Thank you for your response! Currently the NRDB website is using JPEGs and both the above mentioned PR and the current API responses refer to the JPEG version. Is there any work in progress to get the PNGs we expect on NRDB? If not, why not use the JPEGs instead?
$ curl -s https://netrunnerdb.com/api/2.0/public/card/26120 | jq
{
"imageUrlTemplate": "https://netrunnerdb.com/card_image/large/{code}.jpg",
"data": [
[...]
On further investigation to get this working for me locally, I've discovered two more points I'd like to know your thoughts about:
- Card images for the flip sides of Earth Station (26120) and Hoshiko Shiro (26066) are not downloaded correctly. They are expected at
img/cards/{code}flip.png, but as far as I can see they have to be placed there manually. - The EDN contains an
image_url, that isn't used anymore. We could update this to keep the knowledge about the card image URLs outside of this repository.
I think you are heading down the same path that we were. Are you in the stimslack jinteki_net channel? I'd like to tie this to the discussion about getting higher-res card images as well.
Just a quick note as I had to run lein fetch again: This problem still affects the current master branch, only 940/1890 card images can be downloaded at the moment.
We did eventually fix this, so I'm going to close this as completed. If we break it again later, please create a new issue :)