line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Comic::Plugin::LeastICouldDo; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
36369
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
76
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
67
|
|
5
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
155
|
|
6
|
2
|
|
|
2
|
|
1834
|
use XML::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use vars qw($VERSION @ISA %COMICS); |
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
@ISA = qw(WWW::Comic::Plugin); |
11
|
|
|
|
|
|
|
%COMICS = (leasticoulddo => 'LeastICouldDo'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# $Id: LeastICouldDo.pm 388 2008-06-26 14:56:37Z davidp $ |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
WWW::Comic::Plugin::LeastICouldDo - WWW::Comic plugin to fetch LeastICouldDo comic |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
See L for full details, but here's a brief example: |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use WWW::Comic; |
25
|
|
|
|
|
|
|
my $wc = new WWW::Comic; |
26
|
|
|
|
|
|
|
my $latest_candh_strip_url |
27
|
|
|
|
|
|
|
= WWW::Comic->strip_url(comic => 'LeastICouldDo'); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
A plugin for L to fetch the LeastICouldDo comic from |
33
|
|
|
|
|
|
|
http://www.leasticoulddo.com/ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
See L and L for information on the WWW::Comic |
36
|
|
|
|
|
|
|
interface. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 FUNCTIONS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Constructor - see L for usage |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
|
|
|
|
|
|
my $class = shift; |
52
|
|
|
|
|
|
|
my $self = { homepage => 'http://www.leasticoulddo.com/' }; |
53
|
|
|
|
|
|
|
bless $self, $class; |
54
|
|
|
|
|
|
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item strip_url |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns the URL to the current strip image (or, if given the 'id' param, |
60
|
|
|
|
|
|
|
the URL to that particular strip) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub strip_url { |
65
|
|
|
|
|
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
my %param = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $stripstub = 'http://archive.leasticoulddo.com/strips'; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
if ($param{id}) { |
71
|
|
|
|
|
|
|
# we know what the URL will be |
72
|
|
|
|
|
|
|
# TODO: maybe fetch it to make sure it's actually valid? |
73
|
|
|
|
|
|
|
return "$stripstub/$param{id}.gif"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# the latest comic will be found at /strips/comic.gif - but that's not |
77
|
|
|
|
|
|
|
# much good for anything that expects each strip to have a different |
78
|
|
|
|
|
|
|
# URL. So, instead, we'll need to parse the RSS feed and return the |
79
|
|
|
|
|
|
|
# first comic from the feed (which will have the proper URL). |
80
|
|
|
|
|
|
|
my $feedurl = 'http://feeds.feedburner.com/LICD'; |
81
|
|
|
|
|
|
|
my $response = $self->_new_agent->get($feedurl); |
82
|
|
|
|
|
|
|
if ($response->is_success) { |
83
|
|
|
|
|
|
|
my $rss = XML::Simple::XMLin($response->content); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
if (!$rss) { |
86
|
|
|
|
|
|
|
carp "Failed to parse RSS feed"; |
87
|
|
|
|
|
|
|
return; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
item: |
91
|
|
|
|
|
|
|
for my $item (@{ $rss->{channel}->{item} }) { |
92
|
|
|
|
|
|
|
next item if $item->{category} ne 'Comic'; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
if (my($id) = $item->{guid}->{content} =~ m{comic/([0-9]+)$}) |
95
|
|
|
|
|
|
|
{ |
96
|
|
|
|
|
|
|
# bingo, found the first comic listed in the feed: |
97
|
|
|
|
|
|
|
return "$stripstub/$id.gif"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# we should not get here in normal operation: |
102
|
|
|
|
|
|
|
carp "Failed to find comics in RSS feed"; |
103
|
|
|
|
|
|
|
return; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} else { |
106
|
|
|
|
|
|
|
carp "Failed to fetch $feedurl - " . $response->status_line; |
107
|
|
|
|
|
|
|
return; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
David Precious, C<< >> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 BUGS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
122
|
|
|
|
|
|
|
C, |
123
|
|
|
|
|
|
|
or through the web interface at |
124
|
|
|
|
|
|
|
L. |
125
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
126
|
|
|
|
|
|
|
your bug as I make changes. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SUPPORT |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
perldoc WWW::Comic::Plugin::LeastICouldDo |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
You can also look for information at: |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * CPAN Ratings |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * Search CPAN |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
To Nicola Worthington (NICOLAW) for writing WWW::Comic |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Copyright 2008 David Precious, all rights reserved. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
170
|
|
|
|
|
|
|
under the same terms as Perl itself. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; # End of WWW::Comic::Plugin::LeastICouldDo |