Added FLAC class, and some error handling
This commit is contained in:
@@ -115,6 +115,10 @@ class Converter:
|
||||
if self.lossless:
|
||||
if isinstance(self.sampling_rate, int):
|
||||
command.extend(["-ar", str(self.sampling_rate)])
|
||||
else:
|
||||
raise TypeError(
|
||||
f"Sampling rate must be int, not {type(self.sampling_rate)}"
|
||||
)
|
||||
|
||||
if isinstance(self.bit_depth, int):
|
||||
if int(self.bit_depth) == 16:
|
||||
@@ -123,6 +127,8 @@ class Converter:
|
||||
command.extend(["-sample_fmt", "s32"])
|
||||
else:
|
||||
raise ValueError("Bit depth must be 16, 24, or 32")
|
||||
else:
|
||||
raise TypeError(f"Bit depth must be int, not {type(self.bit_depth)}")
|
||||
|
||||
command.extend(["-y", self.tempfile])
|
||||
|
||||
@@ -139,6 +145,14 @@ class Converter:
|
||||
return
|
||||
|
||||
|
||||
class FLAC(Converter):
|
||||
" Class for FLAC converter. "
|
||||
codec_name = "flac"
|
||||
codec_lib = "flac"
|
||||
container = "flac"
|
||||
lossless = True
|
||||
|
||||
|
||||
class LAME(Converter):
|
||||
"""
|
||||
Class for libmp3lame converter. Defaul ffmpeg_arg: `-q:a 0`.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import subprocess
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from tempfile import gettempdir
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
@@ -10,12 +10,12 @@ from mutagen.flac import FLAC, Picture
|
||||
from mutagen.id3 import APIC, ID3, ID3NoHeaderError
|
||||
from pathvalidate import sanitize_filename
|
||||
|
||||
from . import converter
|
||||
from .clients import ClientInterface
|
||||
from .constants import EXT, FLAC_MAX_BLOCKSIZE
|
||||
from .exceptions import InvalidQuality, NonStreamable, TooLargeCoverArt
|
||||
from .metadata import TrackMetadata
|
||||
from .util import quality_id, safe_get, tqdm_download
|
||||
from . import converter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user