use strict;
use warnings;
package PluginBase;
sub new {
my ($class, %params) = @_;
return bless {%params}, $class;
}
sub get_arg {
my ($self, $arg) = @_;
return $self->{command_args}{$arg};
}
sub quote_special {
my ($self, $data) = @_;
$data =~ s@\[@@g;
$data =~ s@\]@@g;
$data =~ s@\(@@g;
$data =~ s@\)@@g;
$data =~ s@\+@@g;
$data =~ s@\?@@g;
$data =~ s@\'@@g;
$data =~ s@\$@@g;
return $data;
}
sub get_raw_data {
my $self = shift;
return $self->{raw_data};
}
sub get_data {
my $self = shift;
return $self->{data};
}
1;
####
use strict;
use warnings;
package GetURL;
use base 'PluginBase';
sub new {
my ($class, %params) = @_;
return $class->SUPER::new (%params);
}
sub doit {
my $self = shift;
my $module = 'LWP::Simple';
return "Couldnt retrieve url" unless $module->use;
my $w_data = $self->get_arg ('url');
return "Couldnt find channel tag"
unless $self->get_raw_data () =~ m@(.*?)@s;
my $channel_data = $self->quote_special ($1);
my $result = '';
while ($channel_data =~ m@- (.*?)
@s) {
my $item_info = $1;
my $mask = $self->get_data ();
#the output mask is set to a copy of the data
#handed to the plugin
while ($mask =~ m@(.*?)@s) {
my $get_item = $1;
my $item_string;
$item_string = $1 if $item_info =~ m@<$get_item>(.*?)$get_item>@s;
$mask =~ s@$get_item@$item_string@;
}
$result .= $mask;
$channel_data =~ s@- $item_info
@@;
}
return $result;
}