Last.Fm Artist Description function

By xderek on Feb 05, 2008

I have created a small script which will take information about an artist from last fm. (how you manipulate this is up to you)

now im sure that my script probably isn't the best way of doing what it does, but it gets the job done. If anyone wants to add comments on how to make this better please go for it.


How it works.

  1. Artist is taken from url (http://EXAMPLE.php?artist=...)
    surely you can manipulate this to work however you want..

  2. File_Get_Contets takes the information from (http://www.last.fm/music/ARTIST/+wiki)

  3. str_pos is used to find the position of the text above and below where the artist description is.

  4. str_replace is used to replace all of this text and all of the text before and after the artist description

  5. all you are left with is you're artist description which is then simply echoed...

have fun, please comment.

<?php

$artist = urlencode($_GET['artist']);
$url = 'http://www.last.fm/music/'.$artist.'/+wiki';
$file = file_get_contents($url);

$factbook2 ='<div class=\"f\"><span class=\"iesucks\">&nbsp;</span></div>
</div></div>';

$thatline = '<div style=\"margin-top:20px; border-top:1px solid #CCC; padding-top:10px;\">';

$factbook2 = stripslashes($factbook2);
$factpos2 = strpos($file, $factbook2);

$desc = substr_replace($file, ' ', 0, $factpos2) . '';
$desc = str_replace($factbook2, ' ', $desc);
$thatline = stripslashes($thatline);
$thatlinepos = strpos($desc, $thatline);
$desc = substr_replace($desc, '', $thatlinepos, -1) . "<br />\n";

echo $desc;

?>

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.