1 # (c) 2010 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
6 package quotesite::AppNetGrabber;
8 use quotesite::GrabberBase;
9 @ISA = qw(quotesite::GrabberBase);
19 my $self = $class->SUPER::new();
21 $self->{'NAME'} = 'app.net';
22 $self->{'PATTERNS'} = ['(https?://alpha\.app\.net/[^/]+/post/(\d+))'];
25 $self->_prepare_parameters();
36 my $p = XML::Simple->new();
42 $metadata->{'URL'} = $url;
43 $metadata->{'ID'} = $2;
44 $metadata->{'TYPE'} = 'quote';
45 $metadata->{'SOURCE'} = $self->{'NAME'};
46 $metadata->{'CONTENT'} = undef;
48 # Get the JSON file containing the quote
49 unless(defined($content = $self->simple_get(sprintf('https://alpha-api.app.net/stream/0/posts/%s', $2)))) {
50 $self->error('Could not download quote');
54 unless(defined($t = JSON->new->utf8->decode($content))) {
55 $self->error('Could not parse JSON metadata');
59 $self->debug("JSON content: %s", Dumper($t));
61 $metadata->{'CONTENT'} = $t->{'data'}->{'text'};
62 $metadata->{'ID'} = $t->{'data'}->{'user'}->{'username'};
64 unless(defined($metadata->{'CONTENT'})) {
65 $self->error('Could not extract quote content');