mirror of
https://github.com/beetbox/beets.git
synced 2026-04-01 19:23:55 +02:00
Use util function for song selection
This commit is contained in:
parent
f28a9f0881
commit
4dd66eefe8
1 changed files with 13 additions and 18 deletions
|
|
@ -71,24 +71,19 @@ class ReplacePlugin(BeetsPlugin):
|
|||
for i, item in enumerate(items, 1):
|
||||
ui.print_(f"{i}. {util.displayable_path(item)}")
|
||||
|
||||
while True:
|
||||
try:
|
||||
index = int(
|
||||
input(
|
||||
f"Which song would you like to replace? "
|
||||
f"[1-{len(items)}] (0 to cancel): "
|
||||
)
|
||||
)
|
||||
if index == 0:
|
||||
return None
|
||||
if 1 <= index <= len(items):
|
||||
return items[index - 1]
|
||||
ui.print_(
|
||||
f"Invalid choice. Please enter a number "
|
||||
f"between 1 and {len(items)}."
|
||||
)
|
||||
except ValueError:
|
||||
ui.print_("Invalid input. Please type in a number.")
|
||||
index = ui.input_options(
|
||||
[],
|
||||
require=True,
|
||||
prompt=(
|
||||
f"Which song would you like to replace? "
|
||||
f"[1-{len(items)}] (0 to cancel):"
|
||||
),
|
||||
numrange=(0, len(items)),
|
||||
)
|
||||
|
||||
if index == 0:
|
||||
return None
|
||||
return items[index - 1]
|
||||
|
||||
def confirm_replacement(self, new_file_path: Path, song: Item) -> bool:
|
||||
"""Get user confirmation for the replacement."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue