Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
quotemeta() the filename of the cookie file when passing it to `youtu…
Browse files Browse the repository at this point in the history
…be-dl`.

This now allows the filename to contain shell metacharacters.
  • Loading branch information
trizen committed Sep 27, 2020
1 parent 00f98d9 commit eb9f04d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/WWW/StrawViewer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,11 @@ sub _extract_from_ytdl {
my $cookie_file = $self->get_cookie_file;

if (defined($cookie_file) and -f $cookie_file) {
push @ytdl_cmd, '--cookies', $cookie_file;
push @ytdl_cmd, '--cookies', quotemeta($cookie_file);
}

my $json = $self->proxy_stdout(@ytdl_cmd, quotemeta("https://www.youtube.com/watch?v=" . $videoID));

my $ref = $self->parse_json_string($json);
my $ref = $self->parse_json_string($json);

my @formats;
if (ref($ref) eq 'HASH' and exists($ref->{formats}) and ref($ref->{formats}) eq 'ARRAY') {
Expand Down
6 changes: 3 additions & 3 deletions lib/WWW/StrawViewer/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ sub related_to_videoID {

my $viewCount = 0;

if ($info->{viewCountText}{simpleText} =~ /^([\d,]+) views/) {
if (($info->{viewCountText}{simpleText} // '') =~ /^([\d,]+) views/) {
$viewCount = ($1 =~ tr/,//dr);
}
elsif ($info->{viewCountText}{simpleText} =~ /Recommended for you/i) {
elsif (($info->{viewCountText}{simpleText} // '') =~ /Recommended for you/i) {
next; # filter out recommended videos from related videos
}

my $lengthSeconds = 0;

if ($info->{lengthText}{simpleText} =~ /([\d:]+)/) {
if (($info->{lengthText}{simpleText} // '') =~ /([\d:]+)/) {
my $time = $1;
my @fields = split(/:/, $time);

Expand Down

0 comments on commit eb9f04d

Please sign in to comment.