BlenderKit: fix a bug in text splitting(could run eternal while) and fix wrong argument in Oauth

This commit is contained in:
Vilem Duha 2019-06-01 18:21:40 +02:00
parent 07d74a9b2e
commit 75fc9e4589
3 changed files with 7 additions and 6 deletions

View File

@ -62,11 +62,10 @@ def refresh_token_thread():
def refresh_token(api_key_refresh):
authenticator = oauth.SimpleOAuthAuthenticator(server_url=paths.get_bkit_url(), client_id=CLIENT_ID, ports=PORTS,
redirect_url='')
authenticator = oauth.SimpleOAuthAuthenticator(server_url=paths.get_bkit_url(), client_id=CLIENT_ID, ports=PORTS)
auth_token, refresh_token = authenticator.get_refreshed_token(api_key_refresh)
if auth_token is not None and refresh_token is not None:
tasks_queue.add_task((blenderkit.bkit_oauth.write_tokens, (auth_token, refresh_token)))
tasks_queue.add_task((write_tokens, (auth_token, refresh_token)))
def write_tokens(auth_token, refresh_token):

View File

@ -18,6 +18,7 @@
import bpy, os, sys
_presets = os.path.join(bpy.utils.user_resource('SCRIPTS'), "presets")
BLENDERKIT_LOCAL = "http://localhost:8001"
BLENDERKIT_MAIN = "https://www.blenderkit.com"
BLENDERKIT_DEVEL = "https://devel.blenderkit.com"
@ -34,7 +35,6 @@ BLENDERKIT_SIGNUP_URL = "https://www.blenderkit.com/accounts/register"
BLENDERKIT_ADDON_URL = "https://www.blenderkit.com/api/v1/assets/6923b215-7df0-46f3-95ae-a2b5ff44ddd5/"
BLENDERKIT_ADDON_FILE_URL = "https://www.blenderkit.com/get-blenderkit/"
BLENDERKIT_SETTINGS_FILENAME = os.path.join(_presets, "bkit.json")
_presets = os.path.join(bpy.utils.user_resource('SCRIPTS'), "presets")
def get_bkit_url():

View File

@ -308,11 +308,13 @@ def split_subs(text):
threshold = 40
text = text.rstrip()
lines = []
while len(text) > threshold:
i = text.rfind(' ', 0, threshold)
i1 = text.rfind(',', 0, threshold)
i = max(i, i1)
if i == -1:
i2 = text.rfind('.', 0, threshold)
i = max(i, i1, i2)
if i <= 0:
i = threshold
lines.append(text[:i])
text = text[i:]