diff options
author | trizen <trizen@protonmail.com> | 2020-06-15 15:40:34 +0300 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-06-15 15:40:34 +0300 |
commit | 48d5267401926628bfab8abc61b2247ec3dede23 (patch) | |
tree | d10693c8f45ec5073e705a2119628a1b2ef61ca2 | |
parent | 71bc58c94d416d6660e562f642674fb603c1bfcc (diff) | |
download | fair-viewer-48d5267401926628bfab8abc61b2247ec3dede23.tar.lz fair-viewer-48d5267401926628bfab8abc61b2247ec3dede23.tar.xz fair-viewer-48d5267401926628bfab8abc61b2247ec3dede23.zip |
Handle some potential corner cases.
-rwxr-xr-x | bin/fair-viewer | 18 | ||||
-rw-r--r-- | lib/WWW/FairViewer.pm | 2 |
2 files changed, 16 insertions, 4 deletions
diff --git a/bin/fair-viewer b/bin/fair-viewer index 6e391ad..bb30e6a 100755 --- a/bin/fair-viewer +++ b/bin/fair-viewer @@ -397,7 +397,7 @@ EOD my $dumped_config = q{our $CONFIG = } . Data::Dump::pp(\%CONFIG) . "\n"; - if ($home_dir eq $ENV{HOME}) { + if (defined($ENV{HOME}) and $home_dir eq $ENV{HOME}) { $dumped_config =~ s/\Q$home_dir\E/\$ENV{HOME}/g; } @@ -513,7 +513,7 @@ sub load_config { # Enable history if Term::ReadLine::Gnu::XS is installed if (not defined $CONFIG{history}) { - if ($term->can('ReadHistory')) { + if (eval { $term->can('ReadHistory') }) { $CONFIG{history} = 1; } else { @@ -561,12 +561,24 @@ if ($opt{history}) { # Create the history file. if (not -e $opt{history_file}) { + + require File::Basename; + my $dir = File::Basename::dirname($opt{history_file}); + + if (not -d $dir) { + require File::Path; + File::Path::make_path($dir) + or warn "[!] Can't create path <<$dir>>: $!"; + } + open my $fh, '>', $opt{history_file} or warn "[!] Can't create the history file `$opt{history_file}': $!"; } # Add history to Term::ReadLine - $term->ReadHistory($opt{history_file}); + if (eval { $term->can('ReadHistory') }) { + $term->ReadHistory($opt{history_file}); + } # All history entries my @history = $term->history_list; diff --git a/lib/WWW/FairViewer.pm b/lib/WWW/FairViewer.pm index 71a1389..d70d82d 100644 --- a/lib/WWW/FairViewer.pm +++ b/lib/WWW/FairViewer.pm @@ -548,7 +548,7 @@ sub _make_feed_url { sub _extract_from_invidious { my ($self, $videoID) = @_; - my $url = sprintf("https://invidio.us/api/v1/videos/%s?fields=formatStreams,adaptiveFormats", $videoID); + my $url = sprintf($self->get_api_url . "videos/%s?fields=formatStreams,adaptiveFormats", $videoID); my $tries = 3; my $resp = $self->{lwp}->get($url); |