Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix renaming files when encoder is not found #475

Merged
merged 4 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions spotdl/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ def with_avconv(self):
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))
Expand Down Expand Up @@ -134,7 +139,12 @@ def with_ffmpeg(self, trim_silence=False):
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))
Expand Down
4 changes: 2 additions & 2 deletions spotdl/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def _download_single(self, songname):
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:
Expand Down Expand Up @@ -169,8 +171,6 @@ def refine_songname(self, songname):

@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
Expand Down