Skip to content

Instantly share code, notes, and snippets.

@andrewplus
Last active June 8, 2024 20:45
Show Gist options
  • Save andrewplus/6b5909d0c75e3b02725a2ed475403746 to your computer and use it in GitHub Desktop.
Save andrewplus/6b5909d0c75e3b02725a2ed475403746 to your computer and use it in GitHub Desktop.
Export collection from lorcana.gg to dreamborn.ink
# lorcana.gg => dreamborn.ink exporter
# Outputs a cardlist.csv file that can be imported into Dreamborn.
# HOW TO USE:
# 1. Log into your lorcana.gg account.
# 2. Download the following file: https://api.dotgg.gg/cgfw/getuserdata?game=lorcana
# 3. Rename the downloaded file to data.json and place it in a folder with this script.
# 4. Run the script with Python 3+.
import json
out = "Set Number,Card Number,Variant,Count"
with open("data.json") as f:
data = json.load(f)
collection = data["collection"]
for card in collection:
if int(card["total"]) > 0:
set_num = int(card["card"][:3])
card_num = int(card["card"][-3:])
if int(card["standard"]) > 0:
out = out + "\n" + f"{set_num},{card_num},normal,{card["standard"]}"
if int(card["foil"]) > 0:
out = out + "\n" + f"{set_num},{card_num},foil,{card["foil"]}"
with open("cardlist.csv", "w") as f:
f.write(out)
print("Finished. Check cardlist.csv.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment