diff options
author | trizen <trizen@protonmail.com> | 2020-09-09 00:14:46 +0300 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-09-14 11:05:12 -0500 |
commit | 0ba7b35af0acd66807996abcf81d62517f4ad796 (patch) | |
tree | 77fd2d3afe1bb4f76a455877f17a7db6ba76a06d /bin | |
parent | 84b0a86c4575c8dd6144a6e61dd49901eaad62ff (diff) | |
download | fair-viewer-0ba7b35af0acd66807996abcf81d62517f4ad796.tar.lz fair-viewer-0ba7b35af0acd66807996abcf81d62517f4ad796.tar.xz fair-viewer-0ba7b35af0acd66807996abcf81d62517f4ad796.zip |
- Added support for loading cookies from a file.
The file must be a "# Netscape HTTP Cookie File"; same format as "hypervideo" requires.
The "cookies.txt" extension can be used for exporting the cookies from the browser.
This helps with the "429: Too Many Requests" issue.
See also: https://github.com/ytdl-org/hypervideo#how-do-i-pass-cookies-to-hypervideo
Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fair-viewer | 25 | ||||
-rwxr-xr-x | bin/gtk-fair-viewer | 20 |
2 files changed, 31 insertions, 14 deletions
diff --git a/bin/fair-viewer b/bin/fair-viewer index 6907290..b1a9c4b 100755 --- a/bin/fair-viewer +++ b/bin/fair-viewer @@ -16,7 +16,7 @@ #------------------------------------------------------- # fair-viewer # Fork: 14 February 2020 -# Edit: 06 September 2020 +# Edit: 09 September 2020 # https://framagit.org/heckyel/fair-viewer #------------------------------------------------------- @@ -218,6 +218,9 @@ my %CONFIG = ( # Others autoplay_mode => 0, http_proxy => undef, + cookie_file => undef, + user_agent => undef, + timeout => undef, env_proxy => 1, confirm => 0, debug => 0, @@ -602,13 +605,16 @@ my $yv_obj = WWW::FairViewer->new( escape_utf8 => 1, config_dir => $config_dir, cache_dir => $opt{cache_dir}, - lwp_env_proxy => $opt{env_proxy}, - authentication_file => $authentication_file, - ); + env_proxy => $opt{env_proxy}, + cookie_file => $opt{cookie_file}, + http_proxy => $opt{http_proxy}, + user_agent => $opt{user_agent}, + timeout => $opt{timeout}, + ); require WWW::FairViewer::Utils; my $yv_utils = WWW::FairViewer::Utils->new(youtube_url_format => $opt{youtube_video_url}, - thousand_separator => $opt{thousand_separator},); + thousand_separator => $opt{thousand_separator},); { # Apply the configuration file my %temp = %CONFIG; @@ -793,6 +799,8 @@ usage: $execname [options] ([url] | [keywords]) * Other --api=s : set an API host from https://instances.invidio.us/ --api=auto : use a random instance of invidious + --cookies=s : file to read cookies from and dump cookie + --user-agent=s : specify a custom user agent --proxy=s : set HTTP(S)/SOCKS proxy: 'proto://domain.tld:port/' If authentication required, use 'proto://user:pass\@domain.tld:port/' @@ -1094,7 +1102,8 @@ sub apply_configuration { publishedAfter publishedBefore safeSearch regionCode debug hl http_proxy page comments_order - subscriptions_order + subscriptions_order user_agent + cookie_file timeout ) ) { @@ -1515,7 +1524,9 @@ sub parse_arguments { 'related-videos|rv=s' => \$opt{related_videos}, 'popular-videos|popular|pv=s' => \$opt{popular_videos}, - 'http_proxy|http-proxy|proxy=s' => \$opt{http_proxy}, + 'cookie-file|cookies=s' => \$opt{cookie_file}, + 'user-agent|agent=s' => \$opt{user_agent}, + 'http-proxy|https-proxy|proxy=s' => \$opt{http_proxy}, 'catlang|cl|hl=s' => \$opt{hl}, 'category|cat-id|cat=s' => \$opt{category_id}, diff --git a/bin/gtk-fair-viewer b/bin/gtk-fair-viewer index 4020fd3..fadbf18 100755 --- a/bin/gtk-fair-viewer +++ b/bin/gtk-fair-viewer @@ -16,7 +16,7 @@ #------------------------------------------------------- # GTK Fair Viewer # Fork: 14 February 2020 -# Edit: 06 September 2020 +# Edit: 09 September 2020 # https://framagit.org/heckyel/fair-viewer #------------------------------------------------------- @@ -222,6 +222,9 @@ my %CONFIG = ( # Others env_proxy => 1, http_proxy => undef, + timeout => undef, + user_agent => undef, + cookie_file => undef, prefer_fork => (($^O eq 'linux') ? 0 : 1), debug => 0, fullscreen => 0, @@ -808,12 +811,14 @@ my $yv_obj = WWW::FairViewer->new( escape_utf8 => 1, config_dir => $config_dir, hl => $CONFIG{hl}, - lwp_env_proxy => $CONFIG{env_proxy}, + env_proxy => $CONFIG{env_proxy}, cache_dir => $CONFIG{cache_dir}, - authentication_file => $authentication_file, - ); + cookie_file => $CONFIG{cookie_file}, + user_agent => $CONFIG{user_agent}, + timeout => $CONFIG{timeout}, + ); -$yv_obj->load_authentication_tokens(); +#$yv_obj->load_authentication_tokens(); if (defined $yv_obj->get_access_token()) { show_user_panel(); @@ -824,7 +829,7 @@ else { require WWW::FairViewer::Utils; my $yv_utils = WWW::FairViewer::Utils->new(thousand_separator => $CONFIG{thousand_separator}, - youtube_url_format => $CONFIG{youtube_video_url},); + youtube_url_format => $CONFIG{youtube_video_url},); # Set default combobox values $definition_combobox->set_active(0); @@ -864,7 +869,8 @@ sub apply_configuration { videoEmbeddable videoLicense publishedAfter publishedBefore regionCode videoCategoryId - debug http_proxy + debug http_proxy user_agent + timeout cookie_file ) ) { |