Commit 0008ba29 authored by Buxdehuda's avatar Buxdehuda

Cache version tags

parent c6b76602
Pipeline #45652769 passed with stage
in 11 minutes and 20 seconds
......@@ -27,3 +27,4 @@ pages:
- fdroid
- cache
......@@ -11,6 +11,7 @@ Add new download information in [apks.json](apks.json):
"name": "App",
"baseUrl": "{ver}-{arch}.apk",
"architectures": ["arm", "x86"],
"version": {
......@@ -21,7 +22,7 @@ Add new download information in [apks.json](apks.json):
Everything except `baseUrl` is optional.
Everything except `name` and `baseUrl` is optional.
`{ver}` and `{arch}` will get automatically replaced with the corresponding version and all architectures.
Note that you can use a single `regex` string instead of `json` to query the version.
"name": "Firefox",
"baseUrl": "{arch}&lang=multi",
"architectures": ["", "-x86"]
"name": "Firefox Beta",
"baseUrl": "{arch}&lang=multi",
"architectures": ["", "-x86"],
"ignoreErrors": true
"name": "Firefox Focus",
"baseUrl": "{arch}.apk",
"architectures": ["arm", "x86"]
"name": "Firefox Klar",
"baseUrl": "{arch}.apk",
"architectures": ["arm", "x86"]
"name": "Brave",
"baseUrl": "{ver}/Brave{arch}.apk",
"architectures": ["arm", "x86"],
"version": {
\ No newline at end of file
import json
import os
import re
import requests
import subprocess
......@@ -7,7 +6,8 @@ import subprocess
def main():
with open("apks.json") as file:
apks = json.load(file)
with open("cache/versions.json") as file:
versions = json.load(file)
for apk in apks:
ver = ""
ignore = False
......@@ -17,6 +17,9 @@ def main():
ver = get_version_json(verObj["url"], verObj["json"])
elif "regex" in verObj:
ver = get_version_regex(verObj["url"], verObj["regex"])
if apk["name"] in versions and ver == versions[apk["name"]]:
versions[apk["name"]] = ver
if "ignoreErrors" in apk:
ignore = apk["ignoreErrors"]
if "architectures" in apk:
......@@ -24,12 +27,14 @@ def main():
download(apk["baseUrl"].format(arch=arch, ver=ver), ignore)
download(apk["baseUrl"].format(ver=ver), ignore)
with open('cache/versions.json', 'w') as file:
json.dump(versions, file, ensure_ascii=False)
def download(download_url, ignore):
if download_url.endswith(".apk"):
retcode =["wget", "-N", download_url])
retcode =["wget", "-N", "-P", "fdroid/repo", download_url])
retcode =["wget", "-nc", "--content-disposition", download_url])
retcode =["wget", "-nc", "--content-disposition", "-P", "fdroid/repo", download_url])
if not ignore and retcode != 0:
raise Exception("Failed downloading " + download_url)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment