mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Handle FFmpeg trim silence option
This commit is contained in:
@@ -9,6 +9,8 @@ from spotdl.lyrics.providers import LyricWikia
|
|||||||
from spotdl.lyrics.providers import Genius
|
from spotdl.lyrics.providers import Genius
|
||||||
from spotdl.lyrics.exceptions import LyricsNotFoundError
|
from spotdl.lyrics.exceptions import LyricsNotFoundError
|
||||||
|
|
||||||
|
from spotdl.encode.encoders import EncoderFFmpeg
|
||||||
|
|
||||||
from spotdl.authorize.services import AuthorizeSpotify
|
from spotdl.authorize.services import AuthorizeSpotify
|
||||||
|
|
||||||
from spotdl.track import Track
|
from spotdl.track import Track
|
||||||
@@ -233,10 +235,14 @@ class Spotdl:
|
|||||||
if self.arguments["no_encode"]:
|
if self.arguments["no_encode"]:
|
||||||
track.download(stream, temp_filename)
|
track.download(stream, temp_filename)
|
||||||
else:
|
else:
|
||||||
|
encoder = EncoderFFmpeg()
|
||||||
|
if self.arguments["trim_silence"]:
|
||||||
|
encoder.set_trim_silence()
|
||||||
track.download_while_re_encoding(
|
track.download_while_re_encoding(
|
||||||
stream,
|
stream,
|
||||||
temp_filename,
|
temp_filename,
|
||||||
target_encoding=output_extension,
|
target_encoding=output_extension,
|
||||||
|
encoder=encoder,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.arguments["no_metadata"]:
|
if not self.arguments["no_metadata"]:
|
||||||
@@ -244,6 +250,9 @@ class Spotdl:
|
|||||||
self.apply_metadata(track, temp_filename, output_extension)
|
self.apply_metadata(track, temp_filename, output_extension)
|
||||||
|
|
||||||
if not download_to_stdout:
|
if not download_to_stdout:
|
||||||
|
logger.debug("Renaming {temp_filename} to {filename}.".format(
|
||||||
|
temp_filename=temp_filename, filename=filename
|
||||||
|
))
|
||||||
os.rename(temp_filename, filename)
|
os.rename(temp_filename, filename)
|
||||||
|
|
||||||
def apply_metadata(self, track, filename, encoding):
|
def apply_metadata(self, track, filename, encoding):
|
||||||
|
|||||||
Reference in New Issue
Block a user