mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Accept additional command-line options
This commit is contained in:
@@ -9,7 +9,7 @@ from spotdl.encode.exceptions import FFmpegNotFoundError
|
||||
RULES = {
|
||||
"m4a": {
|
||||
"mp3": "-codec:v copy -codec:a libmp3lame -ar 48000",
|
||||
"webm": "-codec:a libopus -vbr on",
|
||||
"opus": "-codec:a libopus -vbr on",
|
||||
"m4a": "-acodec copy",
|
||||
"flac": "-codec:a flac -ar 48000",
|
||||
},
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestEncodingDefaults:
|
||||
|
||||
@pytest.mark.parametrize("files, expected_command", [
|
||||
(("test.m4a", "test.mp3"), encode_command("test.m4a", "test.mp3")),
|
||||
(("abc.m4a", "cba.webm"), encode_command("abc.m4a", "cba.webm")),
|
||||
(("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")),
|
||||
])
|
||||
@@ -47,7 +47,7 @@ class TestEncodingInDebugMode:
|
||||
|
||||
@pytest.mark.parametrize("files, expected_command", [
|
||||
(("test.m4a", "test.mp3"), debug_encode_command("test.m4a", "test.mp3")),
|
||||
(("abc.m4a", "cba.webm"), debug_encode_command("abc.m4a", "cba.webm")),
|
||||
(("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")),
|
||||
])
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestEncodingDefaults:
|
||||
]
|
||||
return command
|
||||
|
||||
def m4a_to_webm_encoder(input_path, target_path):
|
||||
def m4a_to_opus_encoder(input_path, target_path):
|
||||
command = [
|
||||
'ffmpeg', '-y', '-nostdin', '-hide_banner', '-nostats', '-v', 'panic',
|
||||
'-i', input_path,
|
||||
@@ -36,7 +36,7 @@ class TestEncodingDefaults:
|
||||
'-vbr', 'on',
|
||||
'-b:a', '192k',
|
||||
'-vn',
|
||||
'-f', 'webm',
|
||||
'-f', 'opus',
|
||||
target_path
|
||||
]
|
||||
return command
|
||||
@@ -68,7 +68,7 @@ class TestEncodingDefaults:
|
||||
|
||||
@pytest.mark.parametrize("files, expected_command", [
|
||||
(("test.m4a", "test.mp3"), m4a_to_mp3_encoder("test.m4a", "test.mp3")),
|
||||
(("abc.m4a", "cba.webm"), m4a_to_webm_encoder("abc.m4a", "cba.webm")),
|
||||
(("abc.m4a", "cba.opus"), m4a_to_opus_encoder("abc.m4a", "cba.opus")),
|
||||
(("bla bla.m4a", "ble ble.m4a"), m4a_to_m4a_encoder("bla bla.m4a", "ble ble.m4a")),
|
||||
(("😛.m4a", "• tongue.flac"), m4a_to_flac_encoder("😛.m4a", "• tongue.flac")),
|
||||
])
|
||||
@@ -92,7 +92,7 @@ class TestEncodingInDebugMode:
|
||||
]
|
||||
return command
|
||||
|
||||
def m4a_to_webm_encoder_with_debug(input_path, target_path):
|
||||
def m4a_to_opus_encoder_with_debug(input_path, target_path):
|
||||
command = [
|
||||
'ffmpeg', '-y', '-nostdin', '-loglevel', 'debug',
|
||||
'-i', input_path,
|
||||
@@ -100,7 +100,7 @@ class TestEncodingInDebugMode:
|
||||
'-vbr', 'on',
|
||||
'-b:a', '192k',
|
||||
'-vn',
|
||||
'-f', 'webm',
|
||||
'-f', 'opus',
|
||||
target_path
|
||||
]
|
||||
return command
|
||||
@@ -132,7 +132,7 @@ class TestEncodingInDebugMode:
|
||||
|
||||
@pytest.mark.parametrize("files, expected_command", [
|
||||
(("test.m4a", "test.mp3"), m4a_to_mp3_encoder_with_debug("test.m4a", "test.mp3")),
|
||||
(("abc.m4a", "cba.webm"), m4a_to_webm_encoder_with_debug("abc.m4a", "cba.webm")),
|
||||
(("abc.m4a", "cba.opus"), m4a_to_opus_encoder_with_debug("abc.m4a", "cba.opus")),
|
||||
(("bla bla.m4a", "ble ble.m4a"), m4a_to_m4a_encoder_with_debug("bla bla.m4a", "ble ble.m4a")),
|
||||
(("😛.m4a", "• tongue.flac"), m4a_to_flac_encoder_with_debug("😛.m4a", "• tongue.flac")),
|
||||
])
|
||||
@@ -158,7 +158,7 @@ class TestEncodingAndTrimSilence:
|
||||
]
|
||||
return command
|
||||
|
||||
def m4a_to_webm_encoder_and_trim_silence(input_path, target_path):
|
||||
def m4a_to_opus_encoder_and_trim_silence(input_path, target_path):
|
||||
command = [
|
||||
'ffmpeg', '-y', '-nostdin', '-hide_banner', '-nostats', '-v', 'panic',
|
||||
'-i', input_path,
|
||||
@@ -167,7 +167,7 @@ class TestEncodingAndTrimSilence:
|
||||
'-b:a', '192k',
|
||||
'-vn',
|
||||
'-af', 'silenceremove=start_periods=1',
|
||||
'-f', 'webm',
|
||||
'-f', 'opus',
|
||||
target_path
|
||||
]
|
||||
return command
|
||||
@@ -201,7 +201,7 @@ class TestEncodingAndTrimSilence:
|
||||
|
||||
@pytest.mark.parametrize("files, expected_command", [
|
||||
(("test.m4a", "test.mp3"), m4a_to_mp3_encoder_and_trim_silence("test.m4a", "test.mp3")),
|
||||
(("abc.m4a", "cba.webm"), m4a_to_webm_encoder_and_trim_silence("abc.m4a", "cba.webm")),
|
||||
(("abc.m4a", "cba.opus"), m4a_to_opus_encoder_and_trim_silence("abc.m4a", "cba.opus")),
|
||||
(("bla bla.m4a", "ble ble.m4a"), m4a_to_m4a_encoder_and_trim_silence("bla bla.m4a", "ble ble.m4a")),
|
||||
(("😛.m4a", "• tongue.flac"), m4a_to_flac_encoder_and_trim_silence("😛.m4a", "• tongue.flac")),
|
||||
])
|
||||
|
||||
@@ -77,7 +77,7 @@ class TestMethods:
|
||||
@pytest.mark.parametrize("filename, encoding", [
|
||||
("example.m4a", "m4a"),
|
||||
("exampley.mp3", "mp3"),
|
||||
("test 123.webm", "webm"),
|
||||
("test 123.opus", "opus"),
|
||||
("flakey.flac", "flac"),
|
||||
])
|
||||
def test_get_encoding(self, encoderkid, filename, encoding):
|
||||
|
||||
Reference in New Issue
Block a user