From b1d9ad8c93b55202a63a108ecb8a2456974720da Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Tue, 17 Aug 2021 21:59:48 +0100 Subject: [PATCH] Fix normalised files being incorrectly named. --- file_manager.py | 9 ++++++--- helpers/normalisation.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/file_manager.py b/file_manager.py index c853f06..1e5e54f 100644 --- a/file_manager.py +++ b/file_manager.py @@ -83,6 +83,7 @@ class FileManager: self.logger.log.warning("Failed to remove, skipping. Likely file is still in use.") continue self.channel_received[channel] = True + self.known_channels_preloaded = [False]*self.channel_count # If we receive a new status message, let's check for files which have not been pre-loaded. if command == "STATUS": @@ -112,7 +113,7 @@ class FileManager: if (not preloaded and not normalised): # We didn't do any hard work, let's sleep. - sleep(0.5) + sleep(0.2) except Exception as e: self.logger.log.exception( @@ -181,8 +182,10 @@ class FileManager: if not filename: self.logger.log.exception("Somehow got empty filename when all channels are preloaded.") continue # Try next song. - - if "normalised" in filename: + elif (not os.path.isfile(filename)): + self.logger.log.exception("Filename for normalisation does not exist. This is bad.") + continue + elif "normalised" in filename: continue # Sweet, we now need to try generating a normalised version. try: diff --git a/helpers/normalisation.py b/helpers/normalisation.py index 9622c3a..b8eec49 100644 --- a/helpers/normalisation.py +++ b/helpers/normalisation.py @@ -16,7 +16,7 @@ def generate_normalised_file(filename: str): if filename.endswith("-normalised.mp3"): return filename - normalised_filename = "{}-normalised.mp3".format(filename.rstrip(".mp3")) + normalised_filename = "{}-normalised.mp3".format(filename.rsplit(".",1)[0]) # The file already exists, short circuit. if (os.path.exists(normalised_filename)):