Skip to content

Commit

Permalink
No longer include newlines in the message prompt for Term::ReadLine.
Browse files Browse the repository at this point in the history
This fixes a backspace key issue when Term::ReadLine::Gnu::XS is not installed.
  • Loading branch information
trizen committed Jun 15, 2020
1 parent ecd2990 commit 9398610
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 14 additions & 5 deletions bin/youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -1956,10 +1956,18 @@ sub get_user_input {
}

my $input = unpack(
'A*', defined($opt{std_input})
? delete($opt{std_input})
: ($term->readline($text) // return ':return')
) =~ s/^\s+//r;
'A*',
defined($opt{std_input})
? delete($opt{std_input})
: (
do {
my @lines = split(/\R/, $text);
say for @lines[0 .. $#lines - 1];
$term->readline($lines[-1]);
}
// return ':return'
)
) =~ s/^\s+//r;

return q{:next} if $input eq q{}; # <ENTER> for the next page

Expand Down Expand Up @@ -4169,7 +4177,8 @@ sub print_videos {
}

sub press_enter_to_continue {
scalar $term->readline(colored("\n=>> Press ENTER to continue...", 'bold'));
say '';
scalar $term->readline(colored("=>> Press ENTER to continue...", 'bold'));
}

sub main_quit {
Expand Down
4 changes: 2 additions & 2 deletions lib/WWW/YoutubeViewer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,12 @@ sub _extract_from_invidious {
invidious.13ad.de
);

my $tries = 2 * scalar(@instances);
my $instance = shift(@instances);
my $url_format = "https://%s/api/v1/videos/%s?fields=formatStreams,adaptiveFormats";
my $url = sprintf($url_format, $instance, $videoID);

my $tries = 2 * scalar(@instances);
my $resp = $self->{lwp}->get($url);
my $resp = $self->{lwp}->get($url);

while (not $resp->is_success() and $resp->status_line() =~ /read timeout/i and --$tries >= 0) {
$url = sprintf($url_format, shift(@instances), $videoID) if (@instances and ($tries % 2 == 0));
Expand Down

0 comments on commit 9398610

Please sign in to comment.