diff --git a/.gitignore b/.gitignore index 313ef51..99e27da 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.mp3 *.opus *.flac +*.temp config.yml Music/ *.txt diff --git a/spotdl/command_line/arguments.py b/spotdl/command_line/arguments.py index c8d5b28..1f78163 100644 --- a/spotdl/command_line/arguments.py +++ b/spotdl/command_line/arguments.py @@ -292,10 +292,13 @@ class Arguments: "--write-to can only be used with --playlist, --album, --all-albums, --username, or --write-m3u." ) - ffmpeg_exists = shutil.which("ffmpeg") + ffmpeg_exists = shutil.which("fffmpeg") if not ffmpeg_exists: logger.warn("FFmpeg was not found in PATH. Will not re-encode media to specified output format.") - self.parsed.output_ext = self.parsed.input_ext + self.parsed.no_encode = True + + if self.parsed.no_encode and self.parsed.trim_silence: + logger.warn("--trim-silence can only be used when an encoder is set.") if self.parsed.output_file == "-" and self.parsed.no_metadata is False: logger.warn( @@ -311,7 +314,7 @@ class Arguments: logger.warn( "Given output file is a directory. Will download tracks " "in this directory with their filename as per the default " - "file format. Pass '--output-file=\"{}\"' to hide this " + "file format. Pass --output-file=\"{}\" to hide this " "warning.".format( adjusted_output_file ) diff --git a/spotdl/command_line/tests/test_arguments.py b/spotdl/command_line/tests/test_arguments.py index 1e73daa..b780453 100644 --- a/spotdl/command_line/tests/test_arguments.py +++ b/spotdl/command_line/tests/test_arguments.py @@ -34,7 +34,7 @@ class TestArguments: arguments["spotify_client_secret"] = None expect_arguments = { - "track": ["elena coats - one last song"], + "song": ["elena coats - one last song"], "song": None, "list": None, "playlist": None, @@ -46,7 +46,6 @@ class TestArguments: "no_remove_original": False, "no_metadata": False, "no_fallback_metadata": False, - "avconv": False, "directory": "/home/ritiek/Music", "overwrite": "prompt", "input_ext": ".m4a", @@ -60,7 +59,6 @@ class TestArguments: "music_videos_only": False, "no_spaces": False, "log_level": 20, - "youtube_api_key": None, "skip": None, "write_successful": None, "spotify_client_id": None, @@ -72,5 +70,5 @@ class TestArguments: def test_grouped_arguments(self): with pytest.raises(SystemExit): - spotdl.command_line.arguments.get_arguments(to_merge=True) + spotdl.command_line.arguments.get_arguments() diff --git a/spotdl/encode/encoders/tests/test_avconv.py b/spotdl/encode/encoders/tests/test_avconv.py deleted file mode 100644 index 2292992..0000000 --- a/spotdl/encode/encoders/tests/test_avconv.py +++ /dev/null @@ -1,58 +0,0 @@ -from spotdl.encode import EncoderBase -from spotdl.encode.exceptions import AvconvNotFoundError -from spotdl.encode.encoders import EncoderAvconv - -import pytest - - -class TestEncoderAvconv: - def test_subclass(self): - assert issubclass(EncoderAvconv, EncoderBase) - - def test_avconv_not_found_error(self): - with pytest.raises(AvconvNotFoundError): - EncoderAvconv(encoder_path="/a/nonexistent/path") - - -class TestEncodingDefaults: - def encode_command(input_file, target_file): - command = [ - 'avconv', '-y', '-loglevel', '0', - '-i', input_file, - '-ab', '192k', - target_file, - ] - return command - - @pytest.mark.parametrize("files, expected_command", [ - (("test.m4a", "test.mp3"), encode_command("test.m4a", "test.mp3")), - (("abc.m4a", "cba.opus"), encode_command("abc.m4a", "cba.opus")), - (("bla bla.m4a", "ble ble.m4a"), encode_command("bla bla.m4a", "ble ble.m4a")), - (("😛.m4a", "• tongue.flac"), encode_command("😛.m4a", "• tongue.flac")), - ]) - def test_generate_encode_command(self, files, expected_command): - encoder = EncoderAvconv() - assert encoder._generate_encode_command(*files) == expected_command - - -class TestEncodingInDebugMode: - def debug_encode_command(input_file, target_file): - command = [ - 'avconv', '-y', '-loglevel', 'debug', - '-i', input_file, - '-ab', '192k', - target_file, - ] - return command - - @pytest.mark.parametrize("files, expected_command", [ - (("test.m4a", "test.mp3"), debug_encode_command("test.m4a", "test.mp3")), - (("abc.m4a", "cba.opus"), debug_encode_command("abc.m4a", "cba.opus")), - (("bla bla.m4a", "ble ble.m4a"), debug_encode_command("bla bla.m4a", "ble ble.m4a")), - (("😛.m4a", "• tongue.flac"), debug_encode_command("😛.m4a", "• tongue.flac")), - ]) - def test_generate_encode_command_with_debug(self, files, expected_command): - encoder = EncoderAvconv() - encoder.set_debuglog() - assert encoder._generate_encode_command(*files) == expected_command - diff --git a/spotdl/encode/exceptions.py b/spotdl/encode/exceptions.py index f8f8e2a..1941acc 100644 --- a/spotdl/encode/exceptions.py +++ b/spotdl/encode/exceptions.py @@ -11,10 +11,3 @@ class FFmpegNotFoundError(EncoderNotFoundError): def __init__(self, message=None): super().__init__(message) - -class AvconvNotFoundError(EncoderNotFoundError): - __module__ = Exception.__module__ - - def __init__(self, message=None): - super().__init__(message) - diff --git a/spotdl/encode/tests/test_encode_exceptions.py b/spotdl/encode/tests/test_encode_exceptions.py index 13d5846..272fe04 100644 --- a/spotdl/encode/tests/test_encode_exceptions.py +++ b/spotdl/encode/tests/test_encode_exceptions.py @@ -1,6 +1,5 @@ from spotdl.encode.exceptions import EncoderNotFoundError from spotdl.encode.exceptions import FFmpegNotFoundError -from spotdl.encode.exceptions import AvconvNotFoundError class TestEncoderNotFoundSubclass: @@ -10,6 +9,3 @@ class TestEncoderNotFoundSubclass: def test_ffmpeg_not_found_subclass(self): assert issubclass(FFmpegNotFoundError, EncoderNotFoundError) - def test_avconv_not_found_subclass(self): - assert issubclass(AvconvNotFoundError, EncoderNotFoundError) - diff --git a/spotdl/metadata/providers/youtube.py b/spotdl/metadata/providers/youtube.py index c25616d..4cdabc3 100644 --- a/spotdl/metadata/providers/youtube.py +++ b/spotdl/metadata/providers/youtube.py @@ -199,7 +199,7 @@ class YouTubeStreams(StreamsBase): if stream["encoding"] == preftype: selected_stream = stream break - logger.debug('Selected worst quality stream for "{preftype}" format:\n'.format( + logger.debug('Selected worst quality stream for "{preftype}" format:\n{stream}'.format( preftype=preftype, stream=selected_stream, ))