Use placeholder for items with no art
This commit is contained in:
parent
ea71efb5e6
commit
3b22fe98f2
3 changed files with 29 additions and 8 deletions
BIN
public/missing-art.png
Normal file
BIN
public/missing-art.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 727 B |
|
@ -69,3 +69,11 @@ router.get("/favicon.png", defineEventHandler({
|
|||
return fs.promises.readFile("public/favicon.png")
|
||||
}
|
||||
}))
|
||||
|
||||
router.get("/missing-art.png", defineEventHandler({
|
||||
handler: async event => {
|
||||
handleCacheHeaders(event, {maxAge: 86400})
|
||||
defaultContentType(event, "image/png")
|
||||
return fs.promises.readFile("public/missing-art.png")
|
||||
}
|
||||
}))
|
||||
|
|
|
@ -54,14 +54,26 @@ async function loadCollection(inputUsername) {
|
|||
db.transaction(() => {
|
||||
for (const item of items.items) {
|
||||
if (!item.tralbum_type.match(/[at]/)) continue // p=product and s=subscription not supported
|
||||
try {
|
||||
preparedItem.run({
|
||||
account,
|
||||
...item,
|
||||
price: item.price || 0,
|
||||
item_art_url: item.item_art_url || "/missing-art.png",
|
||||
purchased: new Date(item.purchased).getTime(),
|
||||
added: new Date(item.added).getTime(),
|
||||
updated: new Date(item.updated).getTime()
|
||||
})
|
||||
} catch (cause) {
|
||||
throw new class extends Error {
|
||||
constructor() {
|
||||
super("Unsupported album/track data", {cause})
|
||||
this.name = "Collection Import Error"
|
||||
this.account = account
|
||||
this.item = item
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
const storedItemCount = db.prepare("SELECT count(*) AS count FROM item WHERE account = ?").pluck().get(account)
|
||||
|
@ -101,6 +113,7 @@ router.post("/api/load-collection", defineEventHandler(async event => {
|
|||
setCookie(event, "accounts", (getCookie(event, "accounts") || "").split("|").concat(account).join("|"))
|
||||
return pugSync.render(event, "collection-loaded.pug", result)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return pugSync.render(event, "collection-loaded.pug", {error})
|
||||
}
|
||||
}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue