Skip to content

Commit

Permalink
allow choosing audio quality
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwalVandana committed Sep 16, 2024
1 parent 8db97dc commit d31ac9c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
2 changes: 1 addition & 1 deletion maestro/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "2.0.3"
VERSION = "2.0.4"
65 changes: 58 additions & 7 deletions maestro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ def _play(
player.i -= 1
elif player.scroller.pos == player.i + 1:
player.i += 1
player.playlist[player.scroller.pos], player.playlist[
player.scroller.pos - 1
] = (
(
player.playlist[player.scroller.pos],
player.playlist[player.scroller.pos - 1],
) = (
player.playlist[player.scroller.pos - 1],
player.playlist[player.scroller.pos],
)
Expand All @@ -273,9 +274,10 @@ def _play(
player.i += 1
elif player.scroller.pos == player.i - 1:
player.i -= 1
player.playlist[player.scroller.pos], player.playlist[
player.scroller.pos + 1
] = (
(
player.playlist[player.scroller.pos],
player.playlist[player.scroller.pos + 1],
) = (
player.playlist[player.scroller.pos + 1],
player.playlist[player.scroller.pos],
)
Expand Down Expand Up @@ -949,6 +951,45 @@ def cli(ctx: click.Context):
default=True,
help="Search for and download lyrics for the song.",
)
@click.option(
"-q",
"--audio-quality",
type=click.Choice(
(
"auto",
# "disable",
"8k",
"16k",
"24k",
"32k",
"40k",
"48k",
"64k",
"80k",
"96k",
"112k",
"128k",
"160k",
"192k",
"224k",
"256k",
"320k",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
),
case_sensitive=False,
),
default="auto",
help="Specify the audio quality to download. 0 is the best quality, 9 is the worst. 'auto' is the default (5). You can also specify a bitrate (e.g. '128k').",
)
def add(
path_,
tags,
Expand All @@ -965,6 +1006,7 @@ def add(
album_artist,
skip_dupes,
lyrics,
audio_quality,
):
"""
Add a new song.
Expand Down Expand Up @@ -1039,6 +1081,11 @@ def add(
{
"key": "FFmpegExtractAudio",
"preferredcodec": format_,
"preferredquality": (
audio_quality
if not audio_quality.lower().endswith("k")
else audio_quality[:-1]
),
},
],
"outtmpl": {
Expand Down Expand Up @@ -1088,6 +1135,8 @@ def spotdl_entry_point(args):
"--format",
format_,
"--headless",
"--bitrate",
audio_quality,
],
)
except FFmpegError:
Expand Down Expand Up @@ -3174,7 +3223,9 @@ def lyrics_(
@click.option(
"-l",
"--lang",
type=click.Choice(("japanese", "german") + config.INDIC_SCRIPTS),
type=click.Choice(
("japanese", "german") + config.INDIC_SCRIPTS, case_sensitive=False
),
help="Language-specific transliteration support.",
)
@click.option(
Expand Down

0 comments on commit d31ac9c

Please sign in to comment.