EskoSalaka/mtgtools

DB update procedures don't seems to work

wimglasseesjibe opened this issue · 4 comments

Hi,

I tried using your toolkit but neither scryfall nor mtgio update seems to work at the moment

Any ideas?

Update:

reducing the number of workers to 1 helps.

mtgio updates completely
scryfall however throws an error at 'processing response 696 / 830'

end of the stacktrace:

site-packages\mtgtools\util\api_requests.py", line 37, in process_card_page_response
card_page_uri, headers)[data_identifier]
KeyError: 'data'

found it:
ody and mir claim to be 352 and 351 cards large. But when paging them they apparently contain exactly 350 cards. So you ask for an extra page that doesn't exist.

Correct fix would be to check the result for each page. A page indicates if it is the last one, and also shows the correct number of cards in the set.

Quick fix: check it the response is an error object, if so, just ignore it

def process_card_page_response(card_page_uri, data_identifier, headers=None):
response_json = get_response_json(card_page_uri, headers)

if response_json:
    if response_json.get('object') == 'error':
        return []
    else:
        return [
            PCard(card_json) for card_json in get_response_json(
                card_page_uri, headers)[data_identifier]
        ]
else:
    return []

Hi and thank you for the report! This is a known issue in which i think i accepted a pull request for a fix. It's basically like you reported, Scryfall card numbers (for some reason, not sure if its meant to be like that) dont match, so more robust handling is needed.

As for mtgio, i'm not sure. Probably something with the api has changed, but in any case scryfall is a better choice.

However, now that i think about it, i still havent published the fixes to pypi... Ive been quite busy lately, but ill return to check things in the weekend! You could clone this repo instead of using the PYPI version for now.

The fixes along with a new update method that uses the bulk data from Scryfall are now also in PYPI!