diff --git a/ytbrowser.pl b/ytbrowser.pl index 5f12af2..a551dc8 100755 --- a/ytbrowser.pl +++ b/ytbrowser.pl @@ -200,19 +200,17 @@ $suggestions->set_binding( sub { }, KEY_ENTER); $suggestions->set_binding( sub { - my $video = $watchlist[0]; + my $info = (split($suggestArray[$suggestions->get_active_id()],2))[1]; + my $video = $videos[$suggestions->get_active_id()]; unless($video) { return 0; } - $cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".$watchArray[0]); - if (0 == system("mpv --volume=".$volume." --script-opts=ytdl_hook-ytdl_path=yt-dlp --ytdl-raw-options=cookies=$cookiesFile,mark-watched=,buffer-size=200M,format='bestvideo[height<=720]+bestaudio/best[height<=720]' --terminal=no https://www.youtube.com/watch?v=$video->{id}")) { - shift(@watchArray); - shift(@watchlist); - sync2files(); + $cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".$info); + if (0 == system("mpv --volume=".$volume." --script-opts=ytdl_hook-ytdl_path=yt-dlp --ytdl-raw-options=cookies=$cookiesFile,buffer-size=200M,format='bestvideo[height<=720]+bestaudio/best[height<=720]' --terminal=no https://www.youtube.com/watch?v=$video->{id}")) { $win->draw(); $suggestions->draw(); $wlist->draw(); - $cui->status("Playback Complete, video cleared"); + $cui->status("Playback Complete"); } else { - $cui->status("PLAYBACK ERROR: Video not removed for safety."); + $cui->status("PLAYBACK ERROR"); } }, "p"); @@ -233,6 +231,20 @@ $wlist->set_binding( sub { } } , "p"); +$wlist->set_binding( sub { + my $video = $watchlist[$wlist->get_active_id()]; + unless($video) { return 0; } + $cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".$watchArray[$wlist->get_active_id()]); + if (0 == system("mpv --volume=".$volume." --script-opts=ytdl_hook-ytdl_path=yt-dlp --ytdl-raw-options=cookies=$cookiesFile,mark-watched=,buffer-size=200M,format='bestvideo[height<=720]+bestaudio/best[height<=720]' --terminal=no https://www.youtube.com/watch?v=$video->{id}")) { + $win->draw(); + $suggestions->draw(); + $wlist->draw(); + $cui->status("Playback Complete"); + } else { + $cui->status("PLAYBACK ERROR."); + } +} , "w"); + $suggestions->set_binding( sub { splice(@videos,0,scalar(@videos)); splice(@suggestArray,0,scalar(@suggestArray)); @@ -272,11 +284,15 @@ $wlist->set_binding( sub { $wlist->draw(); }, "<"); +$wlist->set_binding( sub { + $cui->status("Manual Adding not implimented at this time"); +}, "m"); + $suggestions->set_binding( sub { - $cui->status("Controls:\nEnter\tAdd a video to the playlist\np\tPlay currently selected video\ni\tInfo about currently selected video\nr\tRefresh list from youtube\n?\tShow controls"); + $cui->status("Controls:\nEnter\tAdd a video to the playlist\np\tPlay currently selected video from suggestions\ni\tInfo about currently selected video\nr\tRefresh list from youtube\n?\tShow controls"); }, "?"); $wlist->set_binding( sub { - $cui->status("Controls:\n<\tSort from shortest to longest\n>\tSort from longest to shortest\np\tPlay currently selected video\ni\tInfo about currently selected video\n?\tShow controls"); + $cui->status("Controls:\n<\tSort from shortest to longest\n>\tSort from longest to shortest\np\tPlay currently selected video from playlist, then remove it\nw\tPlay currently selected video from playlist without removing it\ni\tInfo about currently selected video\nm\tManually Add a video by URL\n?\tShow controls"); }, "?"); $suggestions->focus();