MagicTheGathering / mtg-sdk-python

Magic: The Gathering SDK - Python
MIT License
255 stars 45 forks source link

Query for language #14

Open Codingboy opened 6 years ago

Codingboy commented 6 years ago

Only english cards are filtered. Even Card.where(language='Portuguese (Brazil)').where(set="RIX").all() just brings up english text as states in a closed issue.

cards = Card.where(language="German").where(set="RIX").all()
for card in cards:
    print(card.name)
    print(card.mana_cost)
    print(card.supertypes)
    print(card.subtypes)
    print(card.types)
    print(card.rarity)
    print(card.text)
    print(card.power)
    print(card.toughness)
    print(card.loyalty)
    print(card.multiverse_id)
    print(card.image_url)
    print(card.set)
    print(card.set_name)
    print(card.rulings)

Example Output:

Angrath's Fury
{3}{B}{R}
None
None
['Sorcery']
Rare
Destroy target creature. Angrath's Fury deals 3 damage to target player. You may search your library and/or graveyard for a card named Angrath, Minotaur Pirate, reveal it, and put it into your hand. If you search your library this way, shuffle it.
None
None
None
441898
http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=441898&type=card
RIX
Rivals of Ixalan
[{'date': '2018-01-19', 'text': "You can't cast Angrath's Fury unless you choose both a target creature and a target player."}, {'date': '2018-01-19', 'text': "If either target becomes illegal after you cast Angrath's Fury but before it resolves, the other is still affected as appropriate and you'll search for Angrath. However, if both targets become illegal, the spell is countered and you won't search."}]
Reid-E commented 5 years ago

Language queries don't produce results in the given language. Non-english names and text are provided with all API calls, and nested under a foreignNames key (in API JSON, which gets converted to foreign_names in Python).

You can get to the data you're looking for with:

[printing['text'] for printing in card.foreign_names if printing['language'] == 'Portuguese (Brazil)'][0]

You could also use any other code that checks the 'language' key in the 'foreign_names' dict, then gets the relevant info from that dict using keys like 'name', 'text', 'flavor', 'image_url'.