Skip to content

Commit

Permalink
CLI: added the :w=i STDIN option for saving a video to watch history.
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Jan 6, 2023
1 parent 7709a40 commit 71a9b70
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bin/youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ $action_options
:ps=i :s2p=i,i : save videos to a post-selected playlist
:sub(scribe)=i : subscribe to author's channel
:unsub(scribe)=i : unsubscribe from author's channel
:w=i :mark=i : add video to watched history
:(dis)like=i : like or dislike a video
:fav(orite)=i : favorite a video
:autoplay=i : autoplay mode, starting from video i
Expand Down Expand Up @@ -4452,6 +4453,7 @@ sub play_videos {
if (not download_video($streaming, $video)) {
return;
}
save_watched_video($video_id);
}
elsif (length($opt{extract_info})) {
my $fh = $opt{extract_info_fh} // \*STDOUT;
Expand Down Expand Up @@ -4483,9 +4485,10 @@ sub play_videos {
$opt{auto_next_page} = 0;
return;
}

save_watched_video($video_id);
}

save_watched_video($video_id);
press_enter_to_continue() if $opt{confirm};
}

Expand Down Expand Up @@ -5105,6 +5108,14 @@ sub print_videos {
warn_no_thing_selected('video');
}
}
elsif ($opt =~ /^(?:w|mark)${digit_or_equal_re}(.*)/) {
if (my @nums = get_valid_numbers($#{$videos}, $1)) {
save_watched_video($yv_utils->get_video_id($videos->[$_])) for @nums;
}
else {
warn_no_thing_selected('video');
}
}
elsif ($opt =~ /^(?:ap|autoplay)${digit_or_equal_re}(.*)/) {
if (my ($id) = get_valid_numbers($#{$videos}, $1)) {
local $opt{autoplay_mode} = 1;
Expand Down

0 comments on commit 71a9b70

Please sign in to comment.