From 0230bf260bed52fb1b2607862e25629251ecaa9c Mon Sep 17 00:00:00 2001 From: "Maxence G. de Montauzan" Date: Sun, 5 Sep 2021 02:13:47 +0200 Subject: [PATCH] Process suggestion according to option --- send_data.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/send_data.py b/send_data.py index 356f679..8064356 100644 --- a/send_data.py +++ b/send_data.py @@ -152,18 +152,24 @@ def main(): if args.ALL or args.no_suggest: print("Process suggestion:") if args.DELETE: # TODO Do a method? - mapping_suggest = load_file(args.mapping_suggest, DEFAULT_MAPPING_SUGGEST_FILE) - if not args.quiet: - print("Mapping of suggest index file: '{}'".format(mapping_suggest.name)) - delete_index(SUGGEST_INDEX, args.quiet) - put_mapping(SUGGEST_INDEX, mapping_suggest, args.quiet) - suggs_docs = 0 - suggs_docs += process_file('/home/budd/workspace/iTunes/es-albums.json', 'Album') - print('Created documents: ' + str(suggs_docs)) - suggs_docs += process_file('/home/budd/workspace/iTunes/es-artists.json', 'Artist', 'Album Artist') - print('Created documents: ' + str(suggs_docs)) + if not args.ALL and not args.album_file and not args.artist_file: + print('Only song file processed. No suggestion to process.') + else: + if args.DELETE: + mapping_suggest = load_file(args.mapping_suggest, DEFAULT_MAPPING_SUGGEST_FILE) + if not args.quiet: + print("Mapping of suggest index file: '{}'".format(mapping_suggest.name)) + put_mapping(SUGGEST_INDEX, mapping_suggest, args.quiet) + + suggs_docs = 0 + if args.album_file or args.ALL: + suggs_docs += process_file(DEFAULT_ALBUM_FILE, 'Album') + print('Created suggestion documents: ' + str(suggs_docs)) + if args.artist_file or args.ALL: + suggs_docs += process_file(DEFAULT_ARTIST_FILE, 'Artist', 'Album Artist') + print('Created suggestion documents: ' + str(suggs_docs)) print("I'm done!") if check_is_ok.count(False) > 0: