Magic The Gathering Database Download

I need a complete card list in a excel format. To find a download able.xls doc with all the Magic cards, all I need is the basic info, names, colors, set. I am going to write a program to manage my library of Magic cards and I am looking for a database file or list of all of the cards that have been released. I know that the Gathering site is useful, but it limits the number of cards I can return in a search. I would happily accept a spreadsheet file, database file, or even a text file.

Latest version

Last released:

Collection of tools for easy handling of Magic: The Gathering card and set data on your computer from Scryfall and/or magicthegathering.io.

Project description

mtgtools is a collection of tools for easy handling of Magic: The Gathering data on your computer. The card datacan be easily downloaded from Scryfall API or magicthegathering.io API and it is saved in a ZODB - database,which is a native object database for Python. Everything is simply in Python, so no knowledge of SQL or the likes is needed to work with the database.

Features

  • Easily download, update and save Magic: The Gathering card and set data from Scryfall and/or magicthegathering.io toa local ZODB database (native object database for Python). Updating the database from scratch usually takes about 2minutes on my computer.

  • Easily iterate, filter, sort, group and handle card lists, sets and decks. The usual searching methods on the wholecard database of 40k cards take about 0.15s on my computer.

  • Save your own card lists and decks in a database in pure Python.

  • Read and write card lists or decks from files.

  • Generate random samples, random cards, booster packs etc. from any lists of cards.

  • Download card images of the type of your choice from Scryfall.

  • Create proxy image sheets from lists of cards using Scryfall.

Requirements

  • Python 3.5 - mtgtools is tested on Python 3.5 but will probably also work on later versions

  • ZODB - Can be installed with pip install zodb. More info in http://www.zodb.org/en/latest/.

  • requests - Can be installed with pip install requests. More info in https://pypi.org/project/requests/.

  • PIL - Not necessary, but needed for creating proxy image sheets. Can be installed with pip install pillow

The

Scryfall vs magicthegathering.io

At the moment there exists two different kind of APIs for mtg data, Scryfall and magicthegathering.io. They arestructured in different ways and both have pros and cons. For example Scryfall cards contain attribute card_faceswhere as the faces in mtgio are separate cards.

At the moment Scryfall has a more extensive database with more useful data like prices and purchase uris and also hostsgood quality card images, so in my opinion it is more useful of the two.

Installing

mtgtools can be simply installed with pip install mtgtools.

Usage guide

Persistent card, set and card list objects

Working with the database mostly revolves around working with the following persistent card and card list objects. Datapersistence in this case basically means that ZODB will automatically detect when these objects are accessed andmodified and saves the according changes automatically when transactions have been committed.

A good guide on ZODB can for example be found here: https://media.readthedocs.org/pdf/zodborg/latest/zodborg.pdf

PCard

PCard is a simple persistent dataclass representing Magic: the Gathering cards with their characteristicattributes. It is constructed simply with a json response dictionary from either magicthegathering.io or ScryfallAPI, so PCard has all the attributes matching the responses' keys and values.

Note, that the attributes power, toughness and loyalty are saved as strings since they might contain characterslike '*' or 'X'. For convenience, the card objects will also contain numerical versions of these attributes:power_num, toughness_num and loyalty_num. This makes searching much easier in many cases. After stripping awaythese non-digit characters, the remaining numbers will be in the numerical version of the attribute. If nothing is leftafter stripping, the numerical version will be 0.

Another difference between Scryfall and mtgio is that in mtgio API attribute names are in camelCase style. For thepurpose of consistency, the attributes in this software are transformed into snake_case which makes many of theattributes identical to the ones in Scryfall. For example, the attribute manaCost from mtgio has been changed tomana_cost which is the same as in Scryfall.

For more information on what attributes cards have, readhttps://scryfall.com/docs/api/cards for Scryfall card objects andhttps://docs.magicthegathering.io/#api_v1cards_list for magicthegathering.io card objects.

Download

PCardList

PCardList is a persistent card list or deck object that mostly acts just like a normal Python list for PCardobjects. These lists can be saved in the database just like any other persistent objects, and a PCardList is usedas a container for all the cards in the database.

PCardList has many useful methods for querying, filtering, sorting and grouping it's contents and creating new cardlists by combining other card lists in various ways. It also contains other handy methods like downloading the imagesof it's cards from Scryfall, creating proxy image sheets from it's cards, printing out it's contents in a readableway and creating deck-like strings or files of it's contents.

Except for the usual in-place list methods like extend, append and remove the PCardList is functional instyle, meaning that calling any of the other filtering or querying methods return new PCardList objects leaving theoriginal untouched.

