From fc7449827cfd5025a2cb5866e0fe6a395960a809 Mon Sep 17 00:00:00 2001 From: spbeach46 Date: Wed, 2 Jun 2021 00:29:58 -0700 Subject: [PATCH] added option to expand pics or not. Meaning @ dl only primary pic will dl --- ebay_api.py | 62 +++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/ebay_api.py b/ebay_api.py index 87c9acf..ff62a52 100644 --- a/ebay_api.py +++ b/ebay_api.py @@ -51,9 +51,11 @@ class FindingApi: "paginationInput.entriesPerPage":"100", "paginationInput.PageNumber":i, "itemFilter(0).name":"Condition", - "itemFilter(0).value":"Used", + "itemFilter(0).value":"Used", # recommended is conditionId instead but for some reason that doesn't work either + # but may not be necessary anyways if you can eleminate dupes "sortOrder":"StartTimeNewest", - "itemFilter(0).name":"HideDuplicateItems" + "itemFilter.name":"HideDuplicateItems", # this is working + "itemFilter.value":'true' } # TODO add try excepts here @@ -368,43 +370,47 @@ class CurateData: * consider applying this function to other cells that have multiple values in their lists ''' - expanded_class = class_training.explode('PictureURL').reset_index(drop=True) - expanded_class = expanded_class.dropna(subset=['PictureURL']) - expanded_class = expanded_class.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) + expand = input("expand image list or use primary listing image? (y or n): ") + if ('y' or 'Y') in expand: + expanded_class = class_training.explode('PictureURL').reset_index(drop=True) + expanded_class = expanded_class.dropna(subset=['PictureURL']) + expanded_class = expanded_class.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) - expanded_dropd = dropd.explode('PictureURL').reset_index(drop=True) - expanded_dropd = expanded_dropd.dropna(subset=['PictureURL']) - expanded_dropd = expanded_dropd.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) + expanded_dropd = dropd.explode('PictureURL').reset_index(drop=True) + expanded_dropd = expanded_dropd.dropna(subset=['PictureURL']) + expanded_dropd = expanded_dropd.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) - expanded_dropd = self.extract_df(expanded_dropd) # convert lists to values + expanded_dropd = self.extract_df(expanded_dropd) # convert lists to values - temp_pics_source_list = list(set(expanded_class.PictureURL.to_list())) + temp_pics_source_list = list(set(expanded_class.PictureURL.to_list())) - try: - with open('temp_pics_source_list.txt') as f: - tpsl = json.load(f) - tpsl.extend(temp_pics_source_list) - temp_pics_source_list = list(set(tpsl)) + try: + with open('temp_pics_source_list.txt') as f: + tpsl = json.load(f) + tpsl.extend(temp_pics_source_list) + temp_pics_source_list = list(set(tpsl)) + with open('temp_pics_source_list.txt', 'w') as f: + json.dump(temp_pics_source_list, f) + except (ValueError, FileNotFoundError): with open('temp_pics_source_list.txt', 'w') as f: json.dump(temp_pics_source_list, f) - except (ValueError, FileNotFoundError): - with open('temp_pics_source_list.txt', 'w') as f: - json.dump(temp_pics_source_list, f) - # Append to master training dataframes, drop potential dupes and save + # Append to master training dataframes, drop potential dupes and save - expanded_class.to_csv('expanded_class.csv') - # expanded_class = pd.read_csv('expanded_class.csv', index_col=0) - # expanded_class.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) - # expanded_class.to_csv('expanded_class.csv', mode='a', encoding='utf-8') # TODO see line 235 about views and copies + expanded_class.to_csv('expanded_class.csv') + # expanded_class = pd.read_csv('expanded_class.csv', index_col=0) + # expanded_class.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) + # expanded_class.to_csv('expanded_class.csv', mode='a', encoding='utf-8') # TODO see line 235 about views and copies - expanded_dropd.to_csv('expanded_dropd.csv') - # expanded_dropd = pd.read_csv('expanded_dropd.csv', index_col=0) - # expanded_dropd.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) - # expanded_dropd.to_csv('expanded_dropd.csv', mode='a', encoding='utf-8') + expanded_dropd.to_csv('expanded_dropd.csv') + # expanded_dropd = pd.read_csv('expanded_dropd.csv', index_col=0) + # expanded_dropd.drop_duplicates(subset=['PictureURL']).reset_index(drop=True) + # expanded_dropd.to_csv('expanded_dropd.csv', mode='a', encoding='utf-8') - return expanded_class, expanded_dropd + return expanded_class, expanded_dropd + else: + return def dl_pictures(self, *args): '''