Added sort functionality, added volume for playback

This commit is contained in:
bluesaxman 2022-10-26 15:47:23 -06:00
parent 8bf9c27b5e
commit 188df677b0

View File

@ -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");