Last.fm tool: How eclectic is your musical style?
Please consider
taking the updated super-eclectic test.
It\'s like level 2, for the \'leet only.
The following script takes the 20 top artists in your musical profile
from Last.fm, and finds the collection of top 5
similar artists for this top 20. The resulting is a list of artists similar
to your preferred artists. As the list is larger (maximum = 100), your
musical preference is more diverse.
Please be patient, the script may require up to a 30 seconds to
process your request. The script needs to download and analyze your profile
and your top 20 artists. Last.fm policy states that we can only make 1
request per second, and the script\'s worst case scenario requires 21
requests. Caching is used to lower the load on user (cache = 10 minutes) and
artist (cache = 1 week) database requests.
Also check out my scripts to compare your profile with that of other users, generate your personal musical tag cloud, or generate a cloud of recommended artists for your profile!
';
if( !$type )
$type = "overall";
if( $user ) {
// get user's top tags
$userfilename = "./users/" . $user . ".xml";
$userurl = "http://ws.audioscrobbler.com/1.0/user/$user/topartists.xml";
$xmlroot = "topartists";
if( $type == "weekly" ) {
$userfilename = "./weeklyusers/" . $user . ".xml";
$userurl = "http://ws.audioscrobbler.com/1.0/user/$user/weeklyartistchart.xml";
$xmlroot = "weeklyartistchart";
}
$userdata = getDataFrom( $userfilename, $userurl, 10*60 );
$data = XML_unserialize( $userdata );
// for each of the users, analyze his top artists
$similarartists;
$nrartists = 0;
if( $data[ $xmlroot ] )
if( $data[ $xmlroot ]['artist'] )
if( count( $data[ $xmlroot ]['artist'] ) > 0 )
foreach( $data[ $xmlroot ]['artist'] as $artist ) {
if( $nrartists < 20 ) {
$nrartists++;
$name = substr(strrchr($artist['url'], "/"), 1);
$playcount = $artist['playcount'];
// print( $name . " -> " . $playcount . "" );
$artistfilename = "./similarartists/" . $name . ".xml";
$artisturl = "http://ws.audioscrobbler.com/1.0/artist/$name/similar.xml";
$artistdata = getDataFrom( $artistfilename, $artisturl );
$data = XML_unserialize( $artistdata );
$similarcount = 0;
if( $data['similarartists'] )
if( $data['similarartists']['artist'] )
if( count( $data['similarartists']['artist'] ) > 1 )
foreach( $data['similarartists']['artist'] as $similarartist ) {
if( $similarcount < 5 ) {
$similarcount++;
$tagname = $similarartist['name'];
$similarartists[ $tagname ] ++;
}
}
if( $similarcount <= 0 )
$nrartists--;
}
}
ksort( $similarartists );
$eclecticscore = count( $similarartists );
echo "
How eclectic is the musical preference of $user?
";
echo "
$user's eclectic score is
" . count( $similarartists ) . "/100";
echo "
If your score is small (lower than 70) your musical preferences are very limited, and if it is large (larger than 80), then you have an eclectic musical preference.
";
echo "
BBCode!
";
echo "
The following BBCode can easily be copied to Last.fm forums, journals, ...
";
echo '
'."\n";
echo " Take your top 20 artists. For each of these artists, collect the top 5 similar artists. The resulting number of unique artists is your [b]eclectic score[/b]. If the score is small (extreme = 5) your musical preferences are very limited, and if it is large (larger than 80, extreme = 100), then you have an eclectic musical preference. You can compute your own score at http://anthony.liekens.net/pub/scripts/last.fm/eclectic.php \n\nMy eclectic score is currently\n\n[align=center][size=18][b]$eclecticscore/100[/b][/size][/align] \n\n";
echo "The $eclecticscore related artists for my profile are ";
$ocunt = 0;
foreach( $similarartists as $similarartist => $value ) {
$artist_unicode = unicode_to_entities( utf8_to_unicode( $similarartist ) );
if( $value > 1 )
echo $artist_unicode . " ($value)";
else
echo $artist_unicode;
if( $count < $eclecticscore - 1 )
echo ", ";
$count++;
}
echo " ";
echo ' |
'."\n";
echo "
Please do not add artist connections to the above BBCode if you want to post it, find out why here.
";
printLinks( $user, "eclectic" );
echo '
';
}
echo '