with open('out/errors.json', 'w') as outfile: json.dump(errorlog, outfile, sort_keys=True, indent=2, separators=(',', ': ')) if __name__ == '__main__': AllSets = spoilers.get_allsets() mtgs = spoilers.scrape_mtgs('http://www.mtgsalvation.com/spoilers.rss') mtgs = spoilers.parse_mtgs(mtgs) mtgs = spoilers.correct_cards(mtgs, manual_cards, card_corrections, delete_cards) #errorlog.append(temperror) #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']) #errorlog.append(temperror) [mtgs, errors] = spoilers.errorcheck(mtgs) errorlog += errors spoilers.write_xml(mtgs, setinfos['setname'], setinfos['setlongname'], setinfos['setreleasedate']) mtgs = spoilers.add_headers(mtgs, setinfos) AllSets = spoilers.make_allsets(AllSets, mtgs, setinfos['setname']) if 'masterpieces' in setinfos: masterpieces = spoilers.make_masterpieces(setinfos['masterpieces'], AllSets, mtgs) [masterpieces, errors] = spoilers.errorcheck(masterpieces) errorlog += errors #errorlog.append(temperror) spoilers.write_xml(masterpieces, setinfos['masterpieces']['setname'], setinfos['masterpieces']['setlongname'], setinfos['masterpieces']['setreleasedate']) AllSets = spoilers.make_allsets(AllSets, masterpieces, setinfos['masterpieces']['setname']) save_masterpieces(masterpieces) save_errorlog(errorlog) save_allsets(AllSets) save_setjson(mtgs) #outline #set variables
setinfo['code'].lower()) mtgjson = scryfall #_scraper.smash_mtgs_scryfall(mtgs, scryfall) if 'fullSpoil' in setinfo and setinfo['fullSpoil']: wotc = wizards_scraper.scrape_fullspoil('', setinfo) wizards_scraper.smash_fullspoil(mtgjson, wotc) [mtgjson, errors] = spoilers.error_check( mtgjson, card_corrections) # check for errors where possible errorlog += errors if not 'cards' in mtgjson or mtgjson[ 'cards'] == [] or not mtgjson['cards']: noCards.append(setinfo['code']) continue spoilers.write_xml(mtgjson, setinfo['code'], setinfo['name'], setinfo['releaseDate']) #save_xml(spoilers.pretty_xml(setinfo['code']), 'out/spoiler.xml') mtgjson = spoilers.add_headers(mtgjson, setinfo) AllSets = spoilers.make_allsets(AllSets, mtgjson, setinfo['code']) if 'masterpieces' in setinfo: # repeat all of the above for masterpieces # masterpieces aren't in the rss feed, so for the new cards, we'll go to their individual pages on mtgs # old cards will get their infos copied from mtgjson (including fields that may not apply like 'artist') # the images will still come from mtgs masterpieces = spoilers.make_masterpieces(setinfo['masterpieces'], AllSets, mtgjson) [masterpieces, errors] = spoilers.error_check(masterpieces) errorlog += errors spoilers.write_xml(masterpieces, setinfo['masterpieces']['code'], setinfo['masterpieces']['name'], setinfo['masterpieces']['releaseDate']) AllSets = spoilers.make_allsets(AllSets, masterpieces, setinfo['masterpieces']['code']) save_masterpieces(masterpieces, setinfo)