From 94b5c27bfb3106df005b6d315c664b4a20ff3e52 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 8 Nov 2011 01:38:57 +1300 Subject: [PATCH] it might be a module --- Changes | 6 +++ MANIFEST | 6 +++ Makefile.PL | 12 +++++ README | 33 ++++++++------ lib/Net/LastFMAPI.pm | 53 +++++++++++++++-------- t/{00-net-lastfmapi.t => Net-LastFMAPI.t} | 0 6 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 Changes create mode 100644 MANIFEST create mode 100644 Makefile.PL rename t/{00-net-lastfmapi.t => Net-LastFMAPI.t} (100%) diff --git a/Changes b/Changes new file mode 100644 index 0000000..2f65be8 --- /dev/null +++ b/Changes @@ -0,0 +1,6 @@ +Revision history for Perl extension Net::LastFMAPI. + +0.1 Tue Nov 8 01:04:46 2011 + - original version; created by h2xs 1.23 with options + -AX Net::LastFMAPI + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..744195a --- /dev/null +++ b/MANIFEST @@ -0,0 +1,6 @@ +Changes +Makefile.PL +MANIFEST +README +t/Net-LastFMAPI.t +lib/Net/LastFMAPI.pm diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..ac908d1 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,12 @@ +use 5.010001; +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + NAME => 'Net::LastFMAPI', + VERSION_FROM => 'lib/Net/LastFMAPI.pm', # finds $VERSION + PREREQ_PM => {}, # e.g., Module::Name => 1.1 + ($] >= 5.005 ? ## Add these new keywords supported since 5.005 + (ABSTRACT_FROM => 'lib/Net/LastFMAPI.pm', # retrieve abstract from module + AUTHOR => 'steve ') : ()), +); diff --git a/README b/README index 967a5b9..e51d4de 100644 --- a/README +++ b/README @@ -1,24 +1,29 @@ -README for Net::LastFMAPI -========================= +Net-LastFMAPI version 0.01 +========================== Functions for interacting with the LastFM API version 2.0. -Installing ----------- -The application is designed to be installed like a CPAN module; so use -the usual: +INSTALLATION - perl Makefile.PL - make - sudo make install +To install this module type the following: -The CPAN module dependencies will be highlighted during the first -command. If you do not have 'sudo' installed, you can use: + perl Makefile.PL + make + make test + make install - su root -c make install +DEPENDENCIES + +This module requires these other modules and libraries: + + LWP::UserAgent + Digest::MD5 + JSON::XS + File::Slurp + File::Path + +COPYRIGHT AND LICENCE -License and credits -------------------- Copyright (c) 2011, Steev Eeeriumn. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License diff --git a/lib/Net/LastFMAPI.pm b/lib/Net/LastFMAPI.pm index 52a05b3..dd43987 100644 --- a/lib/Net/LastFMAPI.pm +++ b/lib/Net/LastFMAPI.pm @@ -12,7 +12,7 @@ use Exporter 'import'; our @EXPORT = ('lastfm'); use Carp; -our $VERSION = 0.4; +our $VERSION = 0.1; our $url = 'http://ws.audioscrobbler.com/2.0/'; our $api_key = 'dfab9b1c7357c55028c84b9a8fb68880'; our $secret = 'd004c86dcfa8ef4c3977b04f558535f2'; @@ -342,36 +342,55 @@ Makes requests to http://ws.audioscrobbler.com/2.0/ and returns the result. Takes care of POSTing to write methods, doing authorisation when needed. -Dies upon error. +Dies if something went obviously wrong. -Will create an authorised session when needed, so unless you alter the subroutine -B it will print instructions to visit a link in your browser -to authorise itself with whoever is logged in. +=head1 THE SESSION KEY -After creating that session it is saved in the symlink -B<$ENV{HOME}/.net-lastfmapi-sessionkey>, you could alter B -to make this happen another way. + $Net::LastFMAPI::session_key = "secret" -Setting B<$Net::LastFMAPI::json> to a true value will automatically add -B "json"> to every request AND decode the result into perl data for you. -Not all methods support JSON. +It will be sought when an authorised request is needed. + +If it is not saved then on-screen instructions should be followed to authorise +with whoever is logged in to L. + +It is saved in the symlink B<$ENV{HOME}/.net-lastfmapi-sessionkey>. This is +probably fine. + +Consider altering the subroutines B, B, +or simply setting the B<$Net::LastFMAPI::session_key> before needing it. + +=head1 RETURN PERL DATA + + $Net::LastFMAPI::json = 1 + +This will automatically add B "json"> to every request B into perl data for you. + +Not all methods support JSON. Beware of "@attr" and empty elements turned into +whitespace strings instead of empty arrays. + +=head1 CACHING + + $Net::LastFMAPI::cache = 1 + + $Net::LastFMAPI::cache_dir = "$ENV{HOME}/.net-lastfmapi-cache/" + +Does caching. Default cache directory is shown. Good for development. =head1 SEE ALSO L doesn't handle sessions for you, won't POST to write methods -These are for the 1.2 API which is deprecated and I had no luck with them: -L -L -L +I had no luck with the 1.2 API modules: L, +L, L =head1 BUGS/CODE -L +L =head1 AUTHOR -Steev Eeeriumn +Steev Eeeriumn =head1 COPYRIGHT diff --git a/t/00-net-lastfmapi.t b/t/Net-LastFMAPI.t similarity index 100% rename from t/00-net-lastfmapi.t rename to t/Net-LastFMAPI.t