mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Better handling when FFmpeg isn't found
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user