diff --git a/anda/apps/authy/update.rhai b/anda/apps/authy/update.rhai index da60fa1e1a..8bd41d377b 100644 --- a/anda/apps/authy/update.rhai +++ b/anda/apps/authy/update.rhai @@ -1,7 +1,5 @@ let req = new_req("https://api.snapcraft.io/v2/snaps/info/authy"); req.head("Snap-Device-Series", "16"); -let obj = json(req.get()); -let obj2 = get_json(obj, "channel-map"); -let obj3 = get_json(obj2, 0); -rpm.version(string_json(get_json(obj3, "version"))); -rpm.source(0, string_json(obj3.get_json("download").get_json("url"))); +let obj = json(req.get()) @ "channel-map" @ 0; +rpm.version(str(obj @ "version")); +rpm.source(0, str(obj @ "download" @ "url")); diff --git a/anda/discord-canary/chkupdate.py b/anda/discord-canary/chkupdate.py deleted file mode 100644 index 888eedea39..0000000000 --- a/anda/discord-canary/chkupdate.py +++ /dev/null @@ -1,38 +0,0 @@ -import os -import re -from requests import get - - -NAME = 'discord-canary' -SPEC = f'{NAME}.spec' -REGEX = r'Version:(\s+)([\.\d]+)\n' -REGEX_LINK = r'https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/' -LINK = 'https://discordapp.com/api/download/canary?platform=linux&format=tar.gz' - - -def run_cmds(*cmds: str): - for cmd in cmds: - print(f"{NAME}: $ {cmd}") - if rc := os.system(cmd): - exit(f"{NAME}: Stopping because {rc=}") - -html = get(LINK, allow_redirects=False).text -newver = re.findall(REGEX_LINK, html) -if not any(newver): - exit(f"{NAME}: Failed to parse html!") -newver = newver[0] - -f = open(SPEC, 'r') -content = f.read() -found = re.findall(REGEX, content) -try: - assert found - curver = found[0][1] - if newver == curver: - exit(f"{NAME}: Up to date!") - else: - print(f"{NAME}: {curver} -> {newver}") -except IndexError or AssertionError: - exit(f"{NAME}: Failed to read spec!") - -run_cmds(f'rpmdev-bumpspec -n {newver} {SPEC}') diff --git a/anda/discord-canary/update.rhai b/anda/discord-canary/update.rhai new file mode 100644 index 0000000000..f08ae6ec42 --- /dev/null +++ b/anda/discord-canary/update.rhai @@ -0,0 +1,3 @@ +let html = get("https://discordapp.com/api/download/canary?platform=linux&format=tar.gz"); +let newver = str(find("https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/", html, 1) @ 0); +rpm.version(newver); \ No newline at end of file diff --git a/anda/discord-ptb/chkupdate.py b/anda/discord-ptb/chkupdate.py deleted file mode 100644 index 034d8e65e3..0000000000 --- a/anda/discord-ptb/chkupdate.py +++ /dev/null @@ -1,38 +0,0 @@ -import os -import re -from requests import get - - -NAME = 'discord-ptb' -SPEC = f'{NAME}.spec' -REGEX = r'Version:(\s+)([\.\d]+)\n' -REGEX_LINK = r'https://dl-ptb\.discordapp\.net/apps/linux/([\.\d]+)/' -LINK = 'https://discordapp.com/api/download/ptb?platform=linux&format=tar.gz' - - -def run_cmds(*cmds: str): - for cmd in cmds: - print(f"{NAME}: $ {cmd}") - if rc := os.system(cmd): - exit(f"{NAME}: Stopping because {rc=}") - -html = get(LINK, allow_redirects=False).text -newver = re.findall(REGEX_LINK, html) -if not any(newver): - exit(f"{NAME}: Failed to parse html!") -newver = newver[0] - -f = open(SPEC, 'r') -content = f.read() -found = re.findall(REGEX, content) -try: - assert found - curver = found[0][1] - if newver == curver: - exit(f"{NAME}: Up to date!") - else: - print(f"{NAME}: {curver} -> {newver}") -except IndexError or AssertionError: - exit(f"{NAME}: Failed to read spec!") - -run_cmds(f'rpmdev-bumpspec -n {newver} {SPEC}') diff --git a/anda/discord-ptb/update.rhai b/anda/discord-ptb/update.rhai new file mode 100644 index 0000000000..79b2837807 --- /dev/null +++ b/anda/discord-ptb/update.rhai @@ -0,0 +1,3 @@ +let html = get("https://discordapp.com/api/download/ptb?platform=linux&format=tar.gz"); +let newver = str(find("https://dl-ptb\.discordapp\.net/apps/linux/([\.\d]+)/", html, 1) @ 0); +rpm.version(newver); \ No newline at end of file diff --git a/anda/games/prismlauncher-nightly/chkupdate.py b/anda/games/prismlauncher-nightly/chkupdate.py deleted file mode 100644 index cd71aa2b02..0000000000 --- a/anda/games/prismlauncher-nightly/chkupdate.py +++ /dev/null @@ -1,26 +0,0 @@ -import requests, re, os -from datetime import datetime - - -NAME = 'prismlauncher-nightly' -REPO = "PrismLauncher/PrismLauncher" -REGEX_SHA = r'%global commit (.+)' -SPEC = f"{NAME}.spec" -LINK = f'https://api.github.com/repos/{REPO}/commits/HEAD' - -sha = requests.get(LINK, headers={'Authorization': 'Bearer ' + os.getenv('GITHUB_TOKEN')}).json()['sha'] -f = open(SPEC, 'r') - -matches = re.findall(REGEX_SHA, txt:=f.read()) -if not len(matches): exit(f"{NAME}: Failed to match regex!") -cur = matches[0] - -if sha == cur: exit(f'{NAME}: Up to date!') -print(f'{NAME}: {cur} -> {sha}') - -newspec = re.sub(REGEX_SHA, f'%global commit {sha}', txt) - -f.close() -f = open(SPEC, 'w') -f.write(newspec) -f.close() diff --git a/anda/games/prismlauncher-nightly/update.rhai b/anda/games/prismlauncher-nightly/update.rhai new file mode 100644 index 0000000000..f301715b1c --- /dev/null +++ b/anda/games/prismlauncher-nightly/update.rhai @@ -0,0 +1,11 @@ +let req = new_req("https://api.github.com/repos/PrismLauncher/PrismLauncher/commits/HEAD"); +req.head("Authorization", `Bearer ${env("GITHUB_TOKEN")}`); +let _sha = json(req.get()) @ "sha"; +let sha = _sha.str(); +let cur = find("%global commit (.+)", rpm.f, 1); +if sha != cur { + print(`prismlauncher-nightly: ${cur} -> ${sha}`); + rpm.f = sub("%global commit (.+)", `%global commit ${sha}`, rpm.f); +} else { + print("prismlauncher-nightly: Up to date!"); +} \ No newline at end of file diff --git a/anda/games/prismlauncher-qt5-nightly/chkupdate.py b/anda/games/prismlauncher-qt5-nightly/chkupdate.py deleted file mode 100644 index bef6b46610..0000000000 --- a/anda/games/prismlauncher-qt5-nightly/chkupdate.py +++ /dev/null @@ -1,26 +0,0 @@ -import requests, re, os -from datetime import datetime - - -NAME = 'prismlauncher-qt5-nightly' -REPO = "PrismLauncher/PrismLauncher" -REGEX_SHA = r'%global commit (.+)' -SPEC = f"{NAME}.spec" -LINK = f'https://api.github.com/repos/{REPO}/commits/HEAD' - -sha = requests.get(LINK, headers={'Authorization': 'Bearer ' + os.getenv('GITHUB_TOKEN')}).json()['sha'] -f = open(SPEC, 'r') - -matches = re.findall(REGEX_SHA, txt:=f.read()) -if not len(matches): exit(f"{NAME}: Failed to match regex!") -cur = matches[0] - -if sha == cur: exit(f'{NAME}: Up to date!') -print(f'{NAME}: {cur} -> {sha}') - -newspec = re.sub(REGEX_SHA, f'%global commit {sha}', txt) - -f.close() -f = open(SPEC, 'w') -f.write(newspec) -f.close() diff --git a/anda/games/prismlauncher-qt5-nightly/update.rhai b/anda/games/prismlauncher-qt5-nightly/update.rhai new file mode 100644 index 0000000000..e286451e63 --- /dev/null +++ b/anda/games/prismlauncher-qt5-nightly/update.rhai @@ -0,0 +1,11 @@ +let req = new_req("https://api.github.com/repos/PrismLauncher/PrismLauncher/commits/HEAD"); +req.head("Authorization", `Bearer ${env("GITHUB_TOKEN")}`); +let _sha = json(req.get()) @ "sha"; +let sha = _sha.str(); +let cur = find("%global commit (.+)", rpm.f, 1); +if sha != cur { + print(`prismlauncher-qt5-nightly: ${cur} -> ${sha}`); + rpm.f = sub("%global commit (.+)", `%global commit ${sha}`, rpm.f); +} else { + print("prismlauncher-qt5-nightly: Up to date!"); +} \ No newline at end of file