mirror of
https://github.com/Relintai/mtg-forge-ios.git
synced 2024-11-14 04:17:19 +01:00
29260c205d
git-svn-id: http://svn.slightlymagic.net/forge/trunk@35700 269b9781-a132-4a9b-9d4e-f004f1b56b58
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
import sys
|
|
import requests
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description='Edition File Generator')
|
|
|
|
# -s for set code
|
|
parser.add_argument('-c', action='store', dest='setcode', help='Required setcode', default=None)
|
|
parser.add_argument('-n', action='store', dest='name', help='Name of edition', default='NEW SET XXX')
|
|
parser.add_argument('-t', action='store', dest='settype', help='Type of edition (Expansion, Duel_Decks, Other, etc)', default='Expansion')
|
|
|
|
result = parser.parse_args()
|
|
|
|
if result.setcode is None:
|
|
print "Missing required set code. Please provide a -c command line argument.\n"
|
|
print parser.parse_args(['-h'])
|
|
sys.exit(1)
|
|
|
|
r = requests.get('http://mtgjson.com/json/%s.json' % result.setcode)
|
|
d = r.json()
|
|
cards = d['cards']
|
|
|
|
f = open('%s.txt' % d['name'], 'w')
|
|
|
|
f.write('[metadata]\n')
|
|
f.write('Code=%s\n' % result.setcode)
|
|
f.write('Date=%s\n' % d['releaseDate'])
|
|
f.write('Name=%s\n' % d['name'])
|
|
f.write('Code2=%s\n' % result.setcode)
|
|
f.write('MciCode=%s\n' % result.setcode.lower())
|
|
f.write('Type=%s\n\n' % d['type'])
|
|
f.write('[cards]\n')
|
|
|
|
for c in cards:
|
|
l = []
|
|
l.append(c['number'])
|
|
|
|
rarity = c['rarity'][0]
|
|
if rarity == 'B':
|
|
rarity = 'L'
|
|
l.append(rarity)
|
|
l.append(c['name'].replace(u'\xc6', 'AE'))
|
|
l.append('\n')
|
|
f.write(' '.join(l)) |