Skip to content

Commit

Permalink
fix #24 + improve version check
Browse files Browse the repository at this point in the history
  • Loading branch information
FozerG committed May 19, 2024
1 parent 9ae0394 commit 59253d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
28 changes: 18 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import win32gui, win32con, win32console
import subprocess
from colorama import init, Fore, Style

from packaging import version
# Идентификатор клиента Discord для Rich Presence
CLIENT_ID = '978995592736944188'

# Версия (tag) скрипта для проверки на актуальность через Github Releases
CURRENT_VERSION = "v1.9"
CURRENT_VERSION = "v1.9.1"

# Ссылка на репозиторий
REPO_URL = "https://github.com/FozerG/WinYandexMusicRPC"
Expand Down Expand Up @@ -299,10 +299,13 @@ def GetLastVersion(repoUrl):
response = requests.get(repoUrl + '/releases/latest', timeout=5)
response.raise_for_status()
latest_version = response.url.split('/')[-1]
if CURRENT_VERSION != latest_version:

if version.parse(CURRENT_VERSION) < version.parse(latest_version):
log(f"A new version has been released on GitHub. You are using - {CURRENT_VERSION}. A new version - {latest_version}, you can download it at {repoUrl + '/releases/tag/' + latest_version}", LogType.Notification)
else:
elif version.parse(CURRENT_VERSION) == version.parse(latest_version):
log(f"You are using the latest version of the script")
else:
log(f"You are using the beta version of the script", LogType.Notification)

except requests.exceptions.RequestException as e:
log(f"Error getting latest version: {e}", LogType.Error)
Expand Down Expand Up @@ -345,13 +348,18 @@ def Is_already_running():
return True
return False

def Is_windows_11():
return sys.getwindowsversion().build >= 22000


def Check_conhost():
if '--run-through-conhost' not in sys.argv: # Запущен ли скрипт уже через conhost
print("Wait a few seconds for the script to load.")
script_path = os.path.abspath(sys.argv[0])
subprocess.Popen(['cmd', '/c', 'start','/min', 'conhost.exe', script_path, '--run-through-conhost'] + sys.argv[1:])
time.sleep(2)
sys.exit()
if Is_windows_11(): #Windows 11 имеет неудобную консоль, которую нельзя свернуть в трей, поэтому мы используем conhost
if '--run-through-conhost' not in sys.argv: # Запущен ли скрипт уже через conhost
print("Wait a few seconds for the script to load.")
script_path = os.path.abspath(sys.argv[0])
subprocess.Popen(['start', '/min', 'conhost.exe', script_path, '--run-through-conhost'] + sys.argv[1:], shell=True)
time.sleep(2)
sys.exit()

def Disable_close_button():
hwnd = win32console.GetConsoleWindow()
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Pillow
winsdk
yandex-music
colorama
pywin32
pywin32
packaging

0 comments on commit 59253d2

Please sign in to comment.