Hi there,
I have this script that helps with displaying my iTunes Playlist and showing images pulled from Amazon.com.
Now what I am trying to acheive is to show only the 1st image for the first item on the playlist. The other songs on the playlist should only display - title - artist - album.
Can anyone assit please?
Thanks
<?php
//_________C_O_N_F_I_G_U_R_A_T_I_O_N_S_____//
$conf['amazon_file'] = './AmazonSearch.php';
$conf['itunes_file'] = '/home/public_html/itunes/now_playing.xml';
//________F_U_N_C_T_I_O_N_S_______________//
if(file_exists($conf['amazon_file']))
{
require($conf['amazon_file']);
}else{
echo '
<li>ERROR - Amazon file not found</li>';
}
function PrintIt($title, $album, $artist)
{
$Tag = 'webservices-20';
$Token = 'D2A8O9KBF2OK4L';
$AS = new AmazonSearch($Token, $Tag);
if ( strlen( $artist ) && strlen( $album ) )
{
$Power = 'artist:' . $artist . ' and title:' . $album;
$Result = $AS->DoPowerSearch($Power, 'lite', 'music', 1);
}
else
{
$Result = $AS->DoArtistSearch($artist, 'lite', 'music', 1);
}
if ($Result !== null && count($Result) )
{
$ResultRow = $Result[0];
$ASIN = $ResultRow['Asin'];
$URL = $ResultRow['Url'];
$UPC = $ResultRow['Upc'];
$Price = $ResultRow['OurPrice'];
$ProductName = $ResultRow['ProductName'];
$AlbumArtURL = $ResultRow['ImageUrlMedium'];
}else{
$AlbumArtURL = '/images/music-no-image.gif';
$URL = 'http://music.barnesandnoble.com/search/results.asp?NME='.$artist.'&SNG=&INS=&LBL=&TYP=P&CAT=&Search=Search';
}
return '<a href="'.$URL.'" target="_blank"><img src="' . $AlbumArtURL . '" alt="' . $artist . '-' . $album . '" /></a>';
}
$xml_parser = xml_parser_create();
if (!($fp = fopen( $conf['itunes_file'], 'r')))
{
die('ERROR - iTunes file not readable or not found');
}
$data = fread( $fp, filesize($conf['itunes_file']) );
fclose( $fp );
xml_parse_into_struct( $xml_parser, $data, $vals, $index );
xml_parser_free( $xml_parser );
$c = 0;
//___________H_T_M_L___O_U_T_P_U_T___________//
foreach ($index as $a)
{
$d=13*$c+2;
$e=13*$c+5;
$f=13*$c+8;
$title = $vals[$d]['value'];
$artist = $vals[$e]['value'];
$album = $vals[$f]['value'];
$c++;
echo '
<li>'.PrintIt($title, $album, $artist).'</li>
<li><strong>'.$title.'</strong></li>
<li>'.$artist.'</li>
<li><em>'.$album.'</em></li>';
}
?>