Constantin Wenger
2019-08-13 6227a8da1770de3eb09e220d3330c21c00dd97ba
work a round for "con" being a forbidden filename on windows
2 files modified
22 ■■■■ changed files
fetch_data.py 10 ●●●● patch | view | raw | blame | history
opencv_dnn.py 12 ●●●● patch | view | raw | blame | history
fetch_data.py
@@ -100,7 +100,10 @@
    :return:
    """
    if out_dir is None:
        out_dir = '%s/card_img/%s/%s' % (Config.data_dir, size, row['set'])
        s = row['set']
        if s == 'con':
           s = 'con__'
        out_dir = '%s/card_img/%s/%s' % (Config.data_dir, size, s)
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)
@@ -133,7 +136,10 @@
def main():
    # Query card data by each set, then merge them together
    for set_name in Config.all_set_list:
        csv_name = '%s/csv/%s.csv' % (Config.data_dir, set_name)
        set_name_m = set_name
        if set_name_m == 'con':
            set_name_m = 'con__'
        csv_name = '%s/csv/%s.csv' % (Config.data_dir, set_name_m)
        print(csv_name)
        if not os.path.isfile(csv_name):
            df = fetch_all_cards_text(url='https://api.scryfall.com/cards/search?q=set:%s+lang:en' % set_name,
opencv_dnn.py
@@ -49,15 +49,21 @@
        for card_name in card_names:
            # Fetch the image - name can be found based on the card's information
            card_info['name'] = card_name
            cname = card_name
            if cname == 'con':
                cname == 'con__'
            img_name = '%s/card_img/png/%s/%s_%s.png' % (Config.data_dir, card_info['set'],
                                                         card_info['collector_number'],
                                                         fetch_data.get_valid_filename(card_info['name']))
                                                         fetch_data.get_valid_filename(cname))
            card_img = cv2.imread(img_name)
            # If the image doesn't exist, download it from the URL
            if card_img is None:
                set_name = card_info['set']
                if set_name == 'con':
                    set_name = 'con__'
                fetch_data.fetch_card_image(card_info,
                                            out_dir='%s/card_img/png/%s' % (Config.data_dir, card_info['set']))
                                            out_dir='%s/card_img/png/%s' % (Config.data_dir, set_name))
                card_img = cv2.imread(img_name)
            if card_img is None:
                print('WARNING: card %s is not found!' % img_name)
@@ -624,6 +630,8 @@
        # Merge database for all cards, then calculate pHash values of each, store them
        df_list = []
        for set_name in Config.all_set_list:
            if set_name == 'con':
                set_name = 'con__'
            csv_name = '%s/csv/%s.csv' % (Config.data_dir, set_name)
            df = fetch_data.load_all_cards_text(csv_name)
            df_list.append(df)