30 Nov 2015 18:56:22 UTC
- Distribution: WebService-Audioscrobbler
- Module version: 0.08
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (3)
- Testers (397 / 0 / 0)
- KwaliteeBus factor: 0
- 41.06% Coverage
- License: unknown
- Activity24 month
- Download (10.76KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionNILSONSFJ Nilson Santos Figueiredo Júnior
- COPYRIGHT & LICENSE
WebService::Audioscrobbler::DataFetcher - Cached data fetching provider
This is responsible for fetching and caching all data requested from Audioscrobbler WebServices, as recommended by their usage policy.
It can actually function as a generic XML-fetcher-and-converter-to-hashrefs and has no limitations regarding being used only for Audioscrobbler WebServices. In the future, it might even became a completely separate module.
use WebService::Audioscrobbler::DataFetcher; my $data_fetcher = WebService::Audioscrobbler::DataFetcher->new( "http://www.my-base-url.com/base_dir/" ); # retrieves "http://www.my-base-url.com/base_dir/myown/resource.xml" # and parses it through XML::Simple::XMLin so we get a hashref my $data = $data_fetcher->fetch("myown/resource.xml")
This is the base URL from where data will be fetched.
This is the underlying cache object. By default, this will be a Cache::FileCache object.
This is the root directory where the cache will be created. It should only be set as a parameter to
new(), setting it afterwards won't have any effect.
Creates a new object using either the given
\%fieldshashref. Any of the above fields can be specified. If the
cachefield is undefined,
create_cachewill be called after object construction.
Creates a new Cache::FileCache object and saves it in the
cachefield. The cache has a daily auto purging turned on and data will expire by default in 3 days, which is reasonable since most of Audioscrobbler data changes at most weekly. The cache root will be as specified by the
cache_rootfield (if it's undefined, Cache::FileCache defaults will be used).
Actually fetches a XML resource URL. If the resource is not already cached,
retrieve_datais called it's results are then cached. The results are then processed by
XML::Simple::XMLinso we end up with a nice hashref as our return value.
Retrieves data from the specified $uri using LWP::Simple and returns it.
Carp::croakwhich can be called as a method.
Nilson Santos Figueiredo Junior,
<nilsonsfj at cpan.org>
Copyright 2006-2007 Nilson Santos Figueiredo Junior, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install WebService::Audioscrobbler, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install WebService::Audioscrobbler
For more information on module installation, please visit the detailed CPAN module installation guide.