diff options
author | Jesús <heckyel@hyperbola.info> | 2020-03-02 08:18:54 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-03-02 08:18:54 -0500 |
commit | c67158fa409f1b1b4f98a8621a69bb2013b76451 (patch) | |
tree | bb4ca80f29cda70734a868d372e00c85e172e7d3 /bin | |
parent | ad7ec1785fc28799e10d10e7a679dc5bb4891ee3 (diff) | |
download | fair-viewer-c67158fa409f1b1b4f98a8621a69bb2013b76451.tar.lz fair-viewer-c67158fa409f1b1b4f98a8621a69bb2013b76451.tar.xz fair-viewer-c67158fa409f1b1b4f98a8621a69bb2013b76451.zip |
rebrand app
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fair-viewer (renamed from bin/straw-viewer) | 50 | ||||
-rwxr-xr-x | bin/gtk-fair-viewer (renamed from bin/gtk-straw-viewer) | 92 |
2 files changed, 71 insertions, 71 deletions
diff --git a/bin/straw-viewer b/bin/fair-viewer index 6fa34ef..525d2bb 100755 --- a/bin/straw-viewer +++ b/bin/fair-viewer @@ -13,25 +13,25 @@ # See https://dev.perl.org/licenses/ for more information. # #------------------------------------------------------- -# straw-viewer +# fair-viewer # Fork: 14 February 2020 # Edit: 14 February 2020 -# https://github.com/trizen/straw-viewer +# https://framagit.org/heckyel/fair-viewer #------------------------------------------------------- -# straw-viewer is a command line utility for streaming YouTube videos in mpv/vlc/mplayer. +# fair-viewer is a command line utility for streaming YouTube videos in mpv/vlc/mplayer. # This is a fork of youtube-viewer: # https://github.com/trizen/youtube-viewer =head1 NAME -straw-viewer - YouTube from command line. +fair-viewer - YouTube from command line. -See: straw-viewer --help - straw-viewer --tricks - straw-viewer --examples - straw-viewer --stdin-help +See: fair-viewer --help + fair-viewer --tricks + fair-viewer --examples + fair-viewer --stdin-help =head1 LICENSE AND COPYRIGHT @@ -58,8 +58,8 @@ no warnings 'once'; my $DEVEL; # true in devel mode use if ($DEVEL = 1), lib => qw(../lib); # devel mode -use WWW::StrawViewer v0.0.1; -use WWW::StrawViewer::RegularExpressions; +use WWW::FairViewer v0.0.1; +use WWW::FairViewer::RegularExpressions; use File::Spec::Functions qw( catdir @@ -73,9 +73,9 @@ use File::Spec::Functions qw( binmode(STDOUT, ':utf8'); -my $appname = 'CLI Straw Viewer'; -my $version = $WWW::StrawViewer::VERSION; -my $execname = 'straw-viewer'; +my $appname = 'CLI Fair Viewer'; +my $version = $WWW::FairViewer::VERSION; +my $execname = 'fair-viewer'; # A better <STDIN> support: require Term::ReadLine; @@ -214,8 +214,8 @@ my %CONFIG = ( get_captions => 1, auto_captions => 0, copy_caption => 0, - captions_dir => catdir(tmpdir(), 'straw-viewer'), - cache_dir => catdir(tmpdir(), 'straw-viewer'), + captions_dir => catdir(tmpdir(), 'fair-viewer'), + cache_dir => catdir(tmpdir(), 'fair-viewer'), # API api_host => "https://invidio.us", @@ -607,7 +607,7 @@ if ($opt{history}) { } } -my $yv_obj = WWW::StrawViewer->new( +my $yv_obj = WWW::FairViewer->new( escape_utf8 => 1, config_dir => $config_dir, cache_dir => $opt{cache_dir}, @@ -615,8 +615,8 @@ my $yv_obj = WWW::StrawViewer->new( authentication_file => $authentication_file, ); -require WWW::StrawViewer::Utils; -my $yv_utils = WWW::StrawViewer::Utils->new(youtube_url_format => $opt{youtube_video_url}, +require WWW::FairViewer::Utils; +my $yv_utils = WWW::FairViewer::Utils->new(youtube_url_format => $opt{youtube_video_url}, thousand_separator => $opt{thousand_separator},); { # Apply the configuration file @@ -845,7 +845,7 @@ sub wrap_text { sub tricks { print <<"TRICKS"; - == straw-viewer -- tips and tricks == + == fair-viewer -- tips and tricks == -> Playing videos > To stream the videos in other players, you need to change the @@ -1108,7 +1108,7 @@ sub apply_configuration { ) { if (defined $opt->{$option_name}) { - my $code = \&{"WWW::StrawViewer::set_$option_name"}; + my $code = \&{"WWW::FairViewer::set_$option_name"}; my $value = delete $opt->{$option_name}; my $set_value = $yv_obj->$code($value); @@ -3028,8 +3028,8 @@ sub get_streaming_url { # Download the closed-captions my $srt_file; if (ref($captions) eq 'ARRAY' and @$captions and $opt{get_captions} and not $opt{novideo}) { - require WWW::StrawViewer::GetCaption; - my $yv_cap = WWW::StrawViewer::GetCaption->new( + require WWW::FairViewer::GetCaption; + my $yv_cap = WWW::FairViewer::GetCaption->new( auto_captions => $opt{auto_captions}, captions_dir => $opt{captions_dir}, captions => $captions, @@ -3038,8 +3038,8 @@ sub get_streaming_url { $srt_file = $yv_cap->save_caption($video_id); } - require WWW::StrawViewer::Itags; - state $yv_itags = WWW::StrawViewer::Itags->new(); + require WWW::FairViewer::Itags; + state $yv_itags = WWW::FairViewer::Itags->new(); # Include DASH itags my $dash = 1; @@ -3499,7 +3499,7 @@ sub play_videos_matched_by_regex { my $regex = $args{regex}; my $videos = $args{videos}; - my $sub = \&{'WWW::StrawViewer::Utils' . '::' . 'get_' . $key}; + my $sub = \&{'WWW::FairViewer::Utils' . '::' . 'get_' . $key}; if (not defined &$sub) { warn colored("\n[!] Invalid key: <$key>.", 'bold red') . "\n"; diff --git a/bin/gtk-straw-viewer b/bin/gtk-fair-viewer index 828f496..6b6b424 100755 --- a/bin/gtk-straw-viewer +++ b/bin/gtk-fair-viewer @@ -13,10 +13,10 @@ # See https://dev.perl.org/licenses/ for more information. # #------------------------------------------------------- -# GTK Straw Viewer +# GTK Fair Viewer # Fork: 14 February 2020 # Edit: 14 February 2020 -# https://github.com/trizen/straw-viewer +# https://framagit.org/heckyel/fair-viewer #------------------------------------------------------- # This is a fork of youtube-viewer: @@ -31,8 +31,8 @@ no warnings 'once'; my $DEVEL; # true in devel mode use if ($DEVEL = 1), lib => qw(../lib); # devel only -use WWW::StrawViewer v0.0.1; -use WWW::StrawViewer::RegularExpressions; +use WWW::FairViewer v0.0.1; +use WWW::FairViewer::RegularExpressions; use Gtk3 qw(-init); use File::Spec::Functions qw( @@ -48,14 +48,14 @@ use File::Spec::Functions qw( binmode(STDOUT, ':utf8'); -my $appname = 'GTK+ Straw Viewer'; -my $version = $WWW::StrawViewer::VERSION; +my $appname = 'GTK+ Fair Viewer'; +my $version = $WWW::FairViewer::VERSION; # Share directory my $share_dir = ($DEVEL and -d "../share") ? '../share' - : do { require File::ShareDir; File::ShareDir::dist_dir('WWW-StrawViewer') }; + : do { require File::ShareDir; File::ShareDir::dist_dir('WWW-FairViewer') }; # Configuration dir/file my $home_dir; @@ -83,8 +83,8 @@ else { } # Configuration dir/file -my $config_dir = catdir($xdg_config_home, 'straw-viewer'); -my $config_file = catfile($config_dir, "gtk-straw-viewer.conf"); +my $config_dir = catdir($xdg_config_home, 'fair-viewer'); +my $config_file = catfile($config_dir, "gtk-fair-viewer.conf"); my $youtube_users_file = catfile($config_dir, 'users.txt'); my $history_file = catfile($config_dir, 'gtk-history.txt'); my $session_file = catfile($config_dir, 'session.dat'); @@ -189,7 +189,7 @@ my %CONFIG = ( hpaned_width => 250, hpaned_position => 420, - # Straw options + # Fair options dash_support => 1, dash_mp4_audio => 1, dash_segmented => 1, # may load slow @@ -222,8 +222,8 @@ my %CONFIG = ( srt_languages => ['en', 'es'], get_captions => 1, auto_captions => 0, - captions_dir => catdir(tmpdir(), 'straw-viewer'), - cache_dir => catdir(tmpdir(), 'straw-viewer'), + captions_dir => catdir(tmpdir(), 'fair-viewer'), + cache_dir => catdir(tmpdir(), 'fair-viewer'), # Others env_proxy => 1, @@ -241,15 +241,15 @@ my %CONFIG = ( web_browser => undef, # defaults to $ENV{WEBBROWSER} or xdg-open terminal => undef, # autodetect it later terminal_exec => q{-e '%s'}, - straw_viewer => undef, - straw_viewer_args => [], + fair_viewer => undef, + fair_viewer_args => [], youtube_users_file => $youtube_users_file, history => 1, history_limit => 100_000, history_file => $history_file, recent_history => 10, remember_session => 1, - remember_session_depth => 10, + remember_session_depth => 10, save_titles_to_history => 0, entry_completion_limit => 10, ); @@ -288,7 +288,7 @@ local $SIG{TERM} = \&on_mainw_destroy; local $SIG{INT} = \&on_mainw_destroy; # Locating the .glade interface file and icons dir -my $glade_file = catfile($share_dir, "gtk-straw-viewer.glade"); +my $glade_file = catfile($share_dir, "gtk-fair-viewer.glade"); my $icons_path = catdir($share_dir, 'icons'); # Defining GUI @@ -406,7 +406,7 @@ local $SIG{__DIE__} = sub { # Just print the third-party errors, # without displaying them to the user. - if (not $caller =~ /^(?:main\z|WWW::StrawViewer\b)/) { + if (not $caller =~ /^(?:main\z|WWW::FairViewer\b)/) { print STDERR "@_\n"; return; } @@ -429,7 +429,7 @@ local $SIG{__DIE__} = sub { }; #---------------------- LOAD IMAGES ----------------------# -my $app_icon_pixbuf = 'Gtk3::Gdk::Pixbuf'->new_from_file(catfile($icons_path, "gtk-straw-viewer.png")); +my $app_icon_pixbuf = 'Gtk3::Gdk::Pixbuf'->new_from_file(catfile($icons_path, "gtk-fair-viewer.png")); my $user_icon_pixbuf = 'Gtk3::Gdk::Pixbuf'->new_from_file_at_size(catfile($icons_path, "user.png"), 16, 16); my $feed_icon_pixbuf = 'Gtk3::Gdk::Pixbuf'->new_from_file_at_size(catfile($icons_path, "feed.png"), 16, 16); my $feed_icon_gray_pixbuf = 'Gtk3::Gdk::Pixbuf'->new_from_file_at_size(catfile($icons_path, "feed_gray.png"), 16, 16); @@ -463,7 +463,7 @@ if (not defined $CONFIG{cache_dir}) { $cache_dir = catdir(curdir(), '.cache'); } - $CONFIG{cache_dir} = catdir($cache_dir, 'straw-viewer'); + $CONFIG{cache_dir} = catdir($cache_dir, 'fair-viewer'); } foreach my $path($CONFIG{cache_dir}, $CONFIG{captions_dir}) { @@ -803,10 +803,10 @@ my %ResultsHistory = ( results => [], ); -# Locate CLI straw-viewer -$CONFIG{straw_viewer} //= which_command('straw-viewer') // 'straw-viewer'; +# Locate CLI fair-viewer +$CONFIG{fair_viewer} //= which_command('fair-viewer') // 'fair-viewer'; -my $yv_obj = WWW::StrawViewer->new( +my $yv_obj = WWW::FairViewer->new( escape_utf8 => 1, config_dir => $config_dir, hl => $CONFIG{hl}, @@ -824,8 +824,8 @@ else { $statusbar->push(1, 'Not logged in.'); } -require WWW::StrawViewer::Utils; -my $yv_utils = WWW::StrawViewer::Utils->new(thousand_separator => $CONFIG{thousand_separator}, +require WWW::FairViewer::Utils; +my $yv_utils = WWW::FairViewer::Utils->new(thousand_separator => $CONFIG{thousand_separator}, youtube_url_format => $CONFIG{youtube_video_url},); # Set default combobox values @@ -871,7 +871,7 @@ sub apply_configuration { ) { if (defined $CONFIG{$option_name}) { - my $code = \&{"WWW::StrawViewer::set_$option_name"}; + my $code = \&{"WWW::FairViewer::set_$option_name"}; my $value = $CONFIG{$option_name}; my $set_value = $yv_obj->$code($value); @@ -1046,7 +1046,7 @@ sub menu_popup { $menu->append($item); } - # Straw comments + # Fair comments { my $item = 'Gtk3::ImageMenuItem'->new("YouTube comments"); $item->set_image('Gtk3::Image'->new_from_icon_name("edit-copy", q{menu})); @@ -1343,11 +1343,11 @@ sub menu_popup { $menu->append($item); } - # Play with CLI straw-viewer + # Play with CLI fair-viewer { my $item = 'Gtk3::ImageMenuItem'->new("Play in terminal"); - $item->signal_connect(activate => \&play_selected_video_with_cli_straw_viewer); - $item->set_property(tooltip_text => "Play with straw-viewer in a new terminal"); + $item->signal_connect(activate => \&play_selected_video_with_cli_fair_viewer); + $item->set_property(tooltip_text => "Play with fair-viewer in a new terminal"); $item->set_image('Gtk3::Image'->new_from_icon_name("computer", q{menu})); $item->show; $menu->append($item); @@ -1412,7 +1412,7 @@ $accel->connect(ord('l'), ['control-mask'], ['visible'], \&show_login_to_youtube $accel->connect(ord('p'), ['control-mask'], ['visible'], \&show_preferences_window); $accel->connect(ord('q'), ['control-mask'], ['visible'], \&on_mainw_destroy); $accel->connect(ord('u'), ['control-mask'], ['visible'], \&show_users_list_window); -$accel->connect(ord('y'), ['control-mask'], ['visible'], \&run_cli_straw_viewer); +$accel->connect(ord('y'), ['control-mask'], ['visible'], \&run_cli_fair_viewer); $accel->connect(ord('d'), ['control-mask'], ['visible'], \&show_details_window); #$accel->connect(ord('c'), ['control-mask'], ['visible'], \&show_comments_window); @@ -2378,7 +2378,7 @@ sub get_code { } : $type eq 'video' ? ( $CONFIG{audio_only} - ? execute_cli_straw_viewer("--id=$code") + ? execute_cli_fair_viewer("--id=$code") : play_video($yv_obj->parse_json_string($liststore->get($iter, 8))) ) : (); @@ -2986,8 +2986,8 @@ sub get_streaming_url { # Download the closed-captions my $srt_file; if (ref($captions) eq 'ARRAY' and @$captions and $CONFIG{get_captions}) { - require WWW::StrawViewer::GetCaption; - my $yv_cap = WWW::StrawViewer::GetCaption->new( + require WWW::FairViewer::GetCaption; + my $yv_cap = WWW::FairViewer::GetCaption->new( auto_captions => $CONFIG{auto_captions}, captions_dir => $CONFIG{captions_dir}, captions => $captions, @@ -2996,8 +2996,8 @@ sub get_streaming_url { $srt_file = $yv_cap->save_caption($video_id); } - require WWW::StrawViewer::Itags; - state $yv_itags = WWW::StrawViewer::Itags->new(); + require WWW::FairViewer::Itags; + state $yv_itags = WWW::FairViewer::Itags->new(); my ($streaming, $resolution) = $yv_itags->find_streaming_url( @@ -3163,8 +3163,8 @@ sub clear_text { return 0; } -sub run_cli_straw_viewer { - execute_cli_straw_viewer('--interactive'); +sub run_cli_fair_viewer { + execute_cli_fair_viewer('--interactive'); } sub get_options_as_arguments { @@ -3246,22 +3246,22 @@ sub enqueue_video { sub play_enqueued_videos { if (@VIDEO_QUEUE) { - execute_cli_straw_viewer('--video-ids=' . join(q{,}, splice @VIDEO_QUEUE)); + execute_cli_fair_viewer('--video-ids=' . join(q{,}, splice @VIDEO_QUEUE)); } return 1; } -sub play_selected_video_with_cli_straw_viewer { +sub play_selected_video_with_cli_fair_viewer { my ($code, $iter) = get_selected_entry_code(); $code // return; my $type = $liststore->get($iter, 7); if ($type eq 'video') { - execute_cli_straw_viewer("--video-id=$code"); + execute_cli_fair_viewer("--video-id=$code"); } elsif ($type eq 'playlist') { - execute_cli_straw_viewer("--pp=$code"); + execute_cli_fair_viewer("--pp=$code"); } else { warn "Can't play $type: $code\n"; @@ -3270,7 +3270,7 @@ sub play_selected_video_with_cli_straw_viewer { return 1; } -sub execute_cli_straw_viewer { +sub execute_cli_fair_viewer { my @arguments = @_; my $command = join( @@ -3279,21 +3279,21 @@ sub execute_cli_straw_viewer { sprintf( $CONFIG{terminal_exec}, join(q{ }, - $CONFIG{straw_viewer}, get_options_as_arguments(), - @arguments, @{$CONFIG{straw_viewer_args}}), + $CONFIG{fair_viewer}, get_options_as_arguments(), + @arguments, @{$CONFIG{fair_viewer_args}}), ) ); my $code = execute_external_program($command); say $command if $yv_obj->get_debug; - warn "straw-viewer - exit code: $code\n" if $code != 0; + warn "fair-viewer - exit code: $code\n" if $code != 0; return 1; } sub download_video { my $code = get_selected_entry_code(type => 'video') // return; - execute_cli_straw_viewer("--video-id=$code", '--download'); + execute_cli_fair_viewer("--video-id=$code", '--download'); return 1; } |