Skip to content

Commit

Permalink
- Added the bypass_age_gate_with_proxy config-option. (disabled by …
Browse files Browse the repository at this point in the history
…default)

When enabled, it will bypass age-restricted videos using an YouTube Account Proxy.

See also:

	https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/tree/main/account-proxy
  • Loading branch information
trizen committed Mar 24, 2022
1 parent f8f171d commit 6d2ff12
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 37 deletions.
6 changes: 4 additions & 2 deletions bin/gtk-youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ my %CONFIG = (
fullscreen => 0,
audio_only => 0,

ignored_projections => [],
bypass_age_gate_with_proxy => 0,
ignored_projections => [],

autolike_watched => 0,
autoscroll_to_end => 0,
Expand Down Expand Up @@ -944,6 +945,7 @@ sub apply_configuration {
debug http_proxy user_agent
timeout cookie_file ytdl ytdl_cmd
prefer_mp4 prefer_av1 force_fallback
bypass_age_gate_with_proxy
)
) {

Expand Down Expand Up @@ -2833,7 +2835,7 @@ sub get_subscription_video_results {
return get_results_from_list(ids => [reverse $yv_utils->read_lines_from_file($local_subscription_videos_file)]);
}

$t0 = time+1;
$t0 = time + 1;

my @channels = $yv_utils->read_channels_from_file($CONFIG{youtube_users_file});
my @channel_ids = map { $_->[0] } @channels;
Expand Down
10 changes: 8 additions & 2 deletions bin/youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ my %CONFIG = (
youtube_users_file => $youtube_users_file,
remove_played_file => 0,

ignored_projections => [],
bypass_age_gate_with_proxy => 0,
ignored_projections => [],

# Conversion options
convert_cmd => 'ffmpeg -i *IN* *OUT*',
Expand Down Expand Up @@ -1231,6 +1232,7 @@ sub apply_configuration {
subscriptions_order user_agent
cookie_file timeout ytdl ytdl_cmd
prefer_mp4 prefer_av1 force_fallback
bypass_age_gate_with_proxy
)
) {

Expand Down Expand Up @@ -3452,7 +3454,7 @@ sub print_local_subscription_videos {
return print_local_playlist($local_subscription_videos_file);
}

$t0 = time+1;
$t0 = time + 1;

my @channels = $yv_utils->read_channels_from_file($opt{youtube_users_file});
my @channel_ids = map { $_->[0] } @channels;
Expand Down Expand Up @@ -5184,6 +5186,10 @@ When set to C<1>, auto-generated captions will be retrieved. By default, auto-ge
Enable autoplay mode, which will continuously play related videos.
=head2 bypass_age_gate_with_proxy
Bypass age-restricted videos using an YouTube Account Proxy.
=head2 cache_dir
Cache directory where to save temporary files.
Expand Down
87 changes: 54 additions & 33 deletions lib/WWW/YoutubeViewer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ my %valid_options = (
ytdl_cmd => {valid => qr/\w/, default => "youtube-dl"},

# Booleans
env_proxy => {valid => [1, 0], default => 1},
escape_utf8 => {valid => [1, 0], default => 0},
prefer_mp4 => {valid => [1, 0], default => 0},
prefer_av1 => {valid => [1, 0], default => 0},
force_fallback => {valid => [1, 0], default => 0},
env_proxy => {valid => [1, 0], default => 1},
escape_utf8 => {valid => [1, 0], default => 0},
prefer_mp4 => {valid => [1, 0], default => 0},
prefer_av1 => {valid => [1, 0], default => 0},
force_fallback => {valid => [1, 0], default => 0},
bypass_age_gate_with_proxy => {valid => [1, 0], default => 0},

# API/OAuth
key => {valid => qr/^.{15}/, default => undef},
client_id => {valid => qr/^.{15}/, default => undef},
client_secret => {valid => qr/^.{15}/, default => undef},
redirect_uri => {valid => qr/^.{15}/, default => 'urn:ietf:wg:oauth:2.0:oob'},
access_token => {valid => qr/^.{15}/, default => undef},
refresh_token => {valid => qr/^.{15}/, default => undef},

authentication_file => {valid => qr/^./, default => undef},
key => {valid => qr/^.{15}/, default => undef},
client_id => {valid => qr/^.{15}/, default => undef},
client_secret => {valid => qr/^.{15}/, default => undef},
redirect_uri => {valid => qr/^.{15}/, default => 'urn:ietf:wg:oauth:2.0:oob'},
access_token => {valid => qr/^.{15}/, default => undef},
refresh_token => {valid => qr/^.{15}/, default => undef},
authentication_file => {valid => qr/^./, default => undef},

#<<<
# No input value allowed
Expand Down Expand Up @@ -481,7 +481,7 @@ sub lwp_post {
$self->{lwp}->post($url, (exists($opt{headers}) ? $opt{headers} : ()), @_);
},
%opt
);
);

if ($response->is_success) {
return $response->decoded_content;
Expand Down Expand Up @@ -656,24 +656,24 @@ sub select_good_invidious_instances {
ref($instances) eq 'ARRAY' or return;

my %ignored = (
'yewtu.be' => 1, # 403 Forbidden (API)
'invidious.tube' => 1, # down?
'invidiou.site' => 0,
'invidious.site' => 1, # AGPL Violation + trackers
'invidious.zee.li' => 1, # uses Cloudflare // 500 read timeout
'invidious.048596.xyz' => 1, # broken API
'invidious.xyz' => 1, # 502 Bad Gateway
'vid.mint.lgbt' => 0,
'invidious.ggc-project.de' => 1, # broken API
'invidious.toot.koeln' => 1, # broken API
'invidious.kavin.rocks' => 1, # 403 Forbidden (API)
'invidious.snopyta.org' => 0,
'invidious.silkky.cloud' => 0,
'invidious.moomoo.me' => 1, # uses Cloudflare
'y.com.cm' => 1, # uses Cloudflare
'invidious.exonip.de' => 1, # 403 Forbidden (API)
'invidious-us.kavin.rocks' => 1, # 403 Forbidden (API)
'invidious-jp.kavin.rocks' => 1, # 403 Forbidden (API)
'yewtu.be' => 1, # 403 Forbidden (API)
'invidious.tube' => 1, # down?
'invidiou.site' => 0,
'invidious.site' => 1, # AGPL Violation + trackers
'invidious.zee.li' => 1, # uses Cloudflare // 500 read timeout
'invidious.048596.xyz' => 1, # broken API
'invidious.xyz' => 1, # 502 Bad Gateway
'vid.mint.lgbt' => 0,
'invidious.ggc-project.de' => 1, # broken API
'invidious.toot.koeln' => 1, # broken API
'invidious.kavin.rocks' => 1, # 403 Forbidden (API)
'invidious.snopyta.org' => 0,
'invidious.silkky.cloud' => 0,
'invidious.moomoo.me' => 1, # uses Cloudflare
'y.com.cm' => 1, # uses Cloudflare
'invidious.exonip.de' => 1, # 403 Forbidden (API)
'invidious-us.kavin.rocks' => 1, # 403 Forbidden (API)
'invidious-jp.kavin.rocks' => 1, # 403 Forbidden (API)
);

#<<<
Expand Down Expand Up @@ -1230,7 +1230,28 @@ sub get_streaming_urls {

if (not defined $json->{streamingData}) {
say STDERR ":: Trying to bypass age-restricted gate..." if $self->get_debug;
%info = $self->_get_video_info($videoID, "clientScreen" => "EMBED");

if ($self->get_bypass_age_gate_with_proxy) {

# See:
# https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/tree/main/account-proxy

my $proxy_url = "https://youtube-proxy.zerody.one/getPlayer?";

$proxy_url .= $self->list_to_url_arguments(
videoId => $videoID,
reason => "LOGIN_REQUIRED",
clientName => "ANDROID",
clientVersion => "16.20",
hl => "en",
);

%info = (player_response => $self->lwp_get($proxy_url));
}
else {
%info = $self->_get_video_info($videoID, "clientScreen" => "EMBED");
}

$json = defined($info{player_response}) ? $self->parse_json_string($info{player_response}) : {};
}

Expand Down

0 comments on commit 6d2ff12

Please sign in to comment.