Added network checking so videos don't vanish into the ether when I lose wifi
This commit is contained in:
parent
d6527dce66
commit
575cf2705a
24
ytbrowser.pl
24
ytbrowser.pl
@ -13,7 +13,7 @@ use Curses::UI;
|
|||||||
#$Data::Dumper::Maxdepth = 1;
|
#$Data::Dumper::Maxdepth = 1;
|
||||||
|
|
||||||
my $homeDir = "/home/bluesaxman/";
|
my $homeDir = "/home/bluesaxman/";
|
||||||
my $cookiesFile = $homeDir.".scripts/cookies.txt";
|
my $cookiesFile = $homeDir."cookies.txt";
|
||||||
my $cachedFile = $homeDir.".yt_cache";
|
my $cachedFile = $homeDir.".yt_cache";
|
||||||
my $playlistFile = $homeDir.".yt_play";
|
my $playlistFile = $homeDir.".yt_play";
|
||||||
my $debugFile = $homeDir.".yt_last";
|
my $debugFile = $homeDir.".yt_last";
|
||||||
@ -198,22 +198,32 @@ $suggestions->set_binding( sub {
|
|||||||
$wlist->draw();
|
$wlist->draw();
|
||||||
}, KEY_ENTER);
|
}, KEY_ENTER);
|
||||||
$suggestions->set_binding( sub {
|
$suggestions->set_binding( sub {
|
||||||
my $video = shift(@watchlist);
|
my $video = $watchlist[0];
|
||||||
$cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".shift(@watchArray));
|
$cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".$watchArray[0]);
|
||||||
`mpv --ytdl-raw-options=cookies=$cookiesFile,mark-watched= --terminal=no https://www.youtube.com/watch?v=$video->{id}`;
|
my $success=`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($success) {
|
||||||
|
shift(@watchlist);}
|
||||||
sync2files();
|
sync2files();
|
||||||
$win->draw();
|
$win->draw();
|
||||||
$suggestions->draw();
|
$suggestions->draw();
|
||||||
$wlist->draw();
|
$wlist->draw();
|
||||||
|
} else {
|
||||||
|
$cui->status("PLAYBACK ERROR: Video not removed for safety.");
|
||||||
|
}
|
||||||
}, "p");
|
}, "p");
|
||||||
$wlist->set_binding( sub {
|
$wlist->set_binding( sub {
|
||||||
my $video = splice(@watchlist,$wlist->get_active_id(),1);
|
my $video = $watchlist[$wlist->get_active_id()];
|
||||||
$cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".splice(@watchArray,$wlist->get_active_id(),1));
|
$cui->status("Playing Video, controls will resume once video is compelte\n Currently Playing: ".$watchArray[$wlist->get_active_id()]);
|
||||||
`mpv --ytdl-raw-options=cookies=$cookiesFile,mark-watched= --terminal=no https://www.youtube.com/watch?v=$video->{id}`;
|
my $success=`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 ($success) {
|
||||||
|
splice(@watchlist,$wlist->get_active_id(),1);
|
||||||
sync2files();
|
sync2files();
|
||||||
$win->draw();
|
$win->draw();
|
||||||
$suggestions->draw();
|
$suggestions->draw();
|
||||||
$wlist->draw();
|
$wlist->draw();
|
||||||
|
} else {
|
||||||
|
$cui->status("PLAYBACK ERROR: Video not removed for safety.");
|
||||||
|
}
|
||||||
} , "p");
|
} , "p");
|
||||||
$suggestions->set_binding( sub {
|
$suggestions->set_binding( sub {
|
||||||
splice(@videos,0,scalar(@videos));
|
splice(@videos,0,scalar(@videos));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user