Skip to content

Commit

Permalink
bugfixes when dealing with non-default song dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwalVandana committed Jul 20, 2023
1 parent b644516 commit a842683
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
Binary file removed dist/maestro-music-1.0.7.tar.gz
Binary file not shown.
Binary file added dist/maestro-music-1.0.8.tar.gz
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _load_visualizer_data(self):
for i in range(self.i, min(self.i + 5, len(self.playlist))):
if self.playlist[i][0] in self.visualizer_data:
continue
print_to_logfile(f"helpers.py {config.SONGS_DIR}")
# print_to_logfile(f"helpers.py {config.SONGS_DIR}")
song_path = os.path.join(config.SONGS_DIR, self.playlist[i][1])
cur_song_data = LIBROSA.load(
song_path, mono=False, sr=config.SAMPLE_RATE
Expand Down
40 changes: 30 additions & 10 deletions maestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _play(
else:
next_playlist = None

helpers.print_to_logfile("maestro.py", config.SONGS_DIR)
# helpers.print_to_logfile("maestro.py", config.SONGS_DIR)
player_output = helpers.PlayerOutput(
stdscr, playlist, volume, clip_mode, update_discord, visualize
)
Expand Down Expand Up @@ -1584,12 +1584,24 @@ def remove(args, force, tag):
song_id = int(details[0])
if song_id in remaining_song_ids:
remaining_song_ids.remove(song_id)
to_be_deleted.append(i)

song_name = details[1]
os.remove( # remove actual song
os.path.join(config.SONGS_DIR, song_name)
)
song_path = os.path.join(config.SONGS_DIR, song_name)
if os.path.exists(song_path):
os.remove(song_path)
else:
click.secho(
f"Warning: Song file '{song_name}' (ID {song_id}) not found. Would you still like to delete the song from the database? [y/n] ",
fg="yellow",
nl=False,
)
if input().lower() != "y":
click.echo(
f"Skipping song '{song_name}' (ID {song_id})."
)
continue

to_be_deleted.append(i)

click.secho(
f"Removed song '{song_name}' with ID {song_id}.",
Expand Down Expand Up @@ -2047,6 +2059,14 @@ def rename(original, new_name, renaming_tag):
old_path = details[1]
details[1] = new_name + os.path.splitext(old_path)[1]

full_song_path = os.path.join(config.SONGS_DIR, old_path)
if not os.path.exists(full_song_path):
click.secho(
f"Song file '{old_path}' (ID {original}) not found.",
fg="red",
)
return

lines[i] = "|".join(details)
songs_file.close()
songs_file = open(config.SONGS_INFO_PATH, "w", encoding="utf-8")
Expand Down Expand Up @@ -2400,16 +2420,16 @@ def check_if_file_exists(detail_string):
if top is not None and num_lines == top:
break

if no_results and search_tags:
if songs_not_found:
click.secho("Song files not found:", fg="red")
for details in songs_not_found:
click.secho(f"\t{details[1]} (ID {details[0]})", fg="red")
elif no_results and search_tags:
click.secho("No songs found matching tags.", fg="red")
elif no_results:
click.secho(
"No songs found. Use 'maestro add' to add a song.", fg="red"
)
elif songs_not_found:
click.secho("Song files not found:", fg="red")
for details in songs_not_found:
click.secho(f"\t{details[1]} (ID {details[0]})", fg="red")


@cli.command()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="maestro-music",
version="1.0.7",
version="1.0.8",
author="Prajwal Vandana",
url="https://github.com/PrajwalVandana/maestro-cli",
description="A simple command line tool to play songs (or any audio files, really).",
Expand Down

0 comments on commit a842683

Please sign in to comment.