use Config;
use POSIX;
use Encode;
+use Cwd 'abs_path';
use Getopt::Std;
use File::Basename;
use Socket;
our ($fexhome,$idf,$tmpdir,$windoof,$useragent);
our ($xv,%autoview);
our $bs = 2**16; # blocksize for tcp-reading and writing file
-our $version = 20160328;
+our $version = 20160919;
our $CTYPE = 'ISO-8859-1';
our $fexsend = $ENV{FEXSEND} || 'fexsend';
our $DEBUG = $ENV{DEBUG};
or: $0 [-v] -a
or: $0 -l [-i tag]
or: $0 -H
+ or: $0 -V
options: -v verbose mode
-m limit kB/s
-s save to filename (-s- means: write to STDOUT/pipe)
-i tag alternate server/account, see: $fexsend -h
-P use Proxy for connection to the F*EX server
-H show hints and examples
+ -V show version and ask for upgrade
argument: F*EX-URL may be file number (see: $0 -l)
EOD
$_ = <STDIN>||'';
if (/^y/i) {
my $new = `wget -nv -O- http://fex.belwue.de/download/fexget`;
- if ($new !~ /upgrade fexget/) {
+ my $newversion = $1 if $new =~ /version = (\d+)/;
+ if ($new !~ /upgrade fexget/ or not $newversion) {
die "$0: bad update\n";
}
- system qw'cp -a',$_0,$_0.'_old';
+ if ($newversion <= $version) {
+ die "$0: no newer version\n";
+ }
+ $_0 = abs_path($_0);
+ system qw'rsync -a',$_0,$_0.'_old';
exit $? if $?;
open $_0,'>',$_0 or die "$0: cannot write $_0. - $!\n";
print {$_0} $new;
exec $_0,qw'-V .';
}
}
+ exit;
exit if "@ARGV" eq '.';
}
($file) = grep { $_ = $1 if /^X-File:\s+(.+)/ } @r;
$file = $url unless $file;
$file =~ s:.*/::;
- printf "%s deleted\n",urldecode($file);
+ printf "%s deleted\n",locale(decode_utf8(urldecode($file)));
} else {
s:HTTP/[\d\. ]+::;
die "$0: server response: $_";