| 1 | #!/usr/bin/env perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Getopt::Long; | ||
| 7 | use Pod::Usage; | ||
| 8 | |||
| 9 | use IO::All -utf8; | ||
| 10 | use FilmAffinity::Utils qw/data2tsv/; | ||
| 11 | use FilmAffinity::UserRating; | ||
| 12 | |||
| 13 | =head1 NAME - filmaffinity-get-ratings.pl | ||
| 14 | |||
| 15 | get ratings from filmaffinity for a user print them in Tab-separated values | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | ./filmaffinity-get-rating.pl --userid=123456 | ||
| 20 | |||
| 21 | ./filmaffinity-get-rating.pl --userid=123456 --delay=2 | ||
| 22 | |||
| 23 | ./filmaffinity-get-rating.pl --userid=123456 --output=/home/william/myvote.list | ||
| 24 | |||
| 25 | =head1 ARGUMENTS | ||
| 26 | |||
| 27 | =over 2 | ||
| 28 | |||
| 29 | =item --userid=192076 | ||
| 30 | |||
| 31 | userid from filmaffinity | ||
| 32 | |||
| 33 | =back | ||
| 34 | |||
| 35 | =head1 OPTIONS | ||
| 36 | |||
| 37 | =over 2 | ||
| 38 | |||
| 39 | =item --delay=3 | ||
| 40 | |||
| 41 | delay between requests | ||
| 42 | |||
| 43 | =item --output=/home/william/rating.list | ||
| 44 | |||
| 45 | output file | ||
| 46 | |||
| 47 | =back | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | my ( $userID, $delay, $output, $help ); | ||
| 52 | |||
| 53 | GetOptions( | ||
| 54 | "userid=i" => \$userID, | ||
| 55 | "delay=i" => \$delay, | ||
| 56 | "output=s" => \$output, | ||
| 57 | "help" => \$help, | ||
| 58 | ) | ||
| 59 | || pod2usage(2); | ||
| 60 | |||
| 61 | if ( $help || !$userID ) { | ||
| 62 | pod2usage(1); | ||
| 63 | exit(0); | ||
| 64 | } | ||
| 65 | |||
| 66 | my $userParser = FilmAffinity::UserRating->new( | ||
| 67 | userID => $userID, | ||
| 68 | delay => $delay || 5, | ||
| 69 | ); | ||
| 70 | |||
| 71 | my $ref_movies = $userParser->parse(); | ||
| 72 | |||
| 73 | my $tsv = data2tsv( $ref_movies ); | ||
| 74 | |||
| 75 | $output ? $tsv > io($output) : print $tsv; | ||
| 76 | |||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | William Belle, C<< <william.belle at gmail.com> >> | ||
| 81 | |||
| 82 | =head1 SEE ALSO | ||
| 83 | |||
| 84 | L<http://www.filmaffinity.com> | ||
| 85 | |||
| 86 | =head1 LICENSE AND COPYRIGHT | ||
| 87 | |||
| 88 | Copyright 2013 William Belle. | ||
| 89 | |||
| 90 | This program is free software; you can redistribute it and/or modify it | ||
| 91 | under the terms of either: the GNU General Public License as published | ||
| 92 | by the Free Software Foundation; or the Artistic License. | ||
| 93 | |||
| 94 | See http://dev.perl.org/licenses/ for more information. | ||
| 95 | |||
| 96 | =cut |