From 188df677b0df16065b5d2db4ee6be7c2074f0e31 Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Wed, 26 Oct 2022 15:47:23 -0600 Subject: [PATCH] Added sort functionality, added volume for playback --- ytbrowser.pl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ytbrowser.pl b/ytbrowser.pl index 4a36b4d..5f12af2 100755 --- a/ytbrowser.pl +++ b/ytbrowser.pl @@ -33,6 +33,7 @@ my $jsonDirty; my $rawFile; my @videos = (); my $recursionWatchdog = 0; +my $volume = 50; my $cookieCrisp = ""; open (COOKIE, $cookiesFile) or die "I CANNOT FUNCTION WITHOUT COOKIES!!!\n"; @@ -202,7 +203,7 @@ $suggestions->set_binding( sub { my $video = $watchlist[0]; unless($video) { return 0; } $cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".$watchArray[0]); - if (0 == system("mpv --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}")) { + 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(); @@ -219,7 +220,7 @@ $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 --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}")) { + 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}")) { splice(@watchArray,$wlist->get_active_id(),1); splice(@watchlist,$wlist->get_active_id(),1); sync2files(); @@ -258,12 +259,18 @@ $wlist->set_binding( sub { } , "i"); $wlist->set_binding( sub { - # Sort shortest to longest -} , "<"); + @watchlist = sort { $a->{runtime} cmp $b->{runtime} } @watchlist; + sync2files(); + loadSugs(); + $wlist->draw(); +} , ">"); $wlist->set_binding( sub { - # Sort longest to shortest -}, ">"); + @watchlist = sort { $b->{runtime} cmp $a->{runtime} } @watchlist; + sync2files(); + loadSugs(); + $wlist->draw(); +}, "<"); $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");