From e57373cfa254637bf9ab9d9c045344a9b0d37b06 Mon Sep 17 00:00:00 2001 From: pika <67532734+pik4li@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:35:09 +0100 Subject: [PATCH] addet sorting and chagned some logging --- tui/tui.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tui/tui.go b/tui/tui.go index d4e3d93..b23bc5e 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -137,8 +137,24 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "enter": if i := m.results.Index(); i != -1 { selectedVideo := m.videos[i] + log.Printf("Playing video: %s", selectedVideo.URL) cmd := player.PlayVideo(selectedVideo.URL) - return m, tea.ExecProcess(cmd, nil) + + // Execute the command and handle any errors + if err := cmd.Start(); err != nil { + m.err = fmt.Errorf("this video URL cannot be played: %w", err) + log.Printf("Error starting video playback: %v", err) + return m, nil + } + + // Optionally, wait for the command to finish + go func() { + if err := cmd.Wait(); err != nil { + log.Printf("Error during video playback: %v", err) + } + }() + + return m, nil } case "s":