Saturday, November 17, 2012

Making a custom Now Playing tab in MusicBee

I use MusicBee a lot these days to play music. There's an option to display some data about the currently playing artist+track (artist picture, name, biography and the amount of my plays). I tried using the Last.fm artist.getinfo-method to get an XML-view of the data but that didn't really work for me. It lacked readability and some of the info that I wanted like how many times someone else had listened to this artist and some other little tweaks.



So I installed a WAMP-server (couldn't believe I didn't have one already), brushed up on the new (to me) PHP5 and the newly introduced simpleXML. I made a couple of files (for now) that take care of the assorted issues with this. They do work but mostly with better known artists, things tend to break when I'm playing more obscure artists.
HEADER INCLUDES STYLESHEET

Settings.php

This contains all of the standard settings like API-keys, user-variables and assorted:
<?php
//API keys
$echonestapi = "api_key=FILDTEOIK2HBORODV"; // test key=FILDTEOIK2HBORODV
$lastfmapi = "&api_key=295555f2ea2a5cdc44a5df93e8ec1cb1";

//Echonest parameters
$echonestformat = "&format=xml"; // optional values: json, xml, jsonp
$resultsartists = "&results=1"; // G
$searchresults = "&results=15"; //
$limit = "&limit=true"; //
$EN_ProfileBuckets = "&bucket=biographies&bucket=blogs&bucket=familiarity&bucket=hotttnesss&bucket=images&bucket=news&bucket=reviews&bucket=songs&bucket=terms&bucket=video&bucket=years_active&bucket=id:fma&bucket=id:discogs&bucket=id:musicbrainz&bucket=id:spotify-WW"; //

//Last.fm settings
//optional format is json (format=json), xml by default
$MyUser = "&user=Alainn"; // username (Optional) : The username for the context of the request. If supplied, the user's playcount for this artist is included in the response.
$MyUsername = "&username=Alainn"; // Alternative var for artist.getinfo
$OMGkickername = "&username=tYhJyYsRuLeS"; // Username of the current kicker in OMG
$MKCkickername = "&username=rolandkirk"; // Username of the current kicker in MKC
$artistimage = "templates/default.png"; // This is the backup image if there is no artist picture on Last.fm
$autocorrect ="&autocorrect=1"; // autocorrect[0|1] (Optional) : Transform misspelled artist names into correct artist names, returning the correct version instead. The corrected artist name will be returned in the response.
$limit = "&limit=50"; // limit (Optional) : The number of results to fetch per page. Defaults to 50.
$limitGetSimilar = "&limit=15"; // The number of results to fetch per Similar Artists page. Defaults to 50.
?>

GetInfo.php
This is the one I use most by adding this to one of the weblinks in MusicBee with the template http://localhost/MusicBee/GetInfo.php?artist=<Artist>
<?php
// Include settings
include "templates/settings.php";
// Include the header
include "templates/header.php";

// Get the artist name from the var in the URL
$artistget = $_GET['artist'];

//LAST.FM DATA
//GETINFO-CALL
//My Query
// Build the URL for the query for me
$MyCompleteGetInfo_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo" . $lastfmapi . $MyUsername . $autocorrect . "&artist=". $artistget ;
//Load the URL into a variabele
$MyGetInfo = simplexml_load_file($MyCompleteGetInfo_url);

//OptionalOMG: Query for the current kicker in OMG - $OMGkickername
$OMGCompleteGetInfo_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo" . $lastfmapi . $OMGkickername . $autocorrect . "&artist=". $artistget ;
//Load the URL into a variabele
$OMGKickerGetInfo = simplexml_load_file($OMGCompleteGetInfo_url);
//Extract info from the kickers xml-data
$OMGKickerPlaycount = $OMGKickerGetInfo->artist->stats->userplaycount;

//OptionalMKC: Query for the current kicker in MKC - $MKCkickername
$MKCCompleteGetInfo_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo" . $lastfmapi . $MKCkickername . $autocorrect . "&artist=". $artistget ;
//Load the URL into a variabele
$MKCKickerGetInfo = simplexml_load_file($MKCCompleteGetInfo_url);
//Extract info from the kickers xml-data
$MKCKickerPlaycount = $MKCKickerGetInfo->artist->stats->userplaycount;

