Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    3,285
    Tokens
    0

    Latest Awards:

    Default [RELEASE] LastLib

    Because I'm rather kind and all, I've decided to release LastLib, a music data fetcher that I've decided to tweak up. It was originally going to be used with me, Tom and Ryan's project called DiskDock, but that fell over so I might as well release this for free. Feel free to use it however you want

    It should be pretty self explanatory. It fetches details of artists and albums from the social music website Last.fm. All the data is very accurated, and it is a big database with pretty much everything. All you need to do is call one of the functions, and it'll do it's thanggg! Enjoy!



    PHP Code:
    <?php
    # LastLib
    # by Tim Rogers
    # with thanks to Ryan, Tom and Audioscrobbler
    # library.inc.php
    # REQUIRES SIMPLEXML (INLCUDED in PHP5)


    function createXmlObject($url) {
        
    error_reporting(0);
        
    $xml file_get_contents($url) or die("<span style='color: red; font-family: Verdana; font-size: 10px;'><b>ERROR:</b> Please try again later. Artist or album may be incorrect.</span>"); /* Get the contents of the XML file */
        
    error_reporting(E_ALL);
        
    $simplexml = new SimpleXMLElement($xml); /* Create a new SimpleXML object with the XML file */
        
    return $simplexml/* Return the object from the function */
    }

    function 
    getAlbumArt($artist$album) {
        
    $artist str_replace(" ""%20"$artist); /* Replace spaces in the artist with URL encoded spaces (%20) */
        
    $album str_replace(" ""%20"$album); /* Replace spaces in the album with URL encoded spaces (%20) */
        
    $url "http://ws.audioscrobbler.com/1.0/album/" $artist "/" $album "/info.xml"/* Form the URL of the XML file */
        
    $feed createXmlObject($url); /* Create a SimpleXML object with the URL */
        
    $arturl $feed->coverart->large/* Fetch the album art URL using SimpleXML into $arturl */
        
    return $arturl/* Return to URL of the album art */
    }

    function 
    getReleaseDate($artist$album) {
        
    $artist str_replace(" ""%20"$artist); /* Replace spaces in the artist with URL encoded spaces (%20) */
        
    $album str_replace(" ""%20"$album); /* Replace spaces in the album with URL encoded spaces (%20) */
        
    $url "http://ws.audioscrobbler.com/1.0/album/" $artist "/" $album "/info.xml"/* Form the URL of the XML file */
        
    $feed createXmlObject($url); /* Create a SimpleXML object with the URL */
        
    $datexml $feed->releasedate/* Fetch the release date and time using SimpleXML into $datexml */
        
    $date explode(", "$datexml); /* Split the release date into time and date */
        
    $datex $date[0]; /* Only keep the first part, which is the date */
        
    return $datex/* Return the release date without the time */
    }

    function 
    tracksArray($artist$album) {
        
    $artist str_replace(" ""%20"$artist); /* Replace spaces in the artist with URL encoded spaces (%20) */
        
    $album str_replace(" ""%20"$album); /* Replace spaces in the album with URL encoded spaces (%20) */
        
    $url "http://ws.audioscrobbler.com/1.0/album/" $artist "/" $album "/info.xml"/* Form the URL of the XML file */
        
    $feed createXmlObject($url); /* Create a SimpleXML object with the URL */
        
        
    $tracks = array(); /* Create an array in $tracks */
        
        
    foreach ($feed->tracks->track as $thetrack) { /* Foreach track in the XML as a variable */
            
    $count count($tracks); /* Count the number of tracks added to the array so far */
            
    $tracks[$count] = $thetrack['title']; /* Get the title of the track and use the number counted earlier as the index in the array */
        
    }
        return 
    $tracks/* Return the tracks array to be handled */
    }

    function 
    similarArray($artist) {
        
    $artist str_replace(" ""%20"$artist); /* Replace spaces in the artist with URL encoded spaces (%20) */
        
    $url "http://ws.audioscrobbler.com/1.0/artist/" $artist "/similar.xml"/* Form the URL of the XML file */
        
    $feed createXmlObject($url); /* Create a SimpleXML object with the URL */
        
        
    $similar = array(); /* Create an array in $similar */
        
        
    foreach ($feed->artist as $anartist) { /* Foreach similar artist in XML as a variable */
            
    $count count($similar); /* Count the number of similar artists added to the array so far */
            
    $similar[$count] = $anartist->name/* Get the name of the similar artist and use the number counted earlier as the index in the array */
        
    }
        return 
    $similar/* Return the similar tracks array to be handled */
    }

    ?>



    i used to be NintendoNews. visit my blog or add me on twitter.
    need help with vista? i am a microsoft certified technology specialist in configuring windows vista and connected home integrator.. pm me for help!


    "I am the way, the truth, and the life. No one comes to the Father except through me"
    John 14:6 (NIV)


  2. #2
    <?PHP> Guest

    Default

    Very Nice, +reppage

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •