Mage: MTGA import fails with some promo cards (on symbols in card number)

Created on 10 Mar 2021  Â·  6Comments  Â·  Source: magefree/mage

As you can see:
image

I exported the list from moxfield (MTGA format).

bug

Most helpful comment

@ldeluigi All your cases contain non-numerical characters ;)

Bug somewhere in the search pattern:

I have written an MTGA parser for one of my projects, so here are some findings that you can benefit from:

Two things need to change:

  • The whole collector number group should be optional, i.e. wrapped in ()?. (Including the space before the collector number)
  • The collector number may contain arbitrary strings that may contain unicode symbols. It currently checks for numerical digits only, which is wrong for data from Scryfall.

First claim:
TappedOut MTGA exports may not contain the collector number. A deck for reference: https://tappedout.net/mtg-decks/yarok-throw-your-lands-in-the-air/
The MTGA export of that deck contains lines like this (shortened the list)

1 Root Maze (10E)
1 Sakura-Tribe Scout (SOK)
1 Shrieking Drake (VIS)
1 Tainted Pact (ODY)

Second claim:

For reference, this is my RE that parses the MTGA format and works for the given cases:
(?P<copies>\d+) (?P<name>.+) \((?P<set_code>\w+)\)( (?P<collector_number>.+))?
It uses the Python RE syntax with named groups to extract the information from the lines. It may not be useful for you directly, but could serve as a reference point

All 6 comments

Card name and set code are fine (xmage must use scryfall sets and codes):
https://scryfall.com/card/prna/246p/breeding-pool
shot_210310_192415

There are must be bug in mtga parser.

I removed my hypothesis. I don't understand the cause

Bug somewhere in the search pattern:

shot_210310_194432

@ldeluigi All your cases contain non-numerical characters ;)

Bug somewhere in the search pattern:

I have written an MTGA parser for one of my projects, so here are some findings that you can benefit from:

Two things need to change:

  • The whole collector number group should be optional, i.e. wrapped in ()?. (Including the space before the collector number)
  • The collector number may contain arbitrary strings that may contain unicode symbols. It currently checks for numerical digits only, which is wrong for data from Scryfall.

First claim:
TappedOut MTGA exports may not contain the collector number. A deck for reference: https://tappedout.net/mtg-decks/yarok-throw-your-lands-in-the-air/
The MTGA export of that deck contains lines like this (shortened the list)

1 Root Maze (10E)
1 Sakura-Tribe Scout (SOK)
1 Shrieking Drake (VIS)
1 Tainted Pact (ODY)

Second claim:

For reference, this is my RE that parses the MTGA format and works for the given cases:
(?P<copies>\d+) (?P<name>.+) \((?P<set_code>\w+)\)( (?P<collector_number>.+))?
It uses the Python RE syntax with named groups to extract the information from the lines. It may not be useful for you directly, but could serve as a reference point

Unable to retrieve information for "?P\w+))( (?P\d+"

Edit: I tested it, and it seems to work. So this is invalid.

Another point: Does \p{Alnum}+ match any of -_ or accented characters?

I used google a bit, but didn’t find a definite answer, but it points towards "no".

In other words, does the parser work with this deck list?

1 Abzan Kin-Guard (FRF) 120
1 _____ (UNH) 23
1 Séance (MM3) 22
1 Déjà Vu (POR) 53

This list contains a hyphen, underscores and accented characters.

I suggest to use \S+ instead of \p{Alnum}+, which should match those.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fenhl picture fenhl  Â·  7Comments

copperfield42 picture copperfield42  Â·  6Comments

copperfield42 picture copperfield42  Â·  10Comments

drmDev picture drmDev  Â·  13Comments

dosfod picture dosfod  Â·  4Comments