diff options
author | trizen <trizen@protonmail.com> | 2020-09-12 13:40:34 +0300 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-09-14 11:27:55 -0500 |
commit | 2cb7294df4a07c505f2a80c4c134812c0ee56f48 (patch) | |
tree | a6b2cc48b9e80d0519e231d977afa43bbea51b5c | |
parent | d4ed9a9222ca8f1941e0a810cd7e4df203568bd0 (diff) | |
download | fair-viewer-2cb7294df4a07c505f2a80c4c134812c0ee56f48.tar.lz fair-viewer-2cb7294df4a07c505f2a80c4c134812c0ee56f48.tar.xz fair-viewer-2cb7294df4a07c505f2a80c4c134812c0ee56f48.zip |
Suggest trying "--api=auto" when the current invidious instance fails.
Signed-off-by: Jesús <heckyel@hyperbola.info>
-rw-r--r-- | README.md | 8 | ||||
-rwxr-xr-x | bin/fair-viewer | 16 | ||||
-rwxr-xr-x | bin/gtk-fair-viewer | 36 | ||||
-rw-r--r-- | lib/WWW/FairViewer.pm | 8 |
4 files changed, 36 insertions, 32 deletions
@@ -98,19 +98,19 @@ To package this application, run the following commands: ### INVIDIOUS INSTANCES -Sometimes, the default instance, [invidious.snopyta.org](https://invidious.snopyta.org/), may fail to work properly. When this happens, we can change the API host to some other instance of invidious, such as [invidious.13ad.de](https://invidious.13ad.de/). +Sometimes, the default instance, [invidious.snopyta.org](https://invidious.snopyta.org/), may fail to work properly. When this happens, we can change the API host to some other instance of invidious, such as [invidious.tube](https://invidious.tube/): ```console - fair-viewer --api=invidious.13ad.de + fair-viewer --api=invidious.tube ``` To make the change permanent, set in the configuration file: ```perl - api_host => "invidious.13ad.de", + api_host => "invidious.tube", ``` -Alternatively, by setting `api_host` to `"auto"`, fair-viewer will automatically pick a random invidious instance: +Alternatively, the following will automatically pick a random invidious instance everytime the program is started: ```perl api_host => "auto", diff --git a/bin/fair-viewer b/bin/fair-viewer index cb3bf05..0414696 100755 --- a/bin/fair-viewer +++ b/bin/fair-viewer @@ -59,7 +59,7 @@ use warnings; no warnings 'once'; my $DEVEL; # true in devel mode -use if ($DEVEL = 0), lib => qw(../lib); # devel only +use if ($DEVEL = 0), lib => qw(../lib); # devel mode use WWW::FairViewer v1.0.4; use WWW::FairViewer::RegularExpressions; @@ -175,7 +175,7 @@ my %CONFIG = ( video_player_selected => ( $constant{win32} ? 'vlc' - : undef # auto-defined + : undef # auto-defined ), # YouTube options @@ -203,7 +203,7 @@ my %CONFIG = ( regionCode => undef, # URI options - youtube_video_url => 'https://invidio.us/watch?v=%s', + youtube_video_url => 'https://www.youtube.com/watch?v=%s', # Subtitle options srt_languages => ['en', 'es'], @@ -3592,9 +3592,6 @@ sub print_video_info { sub print_videos { my ($results, %args) = @_; - # use Data::Dump qw(pp); - # pp $results; - if (not $yv_utils->has_entries($results)) { warn_no_results("video"); } @@ -3611,8 +3608,11 @@ sub print_videos { } if (ref($videos) ne 'ARRAY') { - say "\n:: Probably ", $yv_obj->get_api_host, " is down. Try:"; - say "\n\t$0 --api=invidious.13ad.de\n"; + + my $current_instance = $yv_obj->get_api_host(); + + say "\n:: Probably $current_instance is down. Try:"; + say "\n\t$0 --api=auto\n"; say "See also: https://libregit.org/heckyel/fair-viewer#invidious-instances"; return; } diff --git a/bin/gtk-fair-viewer b/bin/gtk-fair-viewer index 8cd773a..dcc787b 100755 --- a/bin/gtk-fair-viewer +++ b/bin/gtk-fair-viewer @@ -24,13 +24,13 @@ # https://github.com/trizen/youtube-viewer use utf8; -use 5.014; +use 5.016; use warnings; no warnings 'once'; my $DEVEL; # true in devel mode -use if ($DEVEL = 1), lib => qw(../lib); # devel only +use if ($DEVEL = 0), lib => qw(../lib); # devel only use WWW::FairViewer v1.0.4; use WWW::FairViewer::RegularExpressions; @@ -209,9 +209,9 @@ my %CONFIG = ( # URI options thumbnail_type => 'medium', - youtube_video_url => 'https://invidio.us/watch?v=%s', - youtube_playlist_url => 'https://invidio.us/playlist?list=%s', - youtube_channel_url => 'https://invidio.us/channel/%s', + youtube_video_url => 'https://www.youtube.com/watch?v=%s', + youtube_playlist_url => 'https://www.youtube.com/playlist?list=%s', + youtube_channel_url => 'https://www.youtube.com/channel/%s', # Subtitle options srt_languages => ['en', 'es'], @@ -476,7 +476,7 @@ foreach my $path($CONFIG{cache_dir}) { { my $split_string = sub { - grep { $_ ne '' } split(/\W+/, lc($_[0])); + grep { $_ ne '' } split(/\W+/, CORE::fc($_[0])); }; my %history_dict; @@ -537,7 +537,7 @@ foreach my $path($CONFIG{cache_dir}) { } foreach my $token (@tokens) { - @matches = grep { index(lc($_), $token) != -1 } @matches; + @matches = grep { index(CORE::fc($_), $token) != -1 } @matches; } my $store = Gtk3::ListStore->new(['Glib::String']); @@ -643,7 +643,7 @@ foreach my $path($CONFIG{cache_dir}) { else { unshift @search_history, $line; } - undef $history{lc($line)}; + undef $history{CORE::fc($line)}; } require List::Util; @@ -726,7 +726,7 @@ foreach my $path($CONFIG{cache_dir}) { my $str = join(' ', split(' ', $text)); - if ($is_search_keyword or not exists $history{lc($str)}) { + if ($is_search_keyword or not exists $history{CORE::fc($str)}) { if (set_history()) { if ($is_search_keyword) { @@ -736,7 +736,7 @@ foreach my $path($CONFIG{cache_dir}) { say {$history_fh} "~" . $str; } } - undef $history{$str}; + undef $history{CORE::fc($str)}; update_history_dict($str); } } @@ -1382,7 +1382,7 @@ set_text( CTRL+H : help window CTRL+L : login window CTRL+P : preferences window - CTRL+Y : start CLI fair viewer + CTRL+Y : start CLI Fair Viewer CTRL+E : enqueue the selected video CTRL+U : show the saved user-list @@ -2538,10 +2538,14 @@ sub display_results { } if (ref($items) ne 'ARRAY') { + + my $current_instance = $yv_obj->get_api_host(); + $yv_obj->pick_and_set_random_instance(); # set a random invidious instance + die - "Probably " . $yv_obj->get_api_host() . " is down.\n" + "Probably $current_instance is down.\n" . "\nTry changing the `api_host` in configuration file:\n\n" - . qq{\tapi_host => "invidious.13ad.de",\n} + . qq{\tapi_host => "auto",\n} . qq{\nSee also: https://libregit.org/heckyel/fair-viewer#invidious-instances\n}; } @@ -2654,9 +2658,9 @@ sub display_results { #$item->{__is_video__} = 1; # Store the video title to history (when `save_titles_to_history` is true) - #if ($CONFIG{save_titles_to_history}) { - # append_to_history($yv_utils->get_title($item), 0); - #} + if ($CONFIG{save_titles_to_history}) { + append_to_history($yv_utils->get_title($item), 0); + } add_video_entry($item); } diff --git a/lib/WWW/FairViewer.pm b/lib/WWW/FairViewer.pm index 44bd1b2..11a8bba 100644 --- a/lib/WWW/FairViewer.pm +++ b/lib/WWW/FairViewer.pm @@ -686,15 +686,15 @@ sub _extract_from_invidious { if (@instances) { require List::Util; @instances = List::Util::shuffle(map { $_->[0] } @instances); - push @instances, 'invidious.13ad.de'; + #push @instances, 'invidious.13ad.de'; } else { @instances = qw( - invidious.13ad.de - invidious.fdn.fr - invidious.site invidious.tube + invidious.site + invidious.fdn.fr invidious.snopyta.org + invidious.13ad.de ); } |