PCardList can also be used as a deck by adding cards to it's sideboard. Having cards in the sideboardchanges some functionalities of the methods like deck_str in which now also the sideboard cards are added. Imagesare downloaded and proxies created for both the cards and the sideboard. However, Having cards in the 'sideboard'does not change the behavior of the crucial internal methods like len, getitem or setitem,so basically the cards in the sideboard are a kind of an extra.

PSet

Pset is a simple Persistent dataclass representing Magic: The Gathering sets with their characteristicattributes. It is constructed simply with a json response dictionary from either magicthegathering.io or ScryfallAPI, so PSet has all the attributes matching the responses' keys and values.

For more information on what attributes sets have, readhttps://scryfall.com/docs/api/sets for Scryfall set objects andhttps://docs.magicthegathering.io/#api_v1sets_list for magicthegathering.io set objects.

Additionally, PSet inherits from PCardList and it also contains all the cards of the set. Working with PSetby for example querying it's cards returns new PCardList objects is safe for the set leaving it untouched.

PSetList

PSetList is a persistent set list object that mostly acts just like a normal Python list for Pset objects.These lists can be saved in the database just like any other persistent objects. PSetList contains handy methods forquerying the sets it contains but in most cases it is only useful as a container database. It works very similarlyto PCardList except that they hold sets rather than cards.

Working with the database

Opening/creating databases

Sm bus controller driver windows xp for presario sr5410f. An existing database can be opened simply with

If no storage in the given path is found, a new empty database is automatically created.

