mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2026-01-10 03:15:56 +00:00
Write tests for YouTube metadata
This commit is contained in:
@@ -26,7 +26,7 @@ class EncoderAvconv(EncoderBase):
|
||||
def get_encoding(self, filename):
|
||||
return super().get_encoding(filename)
|
||||
|
||||
def _generate_encoding_arguments(self, input_encoding, output_encoding):
|
||||
def _generate_encoding_arguments(self, input_encoding, target_encoding):
|
||||
initial_arguments = self._rules.get(input_encoding)
|
||||
if initial_arguments is None:
|
||||
raise TypeError(
|
||||
@@ -35,7 +35,7 @@ class EncoderAvconv(EncoderBase):
|
||||
)
|
||||
)
|
||||
|
||||
arguments = initial_arguments.get(output_encoding)
|
||||
arguments = initial_arguments.get(target_encoding)
|
||||
if arguments is None:
|
||||
raise TypeError(
|
||||
'The output format ("{}") is not supported.'.format(
|
||||
@@ -45,19 +45,19 @@ class EncoderAvconv(EncoderBase):
|
||||
|
||||
return arguments
|
||||
|
||||
def _generate_encoding_arguments(self, input_encoding, output_encoding):
|
||||
def _generate_encoding_arguments(self, input_encoding, target_encoding):
|
||||
return ""
|
||||
|
||||
def set_debuglog(self):
|
||||
self._loglevel = "-loglevel debug"
|
||||
|
||||
def _generate_encode_command(self, input_file, output_file):
|
||||
def _generate_encode_command(self, input_file, target_file):
|
||||
input_encoding = self.get_encoding(input_file)
|
||||
output_encoding = self.get_encoding(output_file)
|
||||
target_encoding = self.get_encoding(target_file)
|
||||
|
||||
arguments = self._generate_encoding_arguments(
|
||||
input_encoding,
|
||||
output_encoding
|
||||
target_encoding
|
||||
)
|
||||
|
||||
command = [self.encoder_path] \
|
||||
@@ -65,14 +65,14 @@ class EncoderAvconv(EncoderBase):
|
||||
+ self._loglevel.split() \
|
||||
+ ["-i", input_file] \
|
||||
+ self._additional_arguments \
|
||||
+ [output_file]
|
||||
+ [target_file]
|
||||
|
||||
return command
|
||||
|
||||
def re_encode(self, input_file, output_file, delete_original=False):
|
||||
def re_encode(self, input_file, target_file, delete_original=False):
|
||||
encode_command = self._generate_encode_command(
|
||||
input_file,
|
||||
output_file
|
||||
target_file
|
||||
)
|
||||
|
||||
returncode = subprocess.call(encode_command)
|
||||
|
||||
@@ -37,18 +37,18 @@ class EncoderFFmpeg(EncoderBase):
|
||||
def get_encoding(self, path):
|
||||
return super().get_encoding(path)
|
||||
|
||||
def _generate_encoding_arguments(self, input_encoding, output_encoding):
|
||||
def _generate_encoding_arguments(self, input_encoding, target_encoding):
|
||||
initial_arguments = self._rules.get(input_encoding)
|
||||
if initial_arguments is None:
|
||||
raise TypeError(
|
||||
'The input format ("{}") is not supported.'.format(
|
||||
input_encoding,
|
||||
))
|
||||
arguments = initial_arguments.get(output_encoding)
|
||||
arguments = initial_arguments.get(target_encoding)
|
||||
if arguments is None:
|
||||
raise TypeError(
|
||||
'The output format ("{}") is not supported.'.format(
|
||||
output_encoding,
|
||||
target_encoding,
|
||||
))
|
||||
return arguments
|
||||
|
||||
@@ -56,14 +56,14 @@ class EncoderFFmpeg(EncoderBase):
|
||||
self._loglevel = "-loglevel debug"
|
||||
|
||||
def _generate_encode_command(self, input_path, target_path,
|
||||
input_encoding=None, output_encoding=None):
|
||||
input_encoding=None, target_encoding=None):
|
||||
if input_encoding is None:
|
||||
input_encoding = self.get_encoding(input_path)
|
||||
if output_encoding is None:
|
||||
output_encoding = self.get_encoding(target_path)
|
||||
if target_encoding is None:
|
||||
target_encoding = self.get_encoding(target_path)
|
||||
arguments = self._generate_encoding_arguments(
|
||||
input_encoding,
|
||||
output_encoding
|
||||
target_encoding
|
||||
)
|
||||
command = [self.encoder_path] \
|
||||
+ ["-y", "-nostdin"] \
|
||||
@@ -88,7 +88,7 @@ class EncoderFFmpeg(EncoderBase):
|
||||
return process
|
||||
|
||||
def re_encode_from_stdin(self, input_encoding, target_path):
|
||||
output_encoding = self.get_encoding(target_path)
|
||||
target_encoding = self.get_encoding(target_path)
|
||||
encode_command = self._generate_encode_command(
|
||||
"-",
|
||||
target_path,
|
||||
|
||||
@@ -15,12 +15,12 @@ class TestEncoderAvconv:
|
||||
|
||||
|
||||
class TestEncodingDefaults:
|
||||
def encode_command(input_file, output_file):
|
||||
def encode_command(input_file, target_file):
|
||||
command = [
|
||||
'avconv', '-y', '-loglevel', '0',
|
||||
'-i', input_file,
|
||||
'-ab', '192k',
|
||||
output_file,
|
||||
target_file,
|
||||
]
|
||||
return command
|
||||
|
||||
@@ -36,12 +36,12 @@ class TestEncodingDefaults:
|
||||
|
||||
|
||||
class TestEncodingInDebugMode:
|
||||
def debug_encode_command(input_file, output_file):
|
||||
def debug_encode_command(input_file, target_file):
|
||||
command = [
|
||||
'avconv', '-y', '-loglevel', 'debug',
|
||||
'-i', input_file,
|
||||
'-ab', '192k',
|
||||
output_file,
|
||||
target_file,
|
||||
]
|
||||
return command
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from spotdl.encode.encoders import EncoderFFmpeg
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestEncoderFFmpeg:
|
||||
def test_subclass(self):
|
||||
assert issubclass(EncoderFFmpeg, EncoderBase)
|
||||
|
||||
Reference in New Issue
Block a user