--- /dev/null
+# (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
+# licensed under GNU GPL v2
+#
+# A getter which POSTs the JSONified metadata to a remote URL
+
+package videosite::HTTPJSONGetter;
+
+use videosite::GetterBase;
+@ISA = qw(videosite::GetterBase);
+
+use strict;
+use LWP::UserAgent;
+use JSON -support_by_pp;
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new();
+
+ $self->{'NAME'} = 'HTTPJSONGetter';
+ $self->{'_PARAMS'} = {'URL' => ['http://www.example.com/getjson.pl', "The URL to call in order to trigger a download. The JSON encoded information will be POSTed to this URL."]};
+
+ bless($self, $class);
+ $self->_prepare_parameters();
+
+ return $self;
+}
+
+sub get {
+ my $self = shift;
+ my $video = shift;
+ my $j = JSON->new();
+ my $ua = LWP::UserAgent->new('agent' => 'Mozilla/5.0');
+ my $jdata;
+ my $r;
+
+ $jdata = $j->encode($video);
+
+ $self->debug("Encoded metadata to %s", $jdata);
+ $r = $ua->post($self->_getval('URL'), {'json' => $jdata});
+ unless ($r->is_success()) {
+ $self->error("Error calling RPC: %s", $r->code());
+ return 0;
+ }
+
+ return 1;
+}