mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2025-07-01 15:23:15 +00:00
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_PATH': '../ZSpotify Music/',
|
||||||
'ROOT_PODCAST_PATH': '../ZSpotify Podcasts/',
|
'ROOT_PODCAST_PATH': '../ZSpotify Podcasts/',
|
||||||
'SKIP_EXISTING_FILES': True,
|
'SKIP_EXISTING_FILES': True,
|
||||||
'DOWNLOAD_FORMAT': 'mp3',
|
'DOWNLOAD_FORMAT': 'ogg',
|
||||||
'BITRATE': '160k',
|
|
||||||
'FORCE_PREMIUM': False,
|
'FORCE_PREMIUM': False,
|
||||||
'ANTI_BAN_WAIT_TIME': 1,
|
'ANTI_BAN_WAIT_TIME': 1,
|
||||||
'OVERRIDE_AUTO_WAIT': False,
|
'OVERRIDE_AUTO_WAIT': False,
|
||||||
|
@ -2,6 +2,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
from typing import Any, Tuple, List
|
from typing import Any, Tuple, List
|
||||||
|
|
||||||
|
from librespot.audio.decoders import AudioQuality
|
||||||
from librespot.metadata import TrackId
|
from librespot.metadata import TrackId
|
||||||
from ffmpy import FFmpeg
|
from ffmpy import FFmpeg
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
@ -129,13 +130,22 @@ def convert_audio_format(filename) -> None:
|
|||||||
file_codec = CODEC_MAP.get(download_format, "copy")
|
file_codec = CODEC_MAP.get(download_format, "copy")
|
||||||
if file_codec != 'copy':
|
if file_codec != 'copy':
|
||||||
bitrate = ZSpotify.get_config(BITRATE)
|
bitrate = ZSpotify.get_config(BITRATE)
|
||||||
|
if not bitrate:
|
||||||
|
if ZSpotify.DOWNLOAD_QUALITY == AudioQuality.VERY_HIGH:
|
||||||
|
bitrate = '320k'
|
||||||
|
else:
|
||||||
|
bitrate = '160k'
|
||||||
else:
|
else:
|
||||||
bitrate = None
|
bitrate = None
|
||||||
|
|
||||||
|
output_params = ['-c:a', file_codec]
|
||||||
|
if bitrate:
|
||||||
|
output_params += ['-b:a', bitrate]
|
||||||
|
|
||||||
ff_m = FFmpeg(
|
ff_m = FFmpeg(
|
||||||
global_options=['-y', '-hide_banner', '-loglevel error'],
|
global_options=['-y', '-hide_banner', '-loglevel error'],
|
||||||
inputs={temp_filename: None},
|
inputs={temp_filename: None},
|
||||||
outputs={filename: ['-c:a', file_codec] + ['-b:a', bitrate] if bitrate else []}
|
outputs={filename: output_params}
|
||||||
)
|
)
|
||||||
ff_m.run()
|
ff_m.run()
|
||||||
if os.path.exists(temp_filename):
|
if os.path.exists(temp_filename):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user