diff --git a/CHANGES.md b/CHANGES.md index 53932ff..a6891ab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,10 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] - ### Changed - Option `-f` (`--folder`) is used when exporting text files using `-p` (`--playlist`) for playlists or `-b` (`--album`) for albums ([@Silverfeelin](https://github.com/Silverfeelin)) (#476) +### Fixed +- Fix renaming files when encoder is not found ([@ritiek](https://github.com/ritiek)) (#475) + ## [1.1.1] - 2019-01-03 ### Added - Output informative message in case of no result found in YouTube search ([@Amit-L](https://github.com/Amit-L)) (#452) diff --git a/spotdl/convert.py b/spotdl/convert.py index 2edf30a..7421cf9 100644 --- a/spotdl/convert.py +++ b/spotdl/convert.py @@ -83,7 +83,12 @@ class Converter: os.rename(self.output_file, self.input_file) log.debug(command) - code = subprocess.call(command) + try: + code = subprocess.call(command) + except FileNotFoundError: + if self.rename_to_temp: + os.rename(self.input_file, self.output_file) + raise if self.delete_original: log.debug('Removing original file: "{}"'.format(self.input_file)) @@ -134,7 +139,12 @@ class Converter: os.rename(self.output_file, self.input_file) log.debug(command) - code = subprocess.call(command) + try: + code = subprocess.call(command) + except FileNotFoundError: + if self.rename_to_temp: + os.rename(self.input_file, self.output_file) + raise if self.delete_original: log.debug('Removing original file: "{}"'.format(self.input_file)) diff --git a/spotdl/downloader.py b/spotdl/downloader.py index be6fcc3..8e8c243 100644 --- a/spotdl/downloader.py +++ b/spotdl/downloader.py @@ -131,6 +131,8 @@ class Downloader: trim_silence=const.args.trim_silence, ) except FileNotFoundError: + encoder = "avconv" if const.args.avconv else "ffmpeg" + log.warning("Could not find {0}, skip encoding".format(encoder)) output_song = self.unconverted_filename(songname) if not const.args.no_metadata and self.meta_tags is not None: @@ -169,8 +171,6 @@ class Downloader: @staticmethod def unconverted_filename(songname): - encoder = "avconv" if const.args.avconv else "ffmpeg" - log.warning("Could not find {0}, skipping conversion".format(encoder)) const.args.output_ext = const.args.input_ext output_song = songname + const.args.output_ext return output_song