From 54d3336aa2453f017045c84f9d4e7575a027d9aa Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Sun, 13 Jan 2019 18:19:06 +0530 Subject: [PATCH 1/3] Fix renaming files when encoder is not present --- spotdl/convert.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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)) From 31cd1c5856e3194f5d3d2c8bdf150b07d6fb82f3 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Sun, 13 Jan 2019 18:19:38 +0530 Subject: [PATCH 2/3] Move 'encoder not found' warning to more appropriate place --- spotdl/downloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From f078875f0ea00a16bf0fcef72a04bd64b964c423 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Sun, 13 Jan 2019 18:32:48 +0530 Subject: [PATCH 3/3] Update CHANGES.md --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 825d65e..4306843 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### 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)