diff --git a/lb_import.py b/lb_import.py index 09f6f15..75d57b8 100755 --- a/lb_import.py +++ b/lb_import.py @@ -47,19 +47,24 @@ def main(): client = connect_client(sys.argv[1]) with open(sys.argv[2], 'r') as read_file: exported = json.load(read_file) - print("Opened file, starting import...") + print("Opened file with {} listens, starting import...".format(len(exported))) + imported = 0 for raw_listen in exported: listen = parse_listen(raw_listen) for x in range(0, 5): try: client.submit_single_listen(listen) + imported = imported + 1 + print("Imported {} listens.".format(imported), end='\r') submit_error = None except BaseException: submit_error = True if submit_error: - print("Error occurred, retrying in 5 seconds...") - sleep(5) + sleep_time = x * 5 + print( + "\nError occurred, retrying in {} seconds...".format(sleep_time)) + sleep(sleep_time) else: break