# autodownload flash videos
#
-# (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
+# (c) 2007-2008 by Ralf Ertzinger <ralf@camperquake.de>
# licensed under GNU GPL v2
#
# Based on youtube.pl by Christian Garbs <mitch@cgarbs.de>
my $witem = shift;
my @text = @_;
+ $text[0] = 'videosite: ' . $text[0];
+
if (defined $witem) {
$witem->print(sprintf(shift(@text), @text), MSGLEVEL_CLIENTCRAP);
} else {
}
-sub write_verbose {
- if (Irssi::settings_get_bool('youtube_verbose')) {
- write_irssi(shift, @_);
- }
-}
-
sub write_debug {
if ($debug) {
write_irssi(shift, @_);
# 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');
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, 'Could not save config to %s: %s', ($conffile, $@));
+ } else {
+ write_irssi(undef, 'configuration saved to %s', $conffile);
+ }
}
sub cmd_set {
}
write_irssi(undef, 'No such module');
} else {
- write_irssi(undef,
- "Supported commands:\n".
- " save: Save the current configuration\n".
- " help [modulename]: Display this help, or module specific help\n".
- " show [modulename]: Show loaded modules, or the current parameters of a module\n".
- " set modulename parameter value: set a module parameter to a new value\n".
- " getter [modulename]: display or set the getter to use\n".
- " debug: enable debugging messages\n".
- " nodebug: disable debugging messages"
- );
+ write_irssi(undef, <<'EOT');
+Supported commands:
+ save: Save the current configuration
+ help [modulename]: Display this help, or module specific help
+ show [modulename]: Show loaded modules, or the current parameters of a module
+ set modulename parameter value: set a module parameter to a new value
+ getter [modulename]: display or set the getter to use
+ debug: enable debugging messages
+ nodebug: disable debugging messages
+EOT
}
}
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);
}