0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2024-12-24 14:34:39 +03:00

Refactor code and sorting imports

This commit is contained in:
Ben Puls 2024-08-29 18:56:28 +05:00
parent f6f00319ed
commit b8643efe29

View File

@ -4,6 +4,7 @@ import json
import os import os
import shutil import shutil
import tempfile import tempfile
import requests import requests
YM_VERSIONS_URL = "https://music-desktop-application.s3.yandex.net/stable/download.json" YM_VERSIONS_URL = "https://music-desktop-application.s3.yandex.net/stable/download.json"
@ -13,17 +14,21 @@ ELECTRON_DOWNLOAD_URL = "https://github.com/electron/electron/releases/download/
script_dir = os.path.dirname(os.path.realpath(__file__)) script_dir = os.path.dirname(os.path.realpath(__file__))
tempdir = tempfile.mkdtemp() tempdir = tempfile.mkdtemp()
def clear(): def clear():
shutil.rmtree(tempdir) shutil.rmtree(tempdir)
atexit.register(clear) atexit.register(clear)
def assert_dependency(dependency): def assert_dependency(dependency):
if shutil.which(dependency): if shutil.which(dependency):
return return
print(f"{dependency} not installed.") print(f"{dependency} not installed.")
exit(1) exit(1)
# loading versions json # loading versions json
versions_obj = requests.get(YM_VERSIONS_URL).json() versions_obj = requests.get(YM_VERSIONS_URL).json()
exe_link = versions_obj["windows"] exe_link = versions_obj["windows"]