Skip to content

Commit 2d266b4

Browse files
committed
Uncache _get_youtubei_content.
1 parent c061f1c commit 2d266b4

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

lib/WWW/YoutubeViewer.pm

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ use warnings;
77
use Memoize;
88
use Memoize::Expire;
99

10-
tie my %youtubei_cache => 'Memoize::Expire',
11-
LIFETIME => 600, # in seconds
12-
NUM_USES => 2;
10+
#<<<
11+
#~ tie my %youtubei_cache => 'Memoize::Expire',
12+
#~ LIFETIME => 600, # in seconds
13+
#~ NUM_USES => 2;
1314

14-
memoize '_get_youtubei_content', SCALAR_CACHE => [HASH => \%youtubei_cache];
15+
#~ memoize '_get_youtubei_content', SCALAR_CACHE => [HASH => \%youtubei_cache];
16+
#>>>
1517

1618
#memoize('_get_video_info');
1719
memoize('_ytdl_is_available');
@@ -1079,14 +1081,16 @@ sub _get_youtubei_content {
10791081
$self->{lwp}->agent($android_useragent);
10801082
}
10811083

1084+
my $client_version = sprintf("2.%s.00.00", Time::Piece->new(time)->strftime("%Y%m%d"));
1085+
10821086
my %web = (
10831087
"videoId" => $videoID,
10841088
"context" => {
10851089
"client" => {
10861090
"hl" => "en",
10871091
"gl" => "US",
10881092
"clientName" => "WEB",
1089-
"clientVersion" => sprintf("2.%s.00.00", Time::Piece->new(time)->strftime("%Y%m%d")),
1093+
"clientVersion" => $client_version,
10901094
%args,
10911095
},
10921096
},
@@ -1099,25 +1103,14 @@ sub _get_youtubei_content {
10991103
"hl" => "en",
11001104
"gl" => "US",
11011105
"clientName" => "MWEB",
1102-
"clientVersion" => sprintf("2.%s.00.00", Time::Piece->new(time)->strftime("%Y%m%d")),
1106+
"clientVersion" => $client_version,
11031107
%args,
11041108
},
11051109
},
11061110
);
11071111

11081112
if (0) {
1109-
%android = (
1110-
"videoId" => $videoID,
1111-
"context" => {
1112-
"client" => {
1113-
"hl" => "en",
1114-
"gl" => "US",
1115-
"clientName" => "MWEB",
1116-
"clientVersion" => sprintf("2.%s.03.00", Time::Piece->new(time)->strftime("%Y%m%d")),
1117-
%args,
1118-
}
1119-
},
1120-
);
1113+
%android = %mweb;
11211114
}
11221115

11231116
local $self->{access_token} = undef;

lib/WWW/YoutubeViewer/Search.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ sub related_to_videoID {
167167
my $info = $entry->{videoWithContextRenderer} // next;
168168
my $title = $info->{headline}{runs}[0]{text} // next;
169169

170-
if (($info->{viewCountText}{simpleText} // '') =~ /Recommended for you/i) {
170+
if (($info->{shortViewCountText}{runs}[0]{text} // '') =~ /Recommended for you/i) {
171171
next; # filter out recommended videos from related videos
172172
}
173173

0 commit comments

Comments
 (0)