mirror of https://github.com/afkcodes/zspotify.git
Merge pull request #148 from shirt-dev/bitrate-selection
Fix audio copy, set bitrate based on account type if not in config
This commit is contained in:
commit
16ade2d5e1
|
@ -122,8 +122,7 @@ CONFIG_DEFAULT_SETTINGS = {
|
|||
'ROOT_PATH': '../ZSpotify Music/',
|
||||
'ROOT_PODCAST_PATH': '../ZSpotify Podcasts/',
|
||||
'SKIP_EXISTING_FILES': True,
|
||||
'DOWNLOAD_FORMAT': 'mp3',
|
||||
'BITRATE': '160k',
|
||||
'DOWNLOAD_FORMAT': 'ogg',
|
||||
'FORCE_PREMIUM': False,
|
||||
'ANTI_BAN_WAIT_TIME': 1,
|
||||
'OVERRIDE_AUTO_WAIT': False,
|
||||
|
|
|
@ -2,6 +2,7 @@ import os
|
|||
import time
|
||||
from typing import Any, Tuple, List
|
||||
|
||||
from librespot.audio.decoders import AudioQuality
|
||||
from librespot.metadata import TrackId
|
||||
from ffmpy import FFmpeg
|
||||
from tqdm import tqdm
|
||||
|
@ -129,13 +130,22 @@ def convert_audio_format(filename) -> None:
|
|||
file_codec = CODEC_MAP.get(download_format, "copy")
|
||||
if file_codec != 'copy':
|
||||
bitrate = ZSpotify.get_config(BITRATE)
|
||||
if not bitrate:
|
||||
if ZSpotify.DOWNLOAD_QUALITY == AudioQuality.VERY_HIGH:
|
||||
bitrate = '320k'
|
||||
else:
|
||||
bitrate = '160k'
|
||||
else:
|
||||
bitrate = None
|
||||
|
||||
output_params = ['-c:a', file_codec]
|
||||
if bitrate:
|
||||
output_params += ['-b:a', bitrate]
|
||||
|
||||
ff_m = FFmpeg(
|
||||
global_options=['-y', '-hide_banner', '-loglevel error'],
|
||||
inputs={temp_filename: None},
|
||||
outputs={filename: ['-c:a', file_codec] + ['-b:a', bitrate] if bitrate else []}
|
||||
outputs={filename: output_params}
|
||||
)
|
||||
ff_m.run()
|
||||
if os.path.exists(temp_filename):
|
||||
|
|
Loading…
Reference in New Issue