Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion: automatic set symbol selector #7

Open
FlorisWarmenhoven opened this issue Dec 22, 2019 · 4 comments
Open

Feature suggestion: automatic set symbol selector #7

FlorisWarmenhoven opened this issue Dec 22, 2019 · 4 comments
Assignees

Comments

@FlorisWarmenhoven
Copy link

Would it perhaps be possible to add a feature that allows the scryfall api to automatically get the expansion name of the card, then find the appropriate symbol from: https://andrewgioia.github.io/Keyrune/icons.html and set it on the card?

I imagine a dictionary with the expansion name as key and the icon as value would help.

@ndepaola
Copy link
Collaborator

I've done this in the past so it's definitely possible, but I'm wondering if there would be a more maintainable & cleaner way to implement it than a hardcoded dictionary. At minimum, I can include that dictionary and some code that retrieves the set symbol from it based on the card's expansion depending on a flag. Will have a think about how I can implement it & I'll get back to you!

@hunz-dev
Copy link

I did a quick hack of this yesterday by adding an additional (but optional) identifier to the image tag (ex. Blasphemous Act (Daarken) [C18].jpg) and passing the set code to get_card_info.py. The Scryfall lookup will try to use the set code as an additional query param, but if it fails it'll do the normal fuzzy search.

https://github.com/hunz-dev/mtg-autoproxy/blob/set-symbols/scripts/get_card_info.py#L160-L165

From here I manually made a JSON file storing the set codes to the appropriate HTML entity by parsing out the HTML of the Keyrune cheatsheet. Realistically this step could be automated by using something like BeautifulSoup to parse the DOM of that cheatsheet.

https://github.com/hunz-dev/mtg-autoproxy/blob/set-symbols/scripts/set_symbols.json

Then all I had to do was get the mapped set symbol code, use the http.unescape to convert the HTML entity back to the correct encoding, store it in card.json and reference that string in proxy.jsx.

https://github.com/hunz-dev/mtg-autoproxy/blob/set-symbols/scripts/get_card_info.py#L131-L144

I'd be happy to work with you to build on this solution in a way that you think would make sense.

@ndepaola
Copy link
Collaborator

this issue is pretty old, but i'm currently working on adding this feature, as I learned recently that scryfall stores SVGs of all expansion symbols:

set_info = json.loads(request.urlopen(f"https://api.scryfall.com/sets/{set_code}").read())
request.urlretrieve(set_info["icon_svg_uri"], icon_path)

having to maintain a mapping between set codes and keyrune characters was the main thing holding me back from implementing this

@ndepaola ndepaola self-assigned this Apr 15, 2022
@ndepaola
Copy link
Collaborator

#38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants