X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite.pl;h=da075cb6d22738e762be5d1f6f7e85c79d2372d9;hb=c114a610b17e4fc4842454ec71ff7c82c9d07859;hp=847e627c9498ad02dc42d5c547564156ec47a2c2;hpb=ffc24eec49bbdb6117e3a67e6080c119fba6575d;p=videosite.git diff --git a/videosite.pl b/videosite.pl index 847e627..da075cb 100644 --- a/videosite.pl +++ b/videosite.pl @@ -1,6 +1,6 @@ # autodownload flash videos # -# (c) 2007 by Ralf Ertzinger +# (c) 2007-2008 by Ralf Ertzinger # licensed under GNU GPL v2 # # Based on youtube.pl by Christian Garbs @@ -50,12 +50,6 @@ sub write_irssi { } -sub write_verbose { - if (Irssi::settings_get_bool('youtube_verbose')) { - write_irssi(shift, @_); - } -} - sub write_debug { if ($debug) { write_irssi(shift, @_); @@ -86,6 +80,7 @@ sub check_for_link { # Offer the message to all Grabbers in turn foreach $g (@grabbers) { if (defined($m = $g->get($message))) { + write_debug($witem, 'Metadata: %s', Dumper($m)); write_irssi($witem, '%%R>>> %%NSaving %%Y%s%%N %%G%s', $m->{'SOURCE'}, $m->{'TITLE'}); unless($getter->get($m)) { write_irssi($witem, '%%R>>> FAILED'); @@ -96,9 +91,16 @@ sub check_for_link { sub cmd_save { - open(CONF, '>'.$conffile); - print CONF XML::Simple::XMLout($conf, KeepRoot => 1, KeyAttr => {'config' => 'module', 'option' => 'key'}); - close(CONF); + 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); + }; + if ($@) { + write_irssi(undef, 'videosite: Could not save config to %s: %s', ($conffile, $@)); + } else { + write_irssi(undef, 'Videosite configuration saved to %s', $conffile); + } } sub cmd_set { @@ -271,6 +273,8 @@ sub init_videosite { Irssi::signal_add_first('command script load', 'sig_command_script_unload'); Irssi::signal_add_first('command script unload', 'sig_command_script_unload'); + Irssi::signal_add('setup saved', 'cmd_save'); + Irssi::command_bind('videosite' => \&cmdhandler); }