//Extract info from the (my) GetInfo-data
//Artist (name, mbid, image#3, streamable, listeners, playcount, userplaycount, tags(name+URL), summary and content)
$artist = $MyGetInfo->artist->name; //Not really important since MB shows this and the title
$artistbiosummary = $MyGetInfo->artist->bio->summary;
$artistbiocontent = $MyGetInfo->artist->bio->content;
$artistMBID = $MyGetInfo->artist->mbid;
$artistStreamable = $MyGetInfo->artist->streamable;
$listeners = $MyGetInfo->artist->stats->listeners;
$playcount = $MyGetInfo->artist->stats->playcount;
$MyPlaycount = $MyGetInfo->artist->stats->userplaycount;
$artistimage = $MyGetInfo->artist->image[2];// Get 126x126 picture
$tag_count = $MyGetInfo->artist->tags->tag->count();

//GETSIMILAR-CALL
$CompleteGetSimilar_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar" . $lastfmapi . $autocorrect . $limitGetSimilar . "&artist=". $artistget ;
//Load the URL into a variabele
$GetSimilarInfo = simplexml_load_file($CompleteGetSimilar_url);

//Extract info from the GetSimilar call
//get number of children of element "similarartists" for loop termination
$SimilarArtists_count = $GetSimilarInfo->similarartists->artist->count();

//ECHONEST DATA
//Search for artists with the given Get name
$EchonestSearchArtist_url = "http://developer.echonest.com/api/v4/artist/search?" . $echonestapi . $echonestformat . "&name=" . $artistget;
$EchonestSearchArtist = simplexml_load_file($EchonestSearchArtist_url);
//get number of children of element "artist" for loop termination
$EN_artistsname_count = $EchonestSearchArtist->artists->artist->count();
//get the artist + id for the highest match
$EN_artist = $EchonestSearchArtist->artists->name;
$EN_artistID = $EchonestSearchArtist->artists->id;

//Search for artist info: Blogs
$EchonestBlogsArtist_url = "http://developer.echonest.com/api/v4/artist/blogs?" . $echonestapi . $echonestformat . $searchresults . "&name=" . $artistget;

//Search for similar artists with the given Get name
$EchonestSearchSimilarArtists_url = "http://developer.echonest.com/api/v4/artist/similar?" . $echonestapi . $echonestformat . "&name=" . $artistget;
$EchonestSearchSimilarArtists = simplexml_load_file($EchonestSearchSimilarArtists_url);
//get number of children of element "artists" for loop termination
$EN_SimilarArtistsName_count = $EchonestSearchSimilarArtists->artists->artist->count();

//OUTPUT THE VALUES TO THE SCREEN
// Image / Artist name / Streamable / #Listeners / #Playcount / #MyPlaycount / #KickerPlaycount
echo "<img src='" . $artistimage . "' alt='Artist picture is not available' /></a>&nbsp;<h1>" . $artist . "</h1><p>Streamable: " . $artistStreamable . " Listeners: " . $listeners . " Playcount: " . $playcount . " My playcount: <font color='red'>" . $MyPlaycount . "</font> Kicker in OMG (" . $OMGkickername . ") playcount: <font color='red'>" . $OMGKickerPlaycount . "</font> Kicker in MKC (" . $MKCkickername . ") playcount: <font color='red'>" . $MKCKickerPlaycount . "</font></p><br />";

//Similar (name, mbid, match, url,streamable not picture)
//This might benefit from a look-up in the database for "known" artists
echo "<p>Last.fm Similar artists: ";
for ($i = 0; $i < $SimilarArtists_count; $i++) {
    $similarartist_name = $GetSimilarInfo->similarartists->artist[$i]->name;
    $similarartist_mbid = $GetSimilarInfo->similarartists->artist[$i]->mbid; //use this for a search by ID
    $similarartist_match = $GetSimilarInfo->similarartists->artist[$i]->match;
        // truncate to first decimal
        $similarartist_match_short = substr($similarartist_match,0,4);
    $similarartist_url = $GetSimilarInfo->similarartists->artist[$i]->url;
    $similarartist_streamable = $GetSimilarInfo->similarartists->artist[$i]->streamable;// Not really usefull
   
    //GetInfo_MBID.php
    echo "<a href='GetInfo_MBID.php?mbid=" . $similarartist_mbid . "'>" . $similarartist_name . "</a> (" . $similarartist_match_short . ")&nbsp;&nbsp;&nbsp;";
}
echo "</p><br />";

//Top tags is a for-each section
//This might benefit from a look-up in the database for "known" tags
echo "<p>Top tags: ";
for ($i = 0; $i < $tag_count; $i++) {
    $ArtistTopTags = $MyGetInfo->artist->tags->tag[$i]->name;
    $ArtistTopTagURL = $MyGetInfo->artist->tags->tag[$i]->url;
    echo "<a href='" . $ArtistTopTagURL . "' target='TOP'>" . $ArtistTopTags . "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
}
echo "</p><br />";

//OMB search
echo "<p><a href=\"http://www.google.com/cse?cx=014209395896937011977:ouczate7qiu&ie=UTF-8&q=" . $artistget . "&sa=Search&siteurl=www.google.com/cse/home?cx=014209395896937011977:ouczate7qiu&ref=getmusicbee.com/forum/index.php?topic=7447.msg43038&ss=1999j973825j7#gsc.tab=0&gsc.q=" . $artistget . "&gsc.page=1\" target='Top'>Search for blogposts on Obscure Music Blogs for this artist.</a><br /><br />";

//External IDs
//make into a link to GetInfo_MBID.php?mbid=
echo "<p>MBID: " . $artistMBID . "</p><br />";

//Bio Summary
echo "<p>Artist bio: " . $artistbiosummary . "</p><br />";

//Similar names on Echonest
//****Needs rework on the var-naming convention, otherwise will clash at some point with SimilarArtists
echo "<p>Echonest has these names as similar: ";
for ($i = 0; $i < $EN_artistsname_count; $i++) {
    $ArtistSimilarName = $EchonestSearchArtist->artists->artist[$i]->name;
    $ArtistSimilarID = $EchonestSearchArtist->artists->artist[$i]->id;
   
    echo "<a href='GetInfo_EN.php?en_id=" . $ArtistSimilarID . "'>" . $ArtistSimilarName . "</a>&nbsp;&nbsp;&nbsp;";
    //echo $ArtistSimilarName . " (ID:" . $ArtistSimilarID . ")&nbsp;&nbsp;&nbsp;&nbsp;";
}
echo "</p>";

//Similar Artists on Echonest
echo "<p>Echonest has these Artists as similar: ";
for ($i = 0; $i < $EN_SimilarArtistsName_count; $i++) {
    $EN_SimilarArtistsName_name = $EchonestSearchSimilarArtists->artists->artist[$i]->name;
    $EN_SimilarArtistsName_id = $EchonestSearchSimilarArtists->artists->artist[$i]->id;

    echo "<a href='GetInfo_EN.php?en_id=" . $EN_SimilarArtistsName_id . "'>" . $EN_SimilarArtistsName_name . "</a>&nbsp;&nbsp;&nbsp;";
}
echo "</p>";

include "templates/footer.php";
?>

GetInfo_MBID.php
This one is meant to be a copy of the GetInfo.php's functionality but retrieving data based on the Musicbrainz-ID instead.

 <?php
// Include settings
include "templates/settings.php";
// Include the header
include "templates/header.php";

// Get the artist id from the var in the URL
$artistget = $_GET['mbid'];


//LAST.FM DATA
//GETINFO-CALL
//My Query
// Build the URL for the query for me
$MyCompleteGetInfo_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo" . $lastfmapi . $MyUsername . $autocorrect . "&mbid=". $artistget ;
//Load the URL into a variabele
$MyGetInfo = simplexml_load_file($MyCompleteGetInfo_url);

//OptionalOMG: Query for the current kicker in OMG - $OMGkickername
$OMGCompleteGetInfo_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo" . $lastfmapi . $OMGkickername . $autocorrect . "&mbid=". $artistget ;
//Load the URL into a variabele
$OMGKickerGetInfo = simplexml_load_file($OMGCompleteGetInfo_url);
//Extract info from the kickers xml-data
$OMGKickerPlaycount = $OMGKickerGetInfo->artist->stats->userplaycount;

//OptionalMKC: Query for the current kicker in MKC - $MKCkickername
$MKCCompleteGetInfo_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo" . $lastfmapi . $MKCkickername . $autocorrect . "&mbid=". $artistget ;
//Load the URL into a variabele
$MKCKickerGetInfo = simplexml_load_file($MKCCompleteGetInfo_url);
//Extract info from the kickers xml-data
$MKCKickerPlaycount = $MKCKickerGetInfo->artist->stats->userplaycount;

//Extract info from the (my) GetInfo-data
//Artist (name, mbid, image#3, streamable, listeners, playcount, userplaycount, tags(name+URL), summary and content)
$artist = $MyGetInfo->artist->name; //Not really important since MB shows this and the title
$artistbiosummary = $MyGetInfo->artist->bio->summary;
$artistbiocontent = $MyGetInfo->artist->bio->content;
$artistMBID = $MyGetInfo->artist->mbid;
$artistStreamable = $MyGetInfo->artist->streamable;
$listeners = $MyGetInfo->artist->stats->listeners;
$playcount = $MyGetInfo->artist->stats->playcount;
$MyPlaycount = $MyGetInfo->artist->stats->userplaycount;
$artistimage = $MyGetInfo->artist->image[2];// Get 126x126 picture
$tag_count = $MyGetInfo->artist->tags->tag->count();

//GETSIMILAR-CALL
$CompleteGetSimilar_url = "http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar" . $lastfmapi . $autocorrect . $limitGetSimilar . "&mbid=". $artistget ;
//Load the URL into a variabele
$GetSimilarInfo = simplexml_load_file($CompleteGetSimilar_url);

//Extract info from the GetSimilar call
//get number of children of element "similarartists" for loop termination
$SimilarArtists_count = $GetSimilarInfo->similarartists->artist->count();

//OUTPUT THE VALUES TO THE SCREEN
// Image / Artist name / Streamable / #Listeners / #Playcount / #MyPlaycount / #KickerPlaycount
echo "<img src='" . $artistimage . "' alt='Artist picture is not available' /></a>&nbsp;<h1>" . $artist . "</h1><p>Streamable: " . $artistStreamable . " Listeners: " . $listeners . " Playcount: " . $playcount . " My playcount: <font color='red'>" . $MyPlaycount . "</font> Kicker in OMG (" . $OMGkickername . ") playcount: <font color='red'>" . $OMGKickerPlaycount . "</font> Kicker in MKC (" . $MKCkickername . ") playcount: <font color='red'>" . $MKCKickerPlaycount . "</font></p><br />";

//Similar (name, mbid, match, url,streamable not picture)
//This might benefit from a look-up in the database for "known" artists
echo "<p>Last.fm Similar artists: ";
for ($i = 0; $i < $SimilarArtists_count; $i++) {
    $similarartist_name = $GetSimilarInfo->similarartists->artist[$i]->name;
    $similarartist_mbid = $GetSimilarInfo->similarartists->artist[$i]->mbid; //use this for a search by ID
    $similarartist_match = $GetSimilarInfo->similarartists->artist[$i]->match;
        // truncate to first decimal
        $similarartist_match_short = substr($similarartist_match,0,4);
    $similarartist_url = $GetSimilarInfo->similarartists->artist[$i]->url;
    $similarartist_streamable = $GetSimilarInfo->similarartists->artist[$i]->streamable;// Not really usefull
  
    echo "<a href='GetInfo_MBID.php?mbid=" . $similarartist_mbid . "'>" . $similarartist_name . "</a> (" . $similarartist_match_short . ")&nbsp;&nbsp;&nbsp;";
}
echo "</p><br />";

//Top tags is a for-each section
//This might benefit from a look-up in the database for "known" tags
echo "<p>Top tags: ";
for ($i = 0; $i < $tag_count; $i++) {
    $ArtistTopTags = $MyGetInfo->artist->tags->tag[$i]->name;
    $ArtistTopTagURL = $MyGetInfo->artist->tags->tag[$i]->url;
    echo "<a href='" . $ArtistTopTagURL . "' target='TOP'>" . $ArtistTopTags . "</a>&nbsp;&nbsp;&nbsp;&nbsp;";
}
echo "</p><br />";

//OMB search
echo "<p><a href=\"http://www.google.com/cse?cx=014209395896937011977:ouczate7qiu&ie=UTF-8&q=" . $artist . "&sa=Search&siteurl=www.google.com/cse/home?cx=014209395896937011977:ouczate7qiu&ref=getmusicbee.com/forum/index.php?topic=7447.msg43038&ss=1999j973825j7#gsc.tab=0&gsc.q=" . $artist . "&gsc.page=1\" target='Top'>Search for blogposts on Obscure Music Blogs for this artist.</a><br /><br />";

//Bio Summary
echo "<p>Artist bio: " . $artistbiosummary . "</p>";

include "templates/footer.php";
?>

GetInfo_EN.php
This is a different page since it doesn't use the Last.fm API anymore but the Echonest data with its use of "buckets" instead of multiple methods. This makes it much easier to retrieve more data in one call.

<?php
// Include settings
include "templates/settings.php";
// Include the header
include "templates/header.php";

// Get the artist name from the var(s) in the URL
$EN_ArtistID = $_GET['en_id'];
/* $MBID_Artist = $_GET['mbid']; */

//ECHONEST DATA RETRIEVAL
//Artist Profile for given Get ID
$EchonestArtistProfile_url = "http://developer.echonest.com/api/v4/artist/profile?" . $echonestapi .  "&id=" . $EN_ArtistID . $echonestformat . $EN_ProfileBuckets;
$EchonestArtistProfile_info = simplexml_load_file($EchonestArtistProfile_url);

//Available data from the file: terms_list(freq, name, weight), name, biographies_list, blogs_list, familiarity, hotttnesss, reviews_list, foreign ids_list, videos_list, images_list, news_list (name, url, summary, date_posted), id
$EN_Terms_count = $EchonestArtistProfile_info->artist->terms->count(); // Number of terms for loop termination
$EN_ArtistName = $EchonestArtistProfile_info->artist->name;
$EN_Biographies_count = $EchonestArtistProfile_info->artist->biographies->biography->count(); // Number of terms of loop termination
$EN_Blogs_count = $EchonestArtistProfile_info->artist->blogs->blog->count(); // Number of blogs for loop termination
$EN_ArtistFamiliarity = $EchonestArtistProfile_info->artist->familiarity;
$EN_ArtistHotttnesss = $EchonestArtistProfile_info->artist->hotttnesss;
$EN_Reviews_count = $EchonestArtistProfile_info->artist->reviews->review->count(); // Number of reviews for loop termination
$EN_ForeignIDs_count = $EchonestArtistProfile_info->artist->foreign_ids->foreign_id->count(); // Number of foreign_ids for loop termination
$EN_YearsActive_count = $EchonestArtistProfile_info->artist->years_active->count(); // Number of years for loop termination
$EN_Videos_count = $EchonestArtistProfile_info->artist->video->count(); // Number of videos for loop termination
$EN_Images_count = $EchonestArtistProfile_info->artist->images->image->count(); // Number of images for loop termination
    //Grab first picture
    /* $EN_ArtistImage_1st = $EchonestArtistProfile_info->artist->images_>image[0]->url; */
$EN_News_count = $EchonestArtistProfile_info->artist->news->news->count(); // Number of news items for loop termination
$EN_ArtistID = $EchonestArtistProfile_info->artist->id;
$EN_Songs_count = $EchonestArtistProfile_info->artist->songs->song->count(); // Number of songs for loop termination


