diff --git a/ebay_api.py b/ebay_api.py index e019b41..182563c 100644 --- a/ebay_api.py +++ b/ebay_api.py @@ -323,21 +323,21 @@ class CurateData: print('url list not found. download aborted') return - temp_dict_pics = {k:target_dir+re.search(r'[^/]+(?=/\$_|.jpg)', k, re.IGNORECASE).group()+'.jpg' for k in temp_pics_source_list} + temp_dict_pics = {k:target_dir + os.sep + re.search(r'[^/]+(?=/\$_|.jpg)', k, re.IGNORECASE).group() + '.jpg' for k in temp_pics_source_list} - breakpoint() try: with open('dict_pics.txt') as f: dict_pics = json.load(f) - temp_dict_pics.update(dict_pics) + dict_pics.update(temp_dict_pics) with open('dict_pics.txt', 'w') as f: - json.dump(temp_dict_pics, f) + json.dump(dict_pics, f) except (ValueError, FileNotFoundError): - json.dump(temp_dict_pics, f) - dict_pics = temp_dict_pics + with open('dict_pics.txt', 'w') as f: + json.dump(temp_dict_pics, f) + dict_pics = temp_dict_pics - def dl_pic(pic,dict_pics): + def dl_pic(dict_pics, pic): if os.path.exists(dict_pics[pic]): # or call temp_dict_pics[pic] can work pass @@ -348,7 +348,9 @@ class CurateData: with open(temp_dict_pics[pic], 'wb') as f: # Or call dict_pics[pic] can work shutil.copyfileobj(r.raw, f) - bargs = [(dict_pics, pic) for pic in temp_pics_source_list] # TODO not sure this is correct list of tuples needed + breakpoint() + bargs = [(dict_pics, pic) for pic in temp_pics_source_list] + with concurrent.futures.ThreadPoolExecutor() as executor: for future in executor.map(lambda p: dl_pic(*p), bargs): future