aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authortrizen <trizen@protonmail.com>2020-09-12 13:40:34 +0300
committerJesús <heckyel@hyperbola.info>2020-09-14 11:27:55 -0500
commit2cb7294df4a07c505f2a80c4c134812c0ee56f48 (patch)
treea6b2cc48b9e80d0519e231d977afa43bbea51b5c /bin
parentd4ed9a9222ca8f1941e0a810cd7e4df203568bd0 (diff)
downloadfair-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>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fair-viewer16
-rwxr-xr-xbin/gtk-fair-viewer36
2 files changed, 28 insertions, 24 deletions
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);
}