script/filmaffinity-get-ratings.pl untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 62 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2  
3 use strict;
4 use warnings;
5  
6 use Getopt::Long;
7 use Pod::Usage;
8  
9 use Readonly;
10 use IO::All -utf8;
11 use FilmAffinity::Utils qw/data2tsv/;
12 use FilmAffinity::UserRating;
13  
14 =head1 NAME
15  
16 filmaffinity-get-ratings.pl
17  
18 =head1 DESCRIPTION
19  
20 Get ratings from filmaffinity for a user and print them in Tab-separated values
21  
22 =head1 VERSION
23  
24 Version 1.01
25  
26 =head1 USAGE
27  
28 filmaffinity-get-rating.pl --userid=123456
29  
30 filmaffinity-get-rating.pl --userid=123456 --delay=2
31  
32 filmaffinity-get-rating.pl --userid=123456 --output=/home/william/myvote.list
33  
34 =head1 REQUIRED ARGUMENTS
35  
36 =over 2
37  
38 =item --userid=192076
39  
40 userid from filmaffinity
41  
42 =back
43  
44 =head1 OPTIONS
45  
46 =over 2
47  
48 =item --delay=3
49  
50 delay between requests
51  
52 =item --output=/home/william/rating.list
53  
54 output file
55  
56 =back
57  
58 =cut
59  
60 our $VERSION = '1.01';
61  
62 Readonly my $DELAY => 5;
63  
64 my ( $userID, $delay, $output, $help );
65  
66 GetOptions(
67 'userid=i' => \$userID,
68 'delay=i' => \$delay,
69 'output=s' => \$output,
70 'help' => \$help,
71 ) || pod2usage(2);
72  
73 if ( $help || !$userID ) {
74 pod2usage(1);
75 exit 0;
76 }
77  
78 my $userParser = FilmAffinity::UserRating->new(
79 userID => $userID,
80 delay => $delay || $DELAY,
81 );
82  
83 my $ref_movies = $userParser->parse();
84  
85 my $tsv = data2tsv($ref_movies);
86  
87 $output ? $tsv > io($output) : print $tsv;
88  
89 =head1 AUTHOR
90  
91 William Belle, C<< <william.belle at gmail.com> >>
92  
93 =head1 BUGS AND LIMITATIONS
94  
95 Please report any bugs or feature requests to C<bug-filmaffinity-userrating at rt.cpan.org>, or through
96 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FilmAffinity-UserRating>. I will be notified, and then you'll
97 automatically be notified of progress on your bug as I make changes.
98  
99 =head1 SUPPORT
100  
101 You can find documentation for this module with the perldoc command.
102  
103 perldoc filmaffinity-get-ratings.pl
104  
105 You can also look for information at:
106  
107 =over 4
108  
109 =item * RT: CPAN's request tracker (report bugs here)
110  
111 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=FilmAffinity-UserRating>
112  
113 =item * AnnoCPAN: Annotated CPAN documentation
114  
115 L<http://annocpan.org/dist/FilmAffinity-UserRating>
116  
117 =item * CPAN Ratings
118  
119 L<http://cpanratings.perl.org/d/FilmAffinity-UserRating>
120  
121 =item * Search CPAN
122  
123 L<http://search.cpan.org/dist/FilmAffinity-UserRating/>
124  
125 =back
126  
127 =head1 SEE ALSO
128  
129 L<http://www.filmaffinity.com>
130  
131 =head1 LICENSE AND COPYRIGHT
132  
133 Copyright 2013 William Belle.
134  
135 This program is free software; you can redistribute it and/or modify it
136 under the terms of either: the GNU General Public License as published
137 by the Free Software Foundation; or the Artistic License.
138  
139 See http://dev.perl.org/licenses/ for more information.
140  
141 =cut