Skip to content
Merged
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
6 changes: 3 additions & 3 deletions weeb_cli/commands/search/watch_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,16 @@ def on_watched_callback():
return play_success

def _select_stream(streams_list):
if len(streams_list) == 1:
return streams_list[0]

stream_choices = []
for s in streams_list:
server = s.get("server", "Unknown")
quality = s.get("quality", "auto")
label = f"{server} ({quality})"
stream_choices.append(questionary.Choice(label, value=s))

if not stream_choices:
return None

return questionary.select(
i18n.t("details.select_source"),
choices=stream_choices,
Expand Down
20 changes: 15 additions & 5 deletions weeb_cli/services/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,26 @@ def play(self, url: str, title: Optional[str] = None, start_time: Optional[int]
)
self._monitor_thread.start()

result = subprocess.run(cmd, capture_output=True, text=True)
# Using Popen for more flexible process management, similar to doccli
process = subprocess.Popen(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
shell=False
)

# Wait for the process to exit
exit_code = process.wait()

if self._monitor_thread:
self._stop_monitor.set()
self._monitor_thread.join(timeout=1)

if result.returncode != 0:
log_debug(f"[Player] MPV Error (Code {result.returncode}): {result.stderr.strip()}")
console.print(f"[red]{i18n.t('player.error')}[/red]")
return result.returncode == 0
if exit_code != 0:
log_debug(f"[Player] MPV exited with code: {exit_code}")
# Don't show error if exit_code is 0 (normal exit)
return exit_code == 0
except FileNotFoundError as e:
handle_error(e, "Player:MPV", f"{i18n.t('player.error')}: MPV not found at {self.mpv_path}")
return False
Expand Down
Loading