//Header (jump to)

//ECHONEST DATA OUTPUT
//Navigation
echo "<div class=\"options\"><p><a href=\"#terms\">Terms</a> | <a href=\"#biographies\">Biographies</a> | <a href=\"#blogs\">Blogs</a> | <a href=\"#reviews\">Reviews</a> | <a href=\"#foreign ids\">Foreign IDs</a> | <a href=\"#years active\">Years Active</a> | <a href=\"#videos\">Videos</a> | <a href=\"#images\">Images</a> | <a href=\"#news\">News</a> |  <a href=\"#songs\">Songs</a></p></div>";

//name
echo "<h1>" . $EN_ArtistName . "</h1>";

//f+h
echo "<p>Familiarity: " . $EN_ArtistFamiliarity . " Hotttnesss: " .  $EN_ArtistHotttnesss . "</p>";
echo "<br />";

//terms
echo "<a name=\"terms\"><h2>Terms</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_Terms_count; $i++) {
    $EN_ArtistTerms_frequency = $EchonestArtistProfile_info->artist->terms[$i]->frequency;
        // truncate to first decimal
        $EN_ArtistTerms_frequency_short = substr($EN_ArtistTerms_frequency,0,4);
    $EN_ArtistTerms_name = $EchonestArtistProfile_info->artist->terms[$i]->name;
    $EN_ArtistTerms_weight = $EchonestArtistProfile_info->artist->terms[$i]->weight;
        // truncate to first decimal
        $EN_ArtistTerms_weight_short = substr($EN_ArtistTerms_weight,0,4);
    echo $EN_ArtistTerms_name . " Frequency: " . $EN_ArtistTerms_frequency_short . " Weight: " . $EN_ArtistTerms_weight_short . "&nbsp;&nbsp;&nbsp;";
}
echo "</p>";

//foreign ids
echo "<a name=\"foreign ids\"><h2>Foreign IDs</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_ForeignIDs_count; $i++) {
    $EN_ForeignID_catalog = $EchonestArtistProfile_info->artist->foreign_ids->foreign_id[$i]->catalog;
    $EN_ForeignID_foreign_id = $EchonestArtistProfile_info->artist->foreign_ids->foreign_id[$i]->foreign_id;

    echo "Catalog: " . $EN_ForeignID_catalog . " ID: " . $EN_ForeignID_foreign_id . "&nbsp;&nbsp;&nbsp;";
}
echo "</p>";

//biographies
echo "<a name=\"biographies\"><h2>Biographies</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_Biographies_count; $i++) {
    $EN_Biography_text = $EchonestArtistProfile_info->artist->biographies->biography[$i]->text;
    $EN_Biography_site = $EchonestArtistProfile_info->artist->biographies->biography[$i]->site;
    $EN_Biography_url = $EchonestArtistProfile_info->artist->biographies->biography[$i]->url;
    $EN_Biography_truncated = $EchonestArtistProfile_info->artist->biographies->biography[$i]->truncated;
   
    echo "Site: " . $EN_Biography_site . "<br />";
    echo $EN_Biography_text . "<br />";
    echo "<a href='" . $EN_Biography_url . "' target='Top'>Read more</a><br /><br />";
}
echo "</p>";

//blogs
echo "<a name=\"blogs\"><h2>Blogs</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_Blogs_count; $i++) {
    $EN_Blog_name = $EchonestArtistProfile_info->artist->blogs->blog[$i]->name;
    $EN_Blog_url = $EchonestArtistProfile_info->artist->blogs->blog[$i]->url;
    $EN_Blog_summary = $EchonestArtistProfile_info->artist->blogs->blog[$i]->summary;
    $EN_Blog_date_posted = $EchonestArtistProfile_info->artist->blogs->blog[$i]->date_posted;
   
    echo $EN_Blog_name . "<br />";
    echo $EN_Blog_summary . "<br />";
    echo "<a href='" . $EN_Blog_url . "' target='Top'>" . $EN_Blog_date_posted . "</a><br /><br />";
}
echo "</p>";

//reviews
echo "<a name=\"reviews\"><h2>Reviews</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_Reviews_count; $i++) {
    $EN_Review_name = $EchonestArtistProfile_info->artist->reviews->review[$i]->name;
    $EN_Review_url = $EchonestArtistProfile_info->artist->reviews->review[$i]->url;
    $EN_Review_summary = $EchonestArtistProfile_info->artist->reviews->review[$i]->summary;
    $EN_Review_date_found = $EchonestArtistProfile_info->artist->reviews->review[$i]->date_found;
   
    $EN_Review_name . "<br />";
    echo $EN_Review_summary . "<br />";
    echo "<a href='" . $EN_Review_url . "' target='Top'>" . $EN_Review_date_found . "</a><br /><br />";
}
echo "</p>";

//years active
echo "<a name=\"years active\"><h2>Years Active</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_YearsActive_count; $i++) {
    $EN_YearsActive_start = $EchonestArtistProfile_info->artist->years_active[$i]->start;
    $EN_YearsActive_end = $EchonestArtistProfile_info->artist->years_active[$i]->end;
   
    echo "Active from " . $EN_YearsActive_start . " - " . $EN_YearsActive_end . "<br />";
}
echo "</p>";

//videos
echo "<a name=\"videos\"><h2>Videos</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_Videos_count; $i++) {
    $EN_Video_url = $EchonestArtistProfile_info->artist->video[$i]->url;
    $EN_Video_title = $EchonestArtistProfile_info->artist->video[$i]->title;
    $EN_Video_image_url = $EchonestArtistProfile_info->artist->video[$i]->image_url;
    $EN_Video_site = $EchonestArtistProfile_info->artist->video[$i]->site;
   
    echo $EN_Video_site . " - " . $EN_Video_title . "<br />";
    echo "<a href='" . $EN_Video_url . "' target='_blank'><img src='" . $EN_Video_image_url . "' alt='Click here' /></a><br /><br />";
}
echo "</p>";

//urls
//Doesn't work right since every URL has a different _url

//images
echo "<a name=\"images\"><h2>Images</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_Images_count; $i++) {
    $EN_Image_url = $EchonestArtistProfile_info->artist->images->image[$i]->url;
   
    echo "<img src='" . $EN_Image_url . "' alt='Click here' /><br /><br />";
}
echo "</p>";

//news
echo "<a name=\"news\"><h2>News</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_News_count; $i++) {
    $EN_News_name = $EchonestArtistProfile_info->artist->news->news[$i]->name;
    $EN_News_url = $EchonestArtistProfile_info->artist->news->news[$i]->url;
    $EN_News_summary = $EchonestArtistProfile_info->artist->news->news[$i]->summary;
    $EN_News_date_posted = $EchonestArtistProfile_info->artist->news->news[$i]->date_posted;

    echo "<a href='" . $EN_News_url . "' target='_blank'>" . $EN_News_name . "</a><br />";
    echo $EN_News_summary . "<br />";
    echo "Posted on: " . $EN_News_date_posted . "<br /><br />";
}
echo "</p>";


//songs
echo "<a name=\"songs\"><h2>Songs</h2></a>";
echo "<p>";
for ($i = 0; $i < $EN_Songs_count; $i++) {
    $EN_Song_id = $EchonestArtistProfile_info->artist->songs->song[$i]->id;
    $EN_Song_title = $EchonestArtistProfile_info->artist->songs->song[$i]->title;

    echo $EN_Song_title . " (". $EN_Song_id . ") <br />";
}
echo "</p>";

include "templates/footer.php";
?>






2 comments:

  1. Can i use it t my web radio station if i change to my last fm api will it work, using an variable like $artist to get from database or shoutcast/icecast server ?

    Thank you (ok)

    ReplyDelete
  2. Wynn casino - DrmCD
    Wynn 밀양 출장안마 Casino 익산 출장샵 Las 정읍 출장마사지 Vegas. Address: 3131 South Las Vegas Blvd. South. Save 울산광역 출장샵 big with DrmCup audio and videos 거제 출장마사지 from DrmCD.

    ReplyDelete