Update version to 1.11.01 and enhance localization for OAuth profile selection. Added new features including Arabic language support, machine ID restoration from backup, and improved error handling in the update process. Updated menu options and fixed various issues for a better user experience.

This commit is contained in:
Pin Studios
2025-04-24 11:20:21 +08:00
parent 296a69bf73
commit da5bff5994
8 changed files with 131 additions and 51 deletions

123
main.py
View File

@@ -366,14 +366,18 @@ def print_menu():
2: f"{Fore.GREEN}2{Style.RESET_ALL}. {EMOJI['SUCCESS']} {translator.get('menu.register_manual')}",
3: f"{Fore.GREEN}3{Style.RESET_ALL}. {EMOJI['ERROR']} {translator.get('menu.quit')}",
4: f"{Fore.GREEN}4{Style.RESET_ALL}. {EMOJI['LANG']} {translator.get('menu.select_language')}",
5: f"{Fore.GREEN}5{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.disable_auto_update')}",
6: f"{Fore.GREEN}6{Style.RESET_ALL}. {EMOJI['RESET']} {translator.get('menu.totally_reset')}",
7: f"{Fore.GREEN}7{Style.RESET_ALL}. {EMOJI['CONTRIBUTE']} {translator.get('menu.contribute')}",
8: f"{Fore.GREEN}8{Style.RESET_ALL}. {EMOJI['SETTINGS']} {translator.get('menu.config')}",
9: f"{Fore.GREEN}9{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.bypass_version_check', fallback='Bypass Cursor Version Check')}",
10: f"{Fore.GREEN}10{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.check_user_authorized', fallback='Check User Authorized')}",
11: f"{Fore.GREEN}11{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.bypass_token_limit', fallback='Bypass Token Limit')}",
12: f"{Fore.GREEN}12{Style.RESET_ALL}. {EMOJI['BACKUP']} {translator.get('menu.restore_machine_id', fallback='Restore Machine ID from Backup')}"
5: f"{Fore.GREEN}5{Style.RESET_ALL}. {EMOJI['SUN']} {translator.get('menu.register_google')}",
6: f"{Fore.GREEN}6{Style.RESET_ALL}. {EMOJI['STAR']} {translator.get('menu.register_github')}",
7: f"{Fore.GREEN}7{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.disable_auto_update')}",
8: f"{Fore.GREEN}8{Style.RESET_ALL}. {EMOJI['RESET']} {translator.get('menu.totally_reset')}",
9: f"{Fore.GREEN}9{Style.RESET_ALL}. {EMOJI['CONTRIBUTE']} {translator.get('menu.contribute')}",
10: f"{Fore.GREEN}10{Style.RESET_ALL}. {EMOJI['SETTINGS']} {translator.get('menu.config')}",
11: f"{Fore.GREEN}11{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.bypass_version_check')}",
12: f"{Fore.GREEN}12{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.check_user_authorized')}",
13: f"{Fore.GREEN}13{Style.RESET_ALL}. {EMOJI['UPDATE']} {translator.get('menu.bypass_token_limit')}",
14: f"{Fore.GREEN}14{Style.RESET_ALL}. {EMOJI['BACKUP']} {translator.get('menu.restore_machine_id')}",
15: f"{Fore.GREEN}15{Style.RESET_ALL}. {EMOJI['ERROR']} {translator.get('menu.delete_google_account')}",
16: f"{Fore.GREEN}16{Style.RESET_ALL}. {EMOJI['SETTINGS']} {translator.get('menu.select_chrome_profile')}"
}
# Automatically calculate the number of menu items in the left and right columns
@@ -496,31 +500,67 @@ def check_latest_version():
try:
print(f"\n{Fore.CYAN}{EMOJI['UPDATE']} {translator.get('updater.checking')}{Style.RESET_ALL}")
# Get latest version from GitHub API with timeout and proper headers
# First try GitHub API
headers = {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'CursorFreeVIP-Updater'
}
response = requests.get(
"https://api.github.com/repos/yeongpin/cursor-free-vip/releases/latest",
headers=headers,
timeout=10
)
# Check if rate limit exceeded
if response.status_code == 403 and "rate limit exceeded" in response.text.lower():
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('updater.rate_limit_exceeded', fallback='GitHub API rate limit exceeded. Skipping update check.')}{Style.RESET_ALL}")
return
latest_version = None
github_error = None
# Check if response is successful
if response.status_code != 200:
raise Exception(f"GitHub API returned status code {response.status_code}")
# Try GitHub API first
try:
github_response = requests.get(
"https://api.github.com/repos/yeongpin/cursor-free-vip/releases/latest",
headers=headers,
timeout=10
)
response_data = response.json()
if "tag_name" not in response_data:
raise Exception("No version tag found in GitHub response")
# Check if rate limit exceeded
if github_response.status_code == 403 and "rate limit exceeded" in github_response.text.lower():
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('updater.rate_limit_exceeded', fallback='GitHub API rate limit exceeded. Trying backup API...')}{Style.RESET_ALL}")
raise Exception("Rate limit exceeded")
# Check if response is successful
if github_response.status_code != 200:
raise Exception(f"GitHub API returned status code {github_response.status_code}")
github_data = github_response.json()
if "tag_name" not in github_data:
raise Exception("No version tag found in GitHub response")
latest_version = github_data["tag_name"].lstrip('v')
latest_version = response_data["tag_name"].lstrip('v')
except Exception as e:
github_error = str(e)
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('updater.github_api_failed', fallback='GitHub API failed, trying backup API...')}{Style.RESET_ALL}")
# If GitHub API fails, try backup API
try:
backup_headers = {
'Accept': 'application/json',
'User-Agent': 'CursorFreeVIP-Updater'
}
backup_response = requests.get(
"https://pinnumber.rr.nu/badges/release/yeongpin/cursor-free-vip",
headers=backup_headers,
timeout=10
)
# Check if response is successful
if backup_response.status_code != 200:
raise Exception(f"Backup API returned status code {backup_response.status_code}")
backup_data = backup_response.json()
if "message" not in backup_data:
raise Exception("No version tag found in backup API response")
latest_version = backup_data["message"].lstrip('v')
except Exception as backup_e:
# If both APIs fail, raise the original GitHub error
raise Exception(f"Both APIs failed. GitHub error: {github_error}, Backup error: {str(backup_e)}")
# Validate version format
if not latest_version:
@@ -670,7 +710,7 @@ def main():
while True:
try:
choice_num = 12
choice_num = 16
choice = input(f"\n{EMOJI['ARROW']} {Fore.CYAN}{translator.get('menu.input_choice', choices=f'0-{choice_num}')}: {Style.RESET_ALL}")
match choice:
@@ -695,38 +735,55 @@ def main():
print_menu()
continue
case "5":
from oauth_auth import main as oauth_main
oauth_main('google',translator)
print_menu()
case "6":
from oauth_auth import main as oauth_main
oauth_main('github',translator)
print_menu()
case "7":
import disable_auto_update
disable_auto_update.run(translator)
print_menu()
case "6":
case "8":
import totally_reset_cursor
totally_reset_cursor.run(translator)
# print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('menu.fixed_soon')}{Style.RESET_ALL}")
print_menu()
case "7":
case "9":
import logo
print(logo.CURSOR_CONTRIBUTORS)
print_menu()
case "8":
case "10":
from config import print_config
print_config(get_config(), translator)
print_menu()
case "9":
case "11":
import bypass_version
bypass_version.main(translator)
print_menu()
case "10":
case "12":
import check_user_authorized
check_user_authorized.main(translator)
print_menu()
case "11":
case "13":
import bypass_token_limit
bypass_token_limit.run(translator)
print_menu()
case "12":
case "14":
import restore_machine_id
restore_machine_id.run(translator)
print_menu()
case "15":
import delete_cursor_google
delete_cursor_google.main(translator)
print_menu()
case "16":
from oauth_auth import OAuthHandler
oauth = OAuthHandler(translator)
oauth._select_profile()
print_menu()
case _:
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('menu.invalid_choice')}{Style.RESET_ALL}")
print_menu()