Skip to content

Instantly share code, notes, and snippets.

@haozes
Last active October 29, 2023 09:10
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save haozes/5154ee5d7175dbf31e0a94ae15363807 to your computer and use it in GitHub Desktop.
Save haozes/5154ee5d7175dbf31e0a94ae15363807 to your computer and use it in GitHub Desktop.
Update App Connect whats new info
# need install asconnect: pip install asconnect, and openai: pip install openai
import asconnect
import os
import openai
#api key: https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api
APPCONN_APIKEY_ID = "xxxxx"
APPCONN_ISSUER_ID = "xxxxxxx"
APPCONN_KEY_FILE = "xxxxx.p8"
# your openai api key
openai.api_key = "xxxxxxxxxxx"
# your app's bundle id
APP_BUNDLE_ID = "hltek.YaoYao"
# your app's version ready to be released
VERSION_STR = "3.7.8"
WHATS_NEW = "- Bug Fixes & Performance Improvements"
def read_secret_key() -> str:
with open(APPCONN_KEY_FILE, "r") as f:
return f.read()
def translate(lanId,text) -> str:
prompt = "Translate the following text according to the language code:"+ lanId+" \n\n" + text
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": prompt}],
temperature=0,
max_tokens=1024
)
return response.choices[0].message.content
key = read_secret_key()
client = asconnect.Client(key_id=APPCONN_APIKEY_ID, key_contents=key, issuer_id= APPCONN_ISSUER_ID)
app = client.app.get_from_bundle_id(APP_BUNDLE_ID)
print(app.name)
version = client.version.get_version(app_id=app.identifier, version_string=VERSION_STR)
print("-------------------- \n\n")
for localized_info in client.version.get_localizations(version_id=version.identifier):
translated = translate(localized_info.attributes.locale,WHATS_NEW)
print(localized_info.attributes.locale + ":" + translated)
client.app_info.set_localization_version_properties(version_localization_id = localized_info.identifier, whats_new = translated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment