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