Esempio n. 1
0
#! /usr/bin/python
'''
ffxiah_prices.py

For each auctionable item in FFXI scrape the median price from FFXIAH.com.
'''
import argparse as ap
from ffxiah.parser import Parser
from ffxiah.dspdb import DSPDB

if __name__ == '__main__':
    ffxiah = Parser()

    parser = ap.ArgumentParser(prog='ffxiah_prices.py',
                               conflict_handler='resolve',
                               description="Scrape prices from ffxiah.com")

    parser.add_argument(
        '-s', '--server',
        default='Carbuncle',
        help=('Server to scrape from.(ACTIVE: {0} || INACTIVE: {1})'.format(
            ', '.join(ffxiah.active),
            ', '.join(ffxiah.inactive)
        )),
        metavar=''
    )
    parser.add_argument('-m', '--missing',
        default='Carbuncle',
        help=('Server to scrape  missing prices from.(ACTIVE: {0})'.format(
            ', '.join(ffxiah.active)
        )),
if __name__ == '__main__':
    parser = ap.ArgumentParser(prog='update_categories.py', 
                               conflict_handler='resolve', 
                               description="Compare category IDs")

    parser.add_argument('-h', '--help', action='help', 
                        help='Show this help message and exit')
    
    args = parser.parse_args()
    
    # Get DSP item info
    dspdb = DSPDB()
    dspdb.dsp_items()
    
    # Set Server to scrape
    ffxiah = Parser()
    ffxiah.use_server('Carbuncle')
    
    # Get FFXIAH item info
    ffxiah.ah_items()

    # Compare categories
    for item_id in ffxiah.items:
        if ffxiah.items[item_id]['category'] != dspdb.items[item_id]['category']:
            dspdb.update_category(item_id, ffxiah.items[item_id]['category'])
            print 'Updated Category For {0} ({1}, {2}->{3})'.format(
                ffxiah.items[item_id]['name'], 
                item_id, 
                dspdb.items[item_id]['category'],
                ffxiah.items[item_id]['category']
            )