diff --git a/cards_corrections.json b/cards_corrections.json index de07953c..7a73a41b 100644 --- a/cards_corrections.json +++ b/cards_corrections.json @@ -1,18 +1,2 @@ { - "Open into Wonder": { - "manaCost": "{X}{U}{U}" - }, - "By Force": { - "manaCost": "{X}{R}" - }, - "Nissa, Steward of Elements": { - "manaCost": "{X}{U}{G}", - "loyalty": "X" - }, - "Pull From Tomorrow": { - "name": "Pull from Tomorrow" - }, - "Tresspasser's Curse": { - "name": "Trespasser's Curse" - } } \ No newline at end of file diff --git a/cards_delete.json b/cards_delete.json index b4393b6c..fe51488c 100644 --- a/cards_delete.json +++ b/cards_delete.json @@ -1 +1 @@ -["~Sandwurm Convengence","Holaphel, Maw of Sands","Evolving Wilds"] +[] diff --git a/cards_manual.json b/cards_manual.json index 7443059f..bf3d1995 100644 --- a/cards_manual.json +++ b/cards_manual.json @@ -45,10 +45,12 @@ "blank card (do not use this key, just the object) - remove unneeded keys": { "name": "", + "manaCost": "", "number": "", "rarity": "", "type": "", "url": "", + "text": "", "loyalty": "", "cmc": 0, "layout": "", @@ -57,5 +59,37 @@ } }, "cards": [ + { + "name": "Nicol Bolas, God-Pharaoh", + "manaCost": "4UBR", + "number": "140", + "rarity": "Mythic Rare", + "type": "Planeswalker - Bolas", + "url": "https://i.imgur.com/DTNXG2z.png", + "text": "+2: Target opponent exiles cards from the top of his or her library until he or she exiles a nonland card. Until end of turn, you may cast that card without paying its mana cost.\n+1: Each opponent exiles two cards from his or her hand.\n-4: Nicol Bolas, God-Pharaoh deals 7 damage to target opponent or creature an opponent controls.\n-12: Exile each nonland permanent your opponents control.", + "loyalty": "7", + "cmc": 7 + }, + { + "name": "Bontu's Last Reckoning", + "manaCost": "1BB", + "number": "60", + "rarity": "Rare", + "type": "Sorcery", + "url": "https://i.imgur.com/HOjh3pE.png", + "text": "Destroy all creatures. Lands you control don't untap during your next untap step.", + "cmc": 3 + }, + { + "name": "Samut, the Tested", + "manaCost": "2RG", + "number": "144", + "rarity": "Mythic Rare", + "type": "Planeswalker - Samut", + "url": "https://i.imgur.com/4tRYs5z.png", + "text": "+1: Up to one target creature gains double strike until end of turn.\n-2: Samut, the Tested deals 2 damage divided as you choose among one or two target creatures and/or players.\n-7: Search your library for up to two creature and/or planeswalker cards, put them onto the battlefield, then shuffle your library.", + "loyalty": "4", + "cmc": 4 + } ] } diff --git a/main.py b/main.py index f00334fc..15d2001a 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,8 @@ import json presets = { "isfullspoil": True, #when full spoil comes around, we only want to use WOTC images - "includeMasterpieces": True #if the set has masterpieces, let's get those too + "includeMasterpieces": True, #if the set has masterpieces, let's get those too + "oldRSS": True #maybe MTGS hasn't updated their spoiler.rss but new cards have leaked } with open('set_info.json') as data_file: @@ -64,8 +65,11 @@ def save_errorlog(errorlog): if __name__ == '__main__': AllSets = spoilers.get_allsets() #get AllSets from mtgjson - mtgs = spoilers.scrape_mtgs('http://www.mtgsalvation.com/spoilers.rss') #scrape mtgs rss feed - mtgs = spoilers.parse_mtgs(mtgs) #parse spoilers into mtgjson format + if presets['oldRSS']: + mtgs = {"cards":[]} + else: + mtgs = spoilers.scrape_mtgs('http://www.mtgsalvation.com/spoilers.rss') #scrape mtgs rss feed + mtgs = spoilers.parse_mtgs(mtgs) #parse spoilers into mtgjson format mtgs = spoilers.correct_cards(mtgs, manual_cards, card_corrections, delete_cards) #fix using the fixfiles #scryfall = spoilers.get_scryfall('https://api.scryfall.com/cards/search?q=++e:' + setinfos['setname'].lower()) mtgs = spoilers.get_image_urls(mtgs, presets['isfullspoil'], setinfos['setname'], setinfos['setlongname'], setinfos['setsize']) #get images @@ -86,4 +90,4 @@ if __name__ == '__main__': save_masterpieces(masterpieces) save_errorlog(errorlog) save_allsets(AllSets) - #save_setjson(mtgs) + save_setjson(mtgs) diff --git a/set_info.json b/set_info.json index 2db04f68..47d2dbf0 100644 --- a/set_info.json +++ b/set_info.json @@ -1,9 +1,9 @@ { - "setname": "AKH", - "setlongname": "Amonkhet", + "setname": "HOU", + "setlongname": "Hour of Devastation", "blockname": "Amonkhet", - "setsize": 269, - "setreleasedate": "2017-04-28", + "setsize": 199, + "setreleasedate": "2017-07-14", "settype": "expansion", "masterpieces": { "setname": "MPS_AKH", diff --git a/spoilers.py b/spoilers.py index 527ec512..a48bc8b7 100644 --- a/spoilers.py +++ b/spoilers.py @@ -248,17 +248,17 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[] workingCMC += 1 if 'types' not in card: card['types'] = [] - if '—' in card['type']: - workingTypes = card['type'].split('—')[0].strip() - else: - workingTypes = card['type'].split('-')[0].strip() +# if '—' in card['type']: +# workingTypes = card['type'].split('—')[0].strip() +# else: + workingTypes = card['type'].split('-')[0].strip() workingTypes.replace('Legendary ','').replace('Snow ','')\ .replace('Elite ','').replace('Basic ','').replace('World ','').replace('Ongoing ','') card['types'] += workingTypes.split(' ') if 'subtypes' not in card: - if '—' in card['type']: - workingSubtypes = card['type'].split('—')[1].strip() - elif '-' in card['type']: +# if '—' in card['type']: +# workingSubtypes = card['type'].split('—')[1].strip() + if '-' in card['type']: workingSubtypes = card['type'].split('-')[1].strip() if workingSubtypes: card['subtypes'] = workingSubtypes.split(' ') @@ -280,7 +280,7 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[] card['colorIdentity'] = [letter] if 'colors' in card: if not colorMap[letter] in card['colors']: - card['colors'] += colorMap[letter] + card['colors'].append(colorMap[letter]) else: card['colors'] = [colorMap[letter]] if 'text' in card: @@ -297,10 +297,22 @@ def correct_cards(mtgjson, manual_cards=[], card_corrections=[], delete_cards=[] for manualCard in manual_cards: if card['name'] == manualCard['name']: mtgjson2.append(manualCard) + print 'overwriting card ' + card['name'] isManual = True if not isManual and not card['name'] in delete_cards: mtgjson2.append(card) + + for manualCard in manual_cards: + addManual = True + for card in mtgjson['cards']: + if manualCard['name'] == card['name']: + addManual = False + if addManual: + mtgjson2.append(manualCard) + print 'inserting manual card ' + manualCard['name'] + mtgjson = {"cards": mtgjson2} + for card in mtgjson['cards']: for cardCorrection in card_corrections: if card['name'] == cardCorrection: @@ -811,7 +823,7 @@ def write_xml(mtgjson, setname, setlongname, setreleasedate, split_cards=[]): cardsxml.write("" + name.encode('utf-8') + "\n") cardsxml.write('' + setname + '\n') cardsxml.write("" + manacost.encode('utf-8') + "\n") - cardsxml.write("" + cardcmc + "") + cardsxml.write("" + cardcmc + "\n") if card.has_key('colors'): colorTranslate = { "White": "W", @@ -821,14 +833,14 @@ def write_xml(mtgjson, setname, setlongname, setreleasedate, split_cards=[]): "Green": "G" } for color in card['colors']: - cardsxml.write('' + colorTranslate[color] + '') + cardsxml.write('' + colorTranslate[color] + '\n') if name + ' enters the battlefield tapped' in text: - cardsxml.write("1") + cardsxml.write("1\n") cardsxml.write("" + cardtype.encode('utf-8') + "\n") if pt: cardsxml.write("" + pt + "\n") if card.has_key('loyalty'): - cardsxml.write("" + str(card['loyalty']) + "") + cardsxml.write("" + str(card['loyalty']) + "\n") cardsxml.write("" + tablerow + "\n") cardsxml.write("" + text.encode('utf-8') + "\n") if related: @@ -839,9 +851,9 @@ def write_xml(mtgjson, setname, setlongname, setreleasedate, split_cards=[]): cardsxml.write("\n") cardsxml.write("\n") - - if os.path.isfile('out/' + setname + '.xml'): - shutil.copyfile('out/' + setname + '.xml','out/spoiler.xml') + if not 'MPS' in setname: + if os.path.isfile('out/' + setname + '.xml'): + shutil.copyfile('out/' + setname + '.xml','out/spoiler.xml') #failing pretty xml code #with open('out/' + setname + '.xml') as data_file: