NAME
WWW::TinySong - Get free music links using TinySong
SYNOPSIS
# functional
use WWW::TinySong qw(tinysong);
for(tinysong("never gonna give you up")) {
printf("%s", $_->{song});
printf(" by %s", $_->{artist}) if $_->{artist};
printf(" on %s", $_->{album}) if $_->{album};
printf(" <%s>\n", $_->{url});
}
# object-oriented
use WWW::TinySong;
my $ts = new WWW::TinySong;
$ts->timeout(10);
$ts->env_proxy();
for($ts->tinysong("never gonna give you up")) {
printf("%s", $_->{song});
printf(" by %s", $_->{artist}) if $_->{artist};
printf(" on %s", $_->{album}) if $_->{album};
printf(" <%s>\n", $_->{url});
}
DESCRIPTION
TinySong is a web app that can be queried for a song and returns a tiny URL, allowing you to listen to the song for free online and share it with friends. WWW::TinySong is a Perl interface to this service, allowing you to programmatically search its underlying database.
FUNCTIONAL INTERFACE
The functional interface should be adequate for most users. If you need to customize the LWP::UserAgent used for the underlying retrievals, take a look at the object-oriented interface.
- tinysong ( QUERY_STRING [, LIMIT ] )
-
Searches the TinySong database for QUERY_STRING, giving up to LIMIT results. LIMIT defaults to 10 if not
defined
. Returns an array in list context or the top result in scalar context. Return elements are hashrefs with keysqw(album artist song url)
. Their values will be the empty string if not given by the website. Here's a quick script to demonstrate:#!/usr/bin/perl use WWW::TinySong qw(tinysong); use Data::Dumper; print Dumper tinysong("a hard day's night", 3);
...and its output on my system at the time of this writing:
$VAR1 = { 'album' => 'Golden Beatles', 'artist' => 'The Beatles', 'song' => 'A Hard Day\'s Night', 'url' => 'http://tinysong.com/2Cqe' }; $VAR2 = { 'album' => '', 'artist' => 'The Beatles', 'song' => 'A Hard Day\'s Night', 'url' => 'http://tinysong.com/2BI5' }; $VAR3 = { 'album' => 'The Beatles 1', 'artist' => 'The Beatles', 'song' => 'A Hard Day\'s Night', 'url' => 'http://tinysong.com/2Cqi' };
OBJECT-ORIENTED INTERFACE
CONSTRUCTORS
WWW::TinySong subclasses LWP::UserAgent, so you can use the same constructors. You could even bless
an existing LWP::UserAgent as WWW::TinySong, not that I'm recommending you do that.
METHODS
WWW::TinySong implements one more method in addition to the ones supported by LWP::UserAgent.
SEE ALSO
http://tinysong.com/, LWP::UserAgent
BUGS
Please report them.
AUTHOR
Miorel-Lucian Palii, <mlpalii@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Miorel-Lucian Palii
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.