From d80e62cf2b0b6e37f62377521c91a17f74fb5088 Mon Sep 17 00:00:00 2001 From: relikd Date: Wed, 23 Sep 2020 19:16:15 +0200 Subject: [PATCH] Delete app names --- src/common_lib.py | 3 +++ src/index_app_names.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/common_lib.py b/src/common_lib.py index 407b353..7464086 100755 --- a/src/common_lib.py +++ b/src/common_lib.py @@ -272,11 +272,14 @@ def appids_in_data(selection=['*']): # JSON def try_del(index, keys): + did_change = False for x in keys: try: del(index[x]) + did_change = True except KeyError: pass + return did_change def json_read(path): diff --git a/src/index_app_names.py b/src/index_app_names.py index 9da7439..0ed96ff 100755 --- a/src/index_app_names.py +++ b/src/index_app_names.py @@ -39,7 +39,7 @@ def get_name(bundle_id, langs=['us', 'de'], fallback='< App-Name >'): return fallback # None -def process(bundle_ids): +def process(bundle_ids, deleteOnly=False): print('writing index: app names ...') if bundle_ids == ['*']: print(' full reset') @@ -48,13 +48,22 @@ def process(bundle_ids): load_json_if_not_already() did_change = False for bid in mylib.appids_in_data(bundle_ids): + if deleteOnly: + did_change |= mylib.try_del(_bundle_name_dict, [bid]) + continue names = download_itunes.get_app_names(bid) if not names: mylib.err('index-app-names', 'could not load: {}'.format(bid)) continue + try: + if _bundle_name_dict[bid] == names: + continue + except KeyError: + pass _bundle_name_dict[bid] = names did_change = True if did_change: + print(' writing') write_json_to_disk() else: print(' no change') @@ -66,5 +75,5 @@ if __name__ == '__main__': if len(args) > 0: process(args) else: - # process(['*']) + # process(['*'], deleteOnly=False) mylib.usage(__file__, '[bundle_id] [...]')