From bbd3b198837d538b28f9f89b884cec564fe12ea0 Mon Sep 17 00:00:00 2001 From: quintenvandamme Date: Tue, 10 Sep 2024 19:30:46 +0200 Subject: [PATCH] fix api error --- nothing.json | 18 ++++++++++++++++++ tools/gen_api.py | 34 ++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/nothing.json b/nothing.json index 004d507..27744fd 100644 --- a/nothing.json +++ b/nothing.json @@ -1,6 +1,24 @@ [ { "nothing_phone_1": { + "2.6_hotfix": { + "name": "2.6 hotfix", + "build_number": "Spacewar-U2.6-240904-1634", + "changelog": "", + "ota": [ + { + "type": "incremental", + "region": [ + "eea", + "global" + ], + "variant": [], + "post_version": "2.6_hotfix", + "pre_version": "2.6", + "url": "https://archive.org/download/nothing-phone-1-firmware/2.6%20hotfix/159a36df32499e2153475db11ef1f6b8775770f2.zip" + } + ] + }, "2.6": { "name": "2.6", "build_number": "Spacewar-U2.6-240705-1617", diff --git a/tools/gen_api.py b/tools/gen_api.py index 088fab8..00046a2 100644 --- a/tools/gen_api.py +++ b/tools/gen_api.py @@ -29,9 +29,9 @@ def get_tables_of_data(data): # If the last table reaches the end of the file without a break, add it if current_table: tables.append(current_table) - + return tables - + def parse_tabledata(data): @@ -61,16 +61,16 @@ def parse_tabledata(data): parsedTabel[list(parsedTabel.keys())[i]].append(cell) - + parsedTables.append(parsedTabel) - + return parsedTables def convert_table_to_json(table): json = {} model = table['model'] json[model] = {} - + for phoneTable in table['tables']: keys = list(phoneTable.keys()) @@ -82,7 +82,7 @@ def convert_table_to_json(table): if version not in json[model]: json[model][version] = {} - + # generate a clear version name if "name" not in keys: json[model][version]["name"] = version.replace("_", " ") @@ -93,10 +93,12 @@ def convert_table_to_json(table): build_number = phoneTable["build number"][row] if build_number not in json[model][version]: json[model][version]["build_number"] = build_number - + if "changelog" in keys: if row < len(phoneTable["changelog"]): - changelog = phoneTable["changelog"][row].split("")[1].split("")[0] + changelog = '' + if "" in phoneTable["changelog"][row]: + changelog = phoneTable["changelog"][row].split("")[1].split("")[0] if "changelog" not in json[model][version]: json[model][version]["changelog"] = changelog @@ -168,7 +170,7 @@ def convert_table_to_json(table): if region[0] == "allregions" or region[0] == "allregions": region[0] = "eea" region.append("global") - + for r in region: if r != "all" and r != "eea" and r != "global": variant.append(r) @@ -192,7 +194,7 @@ def convert_table_to_json(table): json[model][version]["ota"].append(data) except: pass - + # check if there is a key "rollback" in the table if "rollback" in keys: @@ -239,7 +241,7 @@ def convert_table_to_json(table): if "boot file (stock)" in keys: if row < len(phoneTable["boot file (stock)"]): - boot_file = phoneTable["boot file (stock)"][row] + boot_file = phoneTable["boot file (stock)"][row] if boot_file not in json[model][version]: try: url = boot_file.split("](")[1].split(")")[0] @@ -258,7 +260,7 @@ def convert_table_to_json(table): if "boot file (magisk patched)" in keys: if row < len(phoneTable["boot file (magisk patched)"]): - boot_file = phoneTable["boot file (magisk patched)"][row] + boot_file = phoneTable["boot file (magisk patched)"][row] if boot_file not in json[model][version]: try: url = boot_file.split("](")[1].split(")")[0] @@ -274,7 +276,7 @@ def convert_table_to_json(table): json[model][version]["boot"].append(data) except: pass - + return json def main(): @@ -309,8 +311,8 @@ def main(): parsedJson.append(jsonData) write_file('nothing.json', json.dumps(parsedJson, indent=4)) - - + + if __name__ == '__main__': - main() \ No newline at end of file + main()