mirror of
https://github.com/cucumber-sp/yandex-music-linux.git
synced 2024-12-23 22:22:59 +03:00
Merge pull request #105 from byBenPuls/master
This commit is contained in:
commit
8d7a26f3f3
@ -1,5 +1,5 @@
|
|||||||
import sys
|
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 3:
|
||||||
print("Usage: python extract_release_notes.py <file_name>")
|
print("Usage: python extract_release_notes.py <file_name>")
|
||||||
@ -7,7 +7,8 @@ if len(sys.argv) < 3:
|
|||||||
|
|
||||||
file_name = sys.argv[1]
|
file_name = sys.argv[1]
|
||||||
save_file_name = sys.argv[2]
|
save_file_name = sys.argv[2]
|
||||||
|
|
||||||
|
|
||||||
def build_html(data, first_launch=False):
|
def build_html(data, first_launch=False):
|
||||||
html = ""
|
html = ""
|
||||||
for i, element in enumerate(data):
|
for i, element in enumerate(data):
|
||||||
@ -23,6 +24,7 @@ def build_html(data, first_launch=False):
|
|||||||
html += f"<{element['value']}>{build_html(element['children'])}</{element['value']}>"
|
html += f"<{element['value']}>{build_html(element['children'])}</{element['value']}>"
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
with open(file_name, "r", encoding='utf-8') as file:
|
with open(file_name, "r", encoding='utf-8') as file:
|
||||||
translation = json.load(file)
|
translation = json.load(file)
|
||||||
|
|
||||||
@ -34,4 +36,4 @@ for element_key in translation.keys():
|
|||||||
notes[element_key] = build_html(translation[element_key], True)
|
notes[element_key] = build_html(translation[element_key], True)
|
||||||
|
|
||||||
with open(save_file_name, "w", encoding='utf-8') as file:
|
with open(save_file_name, "w", encoding='utf-8') as file:
|
||||||
file.write(json.dumps(notes, ensure_ascii=False, indent=4))
|
file.write(json.dumps(notes, ensure_ascii=False, indent=4))
|
||||||
|
@ -3,12 +3,14 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def check_dependency(dependency):
|
def check_dependency(dependency):
|
||||||
if shutil.which(dependency):
|
if shutil.which(dependency):
|
||||||
return True
|
return True
|
||||||
print(f"{dependency} not installed.")
|
print(f"{dependency} not installed.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
# loading versions information from json
|
# loading versions information from json
|
||||||
@ -16,6 +18,7 @@ version_info_path = os.path.join(script_dir, "version_info.json")
|
|||||||
with open(version_info_path, "r") as f:
|
with open(version_info_path, "r") as f:
|
||||||
version_info = json.load(f)
|
version_info = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
# Arch
|
# Arch
|
||||||
def generate_arch():
|
def generate_arch():
|
||||||
pkgbuild_template = os.path.join(script_dir, "../templates/PKGBUILD")
|
pkgbuild_template = os.path.join(script_dir, "../templates/PKGBUILD")
|
||||||
@ -35,7 +38,7 @@ def generate_arch():
|
|||||||
|
|
||||||
|
|
||||||
# Nix
|
# Nix
|
||||||
|
|
||||||
def is_nix_version_2_19():
|
def is_nix_version_2_19():
|
||||||
version = subprocess.run(["nix", "--version"], capture_output=True, text=True).stdout.split()[2]
|
version = subprocess.run(["nix", "--version"], capture_output=True, text=True).stdout.split()[2]
|
||||||
print(f"Nix version: {version}")
|
print(f"Nix version: {version}")
|
||||||
@ -44,6 +47,7 @@ def is_nix_version_2_19():
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def generate_nix():
|
def generate_nix():
|
||||||
nixcmd = "nix --extra-experimental-features nix-command --extra-experimental-features flakes"
|
nixcmd = "nix --extra-experimental-features nix-command --extra-experimental-features flakes"
|
||||||
flake_path = os.path.join(script_dir, "../flake.nix")
|
flake_path = os.path.join(script_dir, "../flake.nix")
|
||||||
@ -53,14 +57,14 @@ def generate_nix():
|
|||||||
flake = f.read()
|
flake = f.read()
|
||||||
_start_index = flake.find("ymExe.url = ")
|
_start_index = flake.find("ymExe.url = ")
|
||||||
_end_index = flake.find(";", _start_index)
|
_end_index = flake.find(";", _start_index)
|
||||||
flake = flake.replace(flake[_start_index:_end_index+1], f'ymExe.url = "{version_info["ym"]["exe_link"]}";')
|
flake = flake.replace(flake[_start_index:_end_index + 1], f'ymExe.url = "{version_info["ym"]["exe_link"]}";')
|
||||||
with open(flake_path, "w") as f:
|
with open(flake_path, "w") as f:
|
||||||
f.write(flake)
|
f.write(flake)
|
||||||
|
|
||||||
if not check_dependency("nix"):
|
if not check_dependency("nix"):
|
||||||
print("flake.nix was updated, but nix is not installed to update flake.lock")
|
print("flake.nix was updated, but nix is not installed to update flake.lock")
|
||||||
return
|
return
|
||||||
|
|
||||||
if is_nix_version_2_19():
|
if is_nix_version_2_19():
|
||||||
subprocess.run(f"{nixcmd} flake update ymExe", shell=True)
|
subprocess.run(f"{nixcmd} flake update ymExe", shell=True)
|
||||||
else:
|
else:
|
||||||
@ -71,4 +75,4 @@ def generate_nix():
|
|||||||
|
|
||||||
|
|
||||||
generate_arch()
|
generate_arch()
|
||||||
generate_nix()
|
generate_nix()
|
||||||
|
@ -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"]
|
||||||
@ -74,4 +79,4 @@ version_file = os.path.join(script_dir, "version_info.json")
|
|||||||
with open(version_file, "w") as f:
|
with open(version_file, "w") as f:
|
||||||
f.write(json.dumps(version_info, indent=4))
|
f.write(json.dumps(version_info, indent=4))
|
||||||
|
|
||||||
print(f"Version info written to {version_file}")
|
print(f"Version info written to {version_file}")
|
||||||
|
Loading…
Reference in New Issue
Block a user