Spaces:
Running
Running
raannakasturi
commited on
Commit
·
733aa95
1
Parent(s):
4091161
Update OAuth client secret and improve image upload handling in post_blog.py and get_refresh_token.py
Browse files- get_refresh_token.py +1 -1
- post_blog.py +3 -3
get_refresh_token.py
CHANGED
@@ -6,7 +6,7 @@ from googleapiclient import discovery
|
|
6 |
|
7 |
# Start the OAuth flow to retrieve credentials
|
8 |
def authorize_credentials():
|
9 |
-
CLIENT_SECRET = '
|
10 |
SCOPE = 'https://www.googleapis.com/auth/blogger'
|
11 |
STORAGE = Storage('credentials.storage.json')
|
12 |
credentials = STORAGE.get()
|
|
|
6 |
|
7 |
# Start the OAuth flow to retrieve credentials
|
8 |
def authorize_credentials():
|
9 |
+
CLIENT_SECRET = 'client_secret.json'
|
10 |
SCOPE = 'https://www.googleapis.com/auth/blogger'
|
11 |
STORAGE = Storage('credentials.storage.json')
|
12 |
credentials = STORAGE.get()
|
post_blog.py
CHANGED
@@ -21,7 +21,7 @@ def extract_summary(text):
|
|
21 |
return None
|
22 |
|
23 |
def upload_image(image, api_key):
|
24 |
-
url = 'https://api.imgbb.com/1/upload?key=
|
25 |
response = requests.post(url, data = {'image': image})
|
26 |
image_url = response.json()['data']['image']['url']
|
27 |
status_code = response.json()['status']
|
@@ -149,10 +149,10 @@ def post_blog(title, category, summary, mindmap, citation, uaccess_key):
|
|
149 |
post_title, post_category, post_body, post_image = create_post(title, category, summary, mindmap, citation)
|
150 |
i = 1
|
151 |
status = False
|
152 |
-
while (i <=
|
153 |
print(f'Posting... Tries: {i}')
|
154 |
status = post_post(post_title, post_category, post_body, post_image, i)
|
155 |
-
time.sleep(30)
|
156 |
i += 1
|
157 |
if status:
|
158 |
print('Post created successfully')
|
|
|
21 |
return None
|
22 |
|
23 |
def upload_image(image, api_key):
|
24 |
+
url = f'https://api.imgbb.com/1/upload?key={api_key}'
|
25 |
response = requests.post(url, data = {'image': image})
|
26 |
image_url = response.json()['data']['image']['url']
|
27 |
status_code = response.json()['status']
|
|
|
149 |
post_title, post_category, post_body, post_image = create_post(title, category, summary, mindmap, citation)
|
150 |
i = 1
|
151 |
status = False
|
152 |
+
while (i <= 2 and not status):
|
153 |
print(f'Posting... Tries: {i}')
|
154 |
status = post_post(post_title, post_category, post_body, post_image, i)
|
155 |
+
# time.sleep(30)
|
156 |
i += 1
|
157 |
if status:
|
158 |
print('Post created successfully')
|