Now that the connection to the database is open, the mtg_db will contain all the needed ZODB-related objectsstorage, connection, database and root (more about these in http://www.zodb.org/en/latest/reference/index.html).The cards and sets can now be found in the root of the database with

and

All the cards are saved as a PCardList and all the sets are saved as a PSetList. The root acts as aboot-strapping point and a top-level container for all the objects in the database.

The above method for accessing the database objects is a convenience, and you can also access the root mapping with

Updating

Building the database from scratch from Scryfall and mtgio is simply done with

The update downloads and saves all new card and set data and also updates any changes to the existing data. This isalso useful when updating for example the price and legality attributes of the Scryfall cards which might often change.

Building the database from scratch takes about few minutes to complete and it is mostly affected by the API requestlimits which are 10 request per second for Scryfall and 5000 requests per hour for magicthegathering.io. About 10requests per second are sent during updating which should comply with the Scryfall limits, and with magicthegathering.ioyou have to make sure not to run the update too many times per hour.

Working with card lists

Querying, filtering and sorting

PCardList has two handy methods for 'querying' its contents which return new PCardList objects:

where(invert=False, search_all_faces=False, **kwargs)

and

where_exactly(invert=False, search_all_faces=False, **kwargs)

where, the looser method, returns a new PCardList for which ANY of the given keyword arguments match 'loosely'with the attributes of the cards in this list. The arguments should be any card attribute names such as'power', 'toughness' and 'name'.

String attributes are case insensitive and it is enough that the argument is a substring of the attribute.

For list attributes the order does not matter and it is enough for one of the elements to match exactly.

For convenience, for numerical attributes it is enough that the argument is larger or equal to the attribute.

where_exactly, the stricter method, returns a new list of cards for which ALL the given keyword arguments matchcompletely with the attributes of the cards in this list.

For both of these methods, the results can be inverted to return all the cards NOT matching the arguments by settinginvert=True.

For Scryfall cards, which sometimes have the card_faces attribute, normally only the first face of the card(the normal face you would play) is considered when matching arguments. By setting search_all_faces=True the argumentscan now also match with any possible faces of the cards.

Let's start by getting all the Scryfall cards and sets of the database:

Some basic searching:

Turns out that there are 4 different Werebear cards in 4 different sets. Lets get the single card from Odyssey:

Note, that in this case using cards.where_(name='Werebear', set='ody') would not only return the Werebears but ALSOall the other cards from the set 'ody' since where returns the cards for which ANY of the given keyword argumentsmatch partly or completely.

Also note, that for where it is enough for the arguments match only partly. For example with string arguments likename, type_line, and oracle_text it is enough for the argument to be a substring of the cards' attribute inquestion:

Querying and other operations return new lists so we can also chain multiple queries together. One of he previousexamples with chaining:

If the above methods are not enough to find what you need, then there is also the filtered - method which worksquite like the usual filter - method for Python lists. filtered takes a function object and returns a new listcontaining all the cards of the list for which the given function returns True. Lambda functions are very convenientwith this method. For example, we can find the Odyssey Werebear by filtering our cards in the following way:

The card list can be sorted with the sorted - method, which works quite like the usual sort - method for Pythonlists. It takes a function object which should return some attributes of card objects by which this list is sorted.For example sorting by set codes:

Finally, the card objects in PCardList are stored in it's cards - attribute, in a PersistentList which can alsobe accessed directly.

Creating and combining lists

Magic The Gathering Online Database

PCardList acts like normal Python list so we can use normal indexing and slicing. You can also create empty lists:

Cards can be easily combined with addition. Addition works with lists and single card objects:

Another way of combining lists is to append cards to an existing list. Note, that this will actually change the listinstead of creating another one:

Cards can be removed from lists with subtraction or with the common list method remove. Subtraction works with listsand single card objects and it is basically the same as set subtraction:

Cards in the lists can be multiplied. This is for example handy for getting playsets of certain cards (note, thatyou have to multiply lists, not card objects):

Working with multifaced cards from Scryfall

As mentioned earlier, some cards in Scryfall have multiple faces. These are for example flip-cards like'Akki Lavarunner // Tok-Tok, Volcano Born' and transform-cards like 'Accursed Witch // Infectious Curse'. In somecases some attributes of these cards are only located inside the card_faces - dict attribute of the cards.In other cases the card itself might have non-null attribute and the same attribute with a different value in one ofit's card faces.

For example, the name attribute of the 'Akki Lavarunner' card object is 'Akki Lavarunner // Tok-Tok, Volcano Born'the name attribute of it's first card face is 'Akki Lavarunner' and the name attribute of it's second card face is'Tok-Tok, Volcano Born'. Similarly, the mana_cost - attribute of the card 'Accursed Witch // Infectious Curse' isnull, but the the mana_cost - attribute of it's first card face is '{3}{B}' Free movies download sites. which is what we would expect from thiscard. For that reason, by default the first card face is also matched if it is non-null.

If you want to search all faces of the card you must set search_all_faces=True when querying. It might take some trialand error at first to get what you exactly want.

Grouping cards

Cards in the lists can be grouped in various ways like color, type or converted mana cost. Groupingreturns dicts with group identities as keys and cards lists corresponding the group as values. When grouping by color orcolor identity, the keys will always have an alphabetical order like 'BR' and 'GUW' instead of the normal'WUBRG' - order.

The grouped_by_id - method is useful for fast retrieval of multiples of card objects from the list. Each differentcard contains a unique id attribute by which the ones in the list can be quickly retrieved by grouping them.

You can also create a special kind of grouping, or a kind of an 'index', of the cards in the list by using the methodcreate_id_index which returns a persistent BTree object. In practice you can use BTrees quite like normal Python dictand these can also be handily saved in the database as indexes.

Reading cards from files and strings

Cards can also be retrieved from the database (and from any other card lists) by reading them from list-like stringsand text files by using the PCardList - methods from_str and from_file which build new card lists of the cardsfound in the list. The accepted format of the strings and text files is similar to the standard Apperentice and MWSdeck lists:

Comment lines can be specified with '//', possible desired sets can be specified with either '(set_code)'or '[set_code]' and sideboard cards with the prefix 'SB:'. The set brackets can be anywhere but the desired numberof cards must come before the name of the card. If no matching set is found, a card from a random set is returned.

Note, that this method is useful with the whole database of cards rather than a small list.

You can also structure the deck strings in different ways. For example by color and without set codes:

from_file works exactly the same way except it reads the contents from a text file.

More examples

We can use the looser where to look for cards with for example certain power or toughness by using the fact thatfor numerical attributes it is enough for the argument to be equal or larger. Note, that for power, toughness andloyalty you can use the numerical versions power_num, touhness_num and loyalty_num.

Creatures in Odyssey with power > 5:

Download intel 810 graphic controller driver. White creatures Not including multicolors in Odyssey with power <= 2 AND toughness <= 2:

Auras in Odyssey with cmc <= 2:

Saving your own things in the database

A good guide about saving things in ZODB can be found here:http://www.zodb.org/en/latest/guide/writing-persistent-objects.html

Any objects mentioned above are already Persistent, so they can be conveniently saved. For example any PCardListobjects can easily be saved with

You can then easily later append more cards with

and access them later with

You can similarly save decks or other card lists for example by using a PersistentList which works almost like anormal Python list:

and then later on you can append more lists and access them the same way with single cards.

Another thing you might want to save in the database is for example an index of cards for faster retrieval. An 'index'in this case would be a fast persistent dict like BTree where the keys are some unique identifiers. For PCardList,there already exists the method create_id_index which returns a BTree in which the cards are indexed by their unique'id' values and each id maps to a single card object found in the original list. This is handy if called on the wholedatabase and saved:

Now single cards can be retrieved very speedily from the index by using their id's:

Similarly, the index can also be used to speedily check if some object exists in the database.

PCardList objects have a similar unique id so they are also simple to index if needed.

Working with sets and set lists

PSet and PSetList work very similarly to PCard and PCardList. The difference is that PSetis also a PCardList and contains a set of it's own characteristic Magic: The Gathering set attributes. PSetListobjects can be searched, filtered and sorted exactly like PCardList objects by using the methods where,where_exactly, filtered and sorted which similarly return new PSetList objects.

The sets are saved in the database as a PSetList.

Magic The Gathering Database Download

Some examples

Sets in Masques block:

All the sets containing a Negate:

Normal standard-legal sets without promos:

What else can you do with cards and sets?

The rest of the methods and functionalities are quite self explanatory and well documented, so they don't need furtherguidance. You can for example create random booster packs from card lists with random_pack, download images fromScryfall with download_images_from_scryfall, create sheets of proxy images of cards from Scryfall withcreate_proxies, turn your lists back to JSON with json and many more things.

Notes and possible problems

Possible bugs

The tools are somewhat decently tested for Scryfall data but some bugs and weird behavior are to be expected,especially with some special cards.

Currently, the data from magicthegathering.io is not tested but it should still work quite like Scryfall data. If youare using mtgio, be mindful of the differences between them.

Some things about the database

  • Be mindful when using multiple different storages and formatting/re-updating old ones when you have saved your ownlists. If something goes wrong and the old objects in the base of the database get replaced by new objects, the oldobjects which have references in your own saved lists don't function in the same way anymore. This is because the newlycreated object instances are not equal to the old ones in the database even though they have the same id's. Make sureyou back up the old databases before updates. At the moment there is no good support for recovery.

  • The first time you access any objects in the database after opening it takes a lot of time. This is because the datais not yet cached at that point. When the data is cached, the objects are actually retrieved from the cache withoutdatabase interactions, which is fast.

  • The database can't be used from multiple threads by default. Storage and DB instances can, but to use transactionsand object access you must use different connections and transaction managers for each thread.

  • Objects can be used as keys in a dictionary but it might be slow.

  • Some attributes of the objects like lists and dicts, (for example colors and card_faces) are not immutable.ZODB does not automatically recognize changes to these kinds of attributes. When changing values inside an object'smutable attributes, you must manually set the object's _p_changed attribute to True before calling commit. Oftensimpler way is to just use assignment or setattr instead of changing something inside the attribute. In this case,when the whole attribute is reassigned, ZODB will recognize this and changes are saved when committing.

Authors

Esko-Kalervo Salaka Command and conquer 1 download.

License

Gathering

Copyright © 2018 Esko-Kalervo Salaka.All rights reserved.

Zope Public License (ZPL) Version 2.1

A copyright notice accompanies this license document that identifies thecopyright holders.

This license has been certified as open source. It has also been designated asGPL compatible by the Free Software Foundation (FSF).

Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:

  1. Redistributions in source code must retain the accompanying copyrightnotice, this list of conditions, and the following disclaimer.

  2. Redistributions in binary form must reproduce the accompanying copyrightnotice, this list of conditions, and the following disclaimer in thedocumentation and/or other materials provided with the distribution.

  3. Names of the copyright holders must not be used to endorse or promoteproducts derived from this software without prior written permission from thecopyright holders.

  4. The right to distribute this software or to use it for any purpose does notgive you the right to use Servicemarks (sm) or Trademarks (tm) of thecopyrightholders. Use of them is covered by separate agreement with the copyrightholders.

  5. If any files are modified, you must cause the modified files to carryprominent notices stating that you changed the files and the date of anychange.

Disclaimer

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 'AS IS' AND ANY EXPRESSEDOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIESOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NOEVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Acknowledgments

This software uses ZODB, a native object database for Python, which is acopyright © by Zope Foundation and Contributors.

This software uses Scryfall's rest-like API which is a copyright © by Scryfall LLC.

This software uses rest-like API of magicthegathering.io which is a copyright © by Andrew Backes.

This software uses the Python Imaging Library (PIL) which is a copyright © 1997-2011 by Secret Labs AB andcopyright © 1995-2011 by Fredrik Lundh

All the graphical and literal information and data related to Magic: The Gathering which can be handled with thissoftware, such as card information and card images, is copyright © of Wizards of the Coast LLC, aHasbro inc. subsidiary.

This software is in no way endorsed or promoted by Scryfall, Zope Foundation, magicthegathering.io orWizards of the Coast.

This software is free and is created for the purpose of creating new Magic: The Gathering content and software, andjust for fun.

Release historyRelease notifications

Magic The Gathering Database Download

0.9.30

0.9.21

Magic The Gathering Checklist Download

0.9.1

0.9

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Magic The Gathering Set List

Filename, size & hash File typePython versionUpload date
mtgtools-0.9.30-py2.py3-none-any.whl (50.4 kB) Wheel py2.py3
mtgtools-0.9.30.tar.gz (68.3 kB) Source None
(chadmart)

Thanks for any info!
Edit: Preferably free software!
  • Last edited Mon Apr 19, 2010 2:23 pm (Total Number of Edits: 1)

Magic The Gathering Database Download Free

  • [+] Dice rolls