import json from client.ApolloClient import ApolloClient client = ApolloClient("http://apolloconfig-internal.piaoquantv.com") def main(): config_str = client.get_value( app_id="crawler-scheduler", cluster="default", namespace="application", key="hot.video.keywords.provide.task.config" ) new_config_json = {} config_json = json.loads(config_str) account_filters = config_json['accountFilterMap'] content_filters = config_json['contentFilterMap'] pre_filter_threshold = config_json['preFilterThreshold'] prompt_id = config_json['promptId'] model_value_config = config_json['modelValueConfig'] for merge_cate2 in config_json['mergeCate2PatternPlanIdMap']: type_json = config_json['mergeCate2PatternPlanIdMap'][merge_cate2] if merge_cate2 not in new_config_json: new_config_json[merge_cate2] = {} for produce_type in type_json: produce_plan_ids = type_json[produce_type] new_config_json[merge_cate2][produce_type] = { "accountFilters": account_filters, "contentFilters": content_filters, "preFilterThreshold": pre_filter_threshold, "promptId": prompt_id, "modelValueConfig": model_value_config, "producePlanIds": produce_plan_ids } print(json.dumps(new_config_json, indent=4, ensure_ascii=False)) if __name__ == '__main__': main()