X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=videosite.pl;h=d87b5984fff28b5e01e19f961dc19a13d263c9c5;hb=c5b3d8327f58f02ce2cdcfba5742a4ca4fa2994d;hp=691ef04ceb1ce30ae34d4a3ca5296c68fbc5b637;hpb=542ba5f881a3de86e9d6b01c64dbdbcff172fbaf;p=videosite.git diff --git a/videosite.pl b/videosite.pl index 691ef04..d87b598 100644 --- a/videosite.pl +++ b/videosite.pl @@ -22,6 +22,7 @@ use vars qw($VERSION %IRSSI); use XML::Simple; use Data::Dumper; use File::Spec; +use File::Temp qw(tempfile); use BettIrssi 101 qw(_bcb _bcs); use LWP::UserAgent; @@ -153,7 +154,7 @@ sub expand_url_shortener { my $s = shift; my $os = ''; my @urlshortener = ( - 'is.\gd/[[:alnum:]]+', + 'is\.gd/[[:alnum:]]+', 'otf\.me/[[:alnum:]]+', 'hel\.me/[[:alnum:]]+', '7ax\.de/[[:alnum:]]+', @@ -162,11 +163,18 @@ sub expand_url_shortener { 'bit\.ly/[[:alnum:]]+', 'tinyurl\.com/[[:alnum:]]+', 'pop\.is/[[:alnum:]]+', + 'post\.ly/[[:alnum:]]+', + '1\.ly/[[:alnum:]]+', + '2\.ly/[[:alnum:]]+', + 't\.co/[[:alnum:]]+', + 'shar\.es/[[:alnum:]]+', + 'goo\.gl/[[:alnum:]]+', ); my $ua = LWP::UserAgent->new(agent => 'Mozilla', max_redirect => 0); my $i = 10; OUTER: while (($os ne $s) and ($i > 0)) { + study($s); $os = $s; $i--; @@ -253,10 +261,12 @@ sub check_for_link { sub cmd_save { + eval { - open(CONF, '>'.$conffile) or die 'Could not open config file'; - print CONF XML::Simple::XMLout($conf, KeepRoot => 1, KeyAttr => {'config' => 'module', 'option' => 'key'}); - close(CONF); + my ($tempfile, $tempfn) = tempfile("videosite.xml.XXXXXX", dir => Irssi::get_irssi_dir()); + print $tempfile XML::Simple::XMLout($conf, KeepRoot => 1, KeyAttr => {'config' => 'module', 'option' => 'key'}); + close($tempfile); + rename($tempfn, $conffile); }; if ($@) { write_irssi('Could not save config to %s: %s', ($conffile, $@));