addet sorting and chagned some logging

This commit is contained in:
pika 2025-01-02 15:35:09 +01:00
parent 27a221318e
commit e57373cfa2

View file

@ -137,8 +137,24 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "enter": case "enter":
if i := m.results.Index(); i != -1 { if i := m.results.Index(); i != -1 {
selectedVideo := m.videos[i] selectedVideo := m.videos[i]
log.Printf("Playing video: %s", selectedVideo.URL)
cmd := player.PlayVideo(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": case "s":