Skip to content

Commit

Permalink
Add update checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Elip100 committed Jan 29, 2025
1 parent 1a8576c commit 1a54bf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 9 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tkinter import filedialog
from functools import partial
import os, keyboard, inject, json, time, platformdirs, sys, utils

import os, keyboard, inject, json, time, platformdirs, sys, utils, webbrowser
from colorama import Fore


spotify_path = platformdirs.user_data_dir(roaming=True) + "\Spotify"
Expand All @@ -27,7 +27,12 @@ def main():
def main_menu():
while True:
utils.clear()
option_list(["Add mod", "Manage mods", "Uninstall SpotMod", "Quit"], [add_mod, manage_mods, uninstall, quit])
option_list(
["Add mod", "Manage mods", "Uninstall SpotMod", "Quit",
f"{Fore.BLUE}Update SpotMod Injector{Fore.GREEN}" if utils.check_for_update() else None],
[add_mod, manage_mods, uninstall, quit,
partial(webbrowser.open, "https://github.com/Elip100/SpotMod/releases") if utils.check_for_update() else None]
)

def add_mod():
utils.clear()
Expand Down Expand Up @@ -99,7 +104,7 @@ def uninstall():
def option_list(itemlist, calllist = None, prompt_text = "Please choose an option:"):
print(prompt_text)
for item in itemlist:
print(f"{itemlist.index(item) + 1}) {item}")
if item is not None: print(f"{itemlist.index(item) + 1}) {item}")
while True:
wait_for_no_keys()
key = keyboard.read_event().name
Expand Down
11 changes: 9 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from colorama import Fore, Style, Back
import platform, os
import platform, os, requests, json

version = 0.3
operating_system = platform.system()

def clear():
os.system("cls" if operating_system == "Windows" else "clear")
print(f"{Back.GREEN}{Fore.BLACK} SpotMod Patcher v{str(version)} {Style.RESET_ALL}{Fore.GREEN}\n")
print(f"{Back.GREEN}{Fore.BLACK} SpotMod Patcher v{str(version)} {Style.RESET_ALL}{Fore.GREEN}\n")

def check_for_update():
try:
response = requests.get("https://elip100.github.io/SpotMod/data.json")
return response.json()["latest_version"] > version
except:
return False

0 comments on commit 1a54bf0

Please sign in to comment.