fix quoting in AsyncWgetFileGetter again master
authorChristian Garbs <mitch@cgarbs.de>
Tue, 17 Nov 2015 23:20:22 +0000 (00:20 +0100)
committerChristian Garbs <mitch@cgarbs.de>
Tue, 17 Nov 2015 23:20:41 +0000 (00:20 +0100)
make youtube file https://www.youtube.com/watch?v=DDfRPtDsedA work

- ' was not quoted correctly: '\\'' does not work in shell, it has to be '"'"'

videosite/AsyncWgetFileGetter.pm

index 0cc6856..756b416 100644 (file)
@@ -66,14 +66,14 @@ sub _download {
     my $cookie = '';
     my $useragent = qq{ --user-agent='Mozilla/4.0 (compatible; MSIE 5.0; Linux) Opera 5.0  [en]' };
 
-    $dlfile =~ s/([\\'])/\\$1/g; # ???
-
+    $dlfile =~ s/'/'"'"'/g; # escape ' as '"'"' (end current 'string', new "string" containing a ', start new 'string')
+    
     my (undef, $tmpfile) = tempfile('videosite.tmp.XXXXXXXXXXXX', DIR => dirname($dlfile));
 
     $self->debug('Going to download %s to %s (%s)', $dlurl, $dlfile, $tmpfile);
 
     $cookie = qq{ --header='Cookie: $video->{'COOKIE'}'} if (defined $video->{'COOKIE'});
-    my $cmdline = qq{ ( wget -q -O'$tmpfile' $useragent $cookie '$video->{'DLURL'}' && mv '$tmpfile' '$dlfile' && chmod =rw '$dlfile' && touch '$dlfile' || rm -f '$tmpfile' ) & };
+    my $cmdline = qq{ ( wget -q -O'$tmpfile' $useragent $cookie '$dlurl' && mv '$tmpfile' '$dlfile' && chmod =rw '$dlfile' && touch '$dlfile' || rm -f '$tmpfile' ) & };
     $self->debug("Going to execute: %s", $cmdline);
     system($cmdline);