Skip to content

Commit

Permalink
linted
Browse files Browse the repository at this point in the history
  • Loading branch information
asakura42 committed Mar 28, 2024
1 parent 2dda574 commit 382b1da
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions btstrm/btstrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,32 +614,38 @@ def main():
# For other players, just use original command.
player_with_options = list(player)



if len(media) == 1:
print(f"Playing: {os.path.basename(media[0])}")
status = subprocess.call(player_with_options + media, stdin=sys.stdin)
elif len(media) > 1:
while media:
selection_list = "\n".join(f"{index}: {os.path.basename(path)}" for index, path in enumerate(media))
process = subprocess.Popen(['fzf', '--with-nth', '2..'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
selected, _ = process.communicate(input=selection_list.encode('utf-8'))
selection_list = "\n".join(
f"{index}: {os.path.basename(path)}"
for index, path in enumerate(media)
)
process = subprocess.Popen(
["fzf", "--with-nth", "2.."],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
selected, _ = process.communicate(input=selection_list.encode("utf-8"))
if process.returncode == 0:
selected_index = int(selected.decode('utf-8').split(':')[0])
selected_index = int(selected.decode("utf-8").split(":")[0])
selected_file = media[selected_index]

print(f"Playing: {os.path.basename(selected_file)}")
status = subprocess.call(player_with_options + [selected_file], stdin=sys.stdin)
status = subprocess.call(
player_with_options + [selected_file], stdin=sys.stdin
)

if REMOVE_PLAYED_FROM_LIST:
media.pop(selected_index)
else:
print("Exiting.")
break


# if media:
# status = subprocess.call(player_with_options + media, stdin=sys.stdin)
# status = subprocess.call(player_with_options + media, stdin=sys.stdin)
else:
print("No video media found", file=sys.stderr)
status = 3
Expand Down

0 comments on commit 382b1da

Please sign in to comment.