How to use the scrython.cards function in scrython

To help you get started, we’ve selected a few scrython examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NandaScott / Scrython / examples / handle_errors.py View on Github external
import scrython

# oops, we asked for an exact match to a card, but failed to put the name in quotes
# that's going to throw a Scryfall error
try:
    search = scrython.cards.Search(q="!Black Lotus")
except scrython.ScryfallError as e:
    print(str(e.error_details['status']) + ' ' + e.error_details['code'] + ': ' + e.error_details['details'])
github NandaScott / Scrython / examples / check_collection.py View on Github external
# You can replace fileName here with your .csv file path if you only have one file.
fileName = input("Please enter the name of the file you'd like to scan: ")
searchQuery = input("Enter your Scryfall query: ")

search = scrython.cards.Search(q=searchQuery, page=1)

total = search.total_cards()

totalNames = []

for i in range(len(search.data())):
    totalNames.append(search.data()[i]['name'])

if total > len(search.data()):
    time.sleep(0.05)
    search2 = scrython.cards.Search(q=searchQuery, page=2)
    for i in range(len(search2.data())):
        totalNames.append(search.data()[i]['name'])

with open(fileName, 'r') as f:
    reader = csv.reader(f, delimiter=",")
    print("\nYou own of at least 1 copy of the following:\n")
    for value in reader:
        if value[0] in totalNames:
            print(value[0])
github ndepaola / mtg-autoproxy / scripts / sc_scan.py View on Github external
maxval = np.max(im_recon)
    im_recon_sc = 255*((im_recon - minval)/(maxval - minval))

    # Write image to disk, casting to uint8
    imageio.imwrite("../art_raw/" + cardname + " (" + card["artist"] + ").jpg", im_recon_sc.astype(np.uint8))
    print("Successfully processed scan for {}.".format(cardname))


if __name__ == "__main__":
    cardname = input("Card name (exact): ")
    try:
        # If the card specifies which set to retrieve the scan from, do that
        try:
            pipe_idx = cardname.index("|")
            query = cardname[0:pipe_idx] + " set=" + cardname[pipe_idx + 1:]
            card = scrython.cards.Search(q=query).data()[0]
            print("Processing: " + cardname[0:pipe_idx] + ", set: " + cardname[pipe_idx + 1:])
            cardname = cardname[0:pipe_idx]
        except (ValueError, scrython.foundation.ScryfallError):
            card = scrython.cards.Named(fuzzy=cardname).scryfallJson
            print("Processing: " + cardname)

        # Handle case of transform card
        if card["layout"] == "transform":
            card_idx = [card["card_faces"][x]["name"] for x in range(0, 2)].index(cardname)
            card["image_uris"] = {}
            card["image_uris"]["art_crop"] = card["card_faces"][card_idx]["image_uris"]["art_crop"]
            card["name"] = card["card_faces"][card_idx]["name"]

        # If the card is on Scryfall with that exact name:
        if card["name"] == cardname:
            process_scan(card, cardname)
github NandaScott / Scrython / examples / check_collection.py View on Github external
This script assumes the following:
1. All of the names in your collection .csv are on the first column
2. All of those names are spelled correctly.
3. The .csv only contains cards that you have in your collection.

Also make sure you run this in the same directory as your .csv
"""
import csv
import scrython
import time

# You can replace fileName here with your .csv file path if you only have one file.
fileName = input("Please enter the name of the file you'd like to scan: ")
searchQuery = input("Enter your Scryfall query: ")

search = scrython.cards.Search(q=searchQuery, page=1)

total = search.total_cards()

totalNames = []

for i in range(len(search.data())):
    totalNames.append(search.data()[i]['name'])

if total > len(search.data()):
    time.sleep(0.05)
    search2 = scrython.cards.Search(q=searchQuery, page=2)
    for i in range(len(search2.data())):
        totalNames.append(search.data()[i]['name'])

with open(fileName, 'r') as f:
    reader = csv.reader(f, delimiter=",")
github NandaScott / Scrython / gen_docs.py View on Github external
format_examples(examples, f)
                format_functions(_class, functions, f)

        except Exception as e:
            print(_class.upper())
            print(repr(eval(_class).__doc__))
            print('Args: ', re.findall(r'(?<=Args:)(.*)(?=Returns:)', remove_extra_spaces))
            print('Returns: ', re.findall(r'(?<=Returns:)(.*)(?=Raises:)', remove_extra_spaces))
            print('Raises: ', re.findall(r'(?<=Raises:)(.*)(?=Examples:)', remove_extra_spaces))
            print('Examples: ', re.findall(r'(?<=Examples:)(.*)', remove_extra_spaces))
            print(e)
            print('~~~~~~~~~~~~~~~~~~~~~~~~~~')

if __name__ == '__main__':
    main(scrython.bulk_data)
    main(scrython.cards)
    main(scrython.catalog)
    main(scrython.rulings)
    main(scrython.sets)
    main(scrython.symbology)