Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zotify/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@
'm4a': 'm4a',
'mp3': 'mp3',
'ogg': 'ogg',
'opus': 'ogg',
'opus': 'opus',
'vorbis': 'ogg',
}
22 changes: 16 additions & 6 deletions zotify/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,21 +304,31 @@ def convert_audio_format(filename) -> None:
download_format = Zotify.CONFIG.get_download_format().lower()
file_codec = CODEC_MAP.get(download_format, 'copy')
if file_codec != 'copy':
bitrate = Zotify.CONFIG.get_transcode_bitrate()
bitrates = {
'auto': '320k' if Zotify.check_premium() else '160k',
'normal': '96k',
'high': '160k',
'very_high': '320k'
}
bitrate = bitrates[Zotify.CONFIG.get_download_quality()]

# This var does the job of the old 'bitrate' var.
predef_quality_level_bitrate = bitrates[Zotify.CONFIG.get_download_quality()]
# New var to hold user-specified bitrate separately
custom_bitrate = Zotify.CONFIG.get_transcode_bitrate()

# Check if the user has specified a custom bitrate, ie they've put something in for transcode bitrate, take that and use it as the bitrate. It's more important than the predefined quality levels
if custom_bitrate != None:
set_bitrate = custom_bitrate
else:
set_bitrate = predef_quality_level_bitrate

else:
bitrate = None
set_bitrate = None

output_params = ['-c:a', file_codec]
if bitrate:
output_params += ['-b:a', bitrate]

Printer.print(PrintChannel.DOWNLOADS, f'### Downloading in {file_codec.upper()} ###')
if set_bitrate:
output_params += ['-b:a', set_bitrate]
try:
ff_m = ffmpy.FFmpeg(
global_options=['-y', '-hide_banner', '-loglevel error'],
Expand Down
1 change: 1 addition & 0 deletions zotify/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
class MusicFormat(str, Enum):
MP3 = 'mp3',
OGG = 'ogg',
OPUS = 'opus'


def create_download_directory(download_path: str) -> None:
Expand Down