From 114fec18f6b47e28e8d779564bbb389462c689b1 Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Wed, 3 Mar 2021 15:32:44 -0700 Subject: [PATCH] I changed some things, I don't actually remember what because I did it yesterday --- ytbrowser.pl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ytbrowser.pl b/ytbrowser.pl index 7e289ca..1a45166 100755 --- a/ytbrowser.pl +++ b/ytbrowser.pl @@ -47,7 +47,7 @@ open(WATCH, $playlistFile) or goto SKIPWATCHLOAD; my $readFile = ""; while() { $readFile .= $_; } close(WATCH); -@watchlist = @{decode_json($readFile)}; +if ($readFile) { @watchlist = @{decode_json($readFile)}; } SKIPWATCHLOAD: my %tests = map { $_->{id} => 1 } @watchlist; @@ -153,7 +153,7 @@ open(CACHED, $cachedFile) or goto SKIPCACHED; $readFile = ""; while () { $readFile .= $_; } close(CACHED); -@videos = @{decode_json($readFile)}; +if ($readFile) { @videos = @{decode_json($readFile)}; } SKIPCACHED: `touch $debugFile`; @@ -204,6 +204,15 @@ $suggestions->set_binding( sub { $suggestions->draw(); $wlist->draw(); }, "p"); +$wlist->set_binding( sub { + my $video = splice(@watchlist,$wlist->get_active_id(),1); + $cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".splice(@watchArray,$wlist->get_active_id(),1)); + `mpv --ytdl-raw-options=cookies=$cookiesFile,mark-watched= --terminal=no https://www.youtube.com/watch?v=$video->{id}`; + sync2files(); + $win->draw(); + $suggestions->draw(); + $wlist->draw(); +} , "p"); $suggestions->set_binding( sub { splice(@videos,0,scalar(@videos)); splice(@suggestArray,0,scalar(@suggestArray)); @@ -222,6 +231,11 @@ $suggestions->set_binding( sub { my $vid = $videos[$suggestions->get_active_id()]; $cui->status("Video: ".$vid->{title}."\nChannel: ".$vid->{channel}."\nRuntime: ".$vid->{runtime}."\nPublished: ".$vid->{published}."\nURL: https://www.youtube.com/watch?v=".$vid->{id}); }, "i"); +$wlist->set_binding( sub { + my $vid = $videos[$wlist->get_active_id()]; + $cui->status("Video: ".$vid->{title}."\nChannel: ".$vid->{channel}."\nRuntime: ".$vid->{runtime}."\nPublished: ".$vid->{published}."\nURL: https://www.youtube.com/watch?v=".$vid->{id}); + +} , "i"); $suggestions->focus();