mirror of
https://github.com/Cockatrice/Magic-Spoiler.git
synced 2026-07-19 00:57:04 -05:00
Return of Corrections (#29)
This commit is contained in:
parent
b471f1073d
commit
0f2d772821
2
main.py
2
main.py
|
|
@ -86,7 +86,7 @@ if __name__ == '__main__':
|
|||
scryfall = spoilers.get_scryfall('https://api.scryfall.com/cards/search?q=++e:' + setinfo['setname'].lower())
|
||||
mtgs = spoilers.get_image_urls(mtgs, presets['isfullspoil'], setinfo['setname'], setinfo['setlongname'], setinfo['setsize']) #get images
|
||||
mtgjson = spoilers.smash_mtgs_scryfall(mtgs, scryfall)
|
||||
[mtgjson, errors] = spoilers.error_check(mtgjson) #check for errors where possible
|
||||
[mtgjson, errors] = spoilers.error_check(mtgjson, card_corrections) #check for errors where possible
|
||||
errorlog += errors
|
||||
spoilers.write_xml(mtgjson, setinfo['setname'], setinfo['setlongname'], setinfo['setreleasedate'])
|
||||
#save_xml(spoilers.pretty_xml(setinfo['setname']), 'out/spoiler.xml')
|
||||
|
|
|
|||
18
spoilers.py
18
spoilers.py
|
|
@ -315,7 +315,7 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[]
|
|||
|
||||
return mtgjson
|
||||
|
||||
def error_check(mtgjson):
|
||||
def error_check(mtgjson, card_corrections={}):
|
||||
errors = []
|
||||
|
||||
for card in mtgjson['cards']:
|
||||
|
|
@ -327,7 +327,6 @@ def error_check(mtgjson):
|
|||
if not requiredKey in card:
|
||||
errors.append({"name": card['name'], "key": key, "missing": True})
|
||||
if 'text' in card:
|
||||
#foo = 1
|
||||
card['text'] = card['text'].replace('<i>','').replace('</i>','').replace('<em>','').replace('</em','').replace('(','').replace('•',u'•')
|
||||
if 'type' in card:
|
||||
if 'Planeswalker' in card['type']:
|
||||
|
|
@ -414,6 +413,21 @@ def error_check(mtgjson):
|
|||
errors.append({"name": card['name'], "key": "number", "value": ""})
|
||||
if not 'types' in card:
|
||||
errors.append({"name": card['name'], "key": "types", "value": ""})
|
||||
|
||||
for card in mtgjson['cards']:
|
||||
for cardCorrection in card_corrections:
|
||||
if card['name'] == cardCorrection:
|
||||
for correctionType in card_corrections[cardCorrection]:
|
||||
# if not correctionType in card and correctionType not in :
|
||||
# sys.exit("Invalid correction for " + cardCorrection + " of type " + card)
|
||||
if not correctionType == 'name':
|
||||
if correctionType == 'img':
|
||||
card['url'] = card_corrections[cardCorrection][correctionType]
|
||||
else:
|
||||
card[correctionType] = card_corrections[cardCorrection][correctionType]
|
||||
if 'name' in card_corrections[cardCorrection]:
|
||||
card['name'] = card_corrections[cardCorrection]['name']
|
||||
|
||||
return [mtgjson, errors]
|
||||
|
||||
def remove_corrected_errors(errorlog=[], card_corrections=[], print_fixed=False):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user