From a4f93af3ee02a77520cafe85790fde9fe6e1f476 Mon Sep 17 00:00:00 2001 From: scott Date: Sun, 9 Jan 2022 19:16:56 -0700 Subject: [PATCH] dict_pics cleanup and changed tag file extensions to lowercase --- ebay_api.py | 14 ++++++++------ oauth_fetch.py | 6 ++++++ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 oauth_fetch.py diff --git a/ebay_api.py b/ebay_api.py index f33c6cc..72accb9 100644 --- a/ebay_api.py +++ b/ebay_api.py @@ -400,7 +400,7 @@ class CurateData: try: - if os.path.exists(dict_pics[pic]): + if os.path.exists(dict_pics[pic]): # TODO DOES NOT FIND CURRENT PATHS BECUASE TAGS WILL NOW BE DIFFERENT. YOU WILL END UP RE DOWNLOADING IMAGES pass else: @@ -443,20 +443,22 @@ class CurateData: dict_pics = {} for k in temp_pics_source_list: - if re.search(r'[^/]+(?=/\$_|.(.jpg|.jpeg|.png))', k, re.IGNORECASE) and re.search(r'(.jpg|.jpeg|.png)', k, re.IGNORECASE) is not None: - tag = re.search(r'[^/]+(?=/\$_|.(.jpg|.jpeg|.png))', k, re.IGNORECASE).group() + re.search(r'(.jpg|.jpeg|.png)', k, re.IGNORECASE).group() + patt_1 = re.search(r'[^/]+(?=/\$_|.(.jpg|.jpeg|.png))', k, re.IGNORECASE) + patt_2 = re.search(r'(.jpg|.jpeg|.png)', k, re.IGNORECASE) + if patt_1 and patt_2 is not None: + tag = patt_1.group() + patt_2.group().lower() file_name = target_dir + os.sep + tag dict_pics.update({k:file_name}) - with open('dict_pics.txt', 'w') as f: - json.dump(dict_pics, f) +# with open('dict_pics.txt', 'w') as f: +# json.dump(dict_pics, f) return dict_pics # TODO still need to find sol to outliers (i.e., naming scheme for unusual source URLs) def dl_pictures(self, *dict_pics): ''' Downloads pictures from api to local storage using temp_pics_source_list - and creates custom {source:target} dictionary as dict_pics + and dict_pics ''' if not dict_pics: diff --git a/oauth_fetch.py b/oauth_fetch.py new file mode 100644 index 0000000..bdc91ed --- /dev/null +++ b/oauth_fetch.py @@ -0,0 +1,6 @@ +import json +import config as cfg +import ebay_api +import requests + +req_endpoint = "https://api.ebay.com/identity/v1/oauth2/token"