Ejemplo n.º 1
0
function SERVICE_GETALBUMMETADATA_google($node, $displayOutput = true, $return = false)
{
    global $include_path;
    // Ok, now we need to see if we are reading a album or an artist
    $album = $node->getName();
    $parent = $node->getParent();
    $artist = $parent->getName();
    include_once $include_path . "lib/snoopy.class.php";
    $snoopy = new Snoopy();
    $snoopy->fetch("http://www.google.com/musicsearch?btnG=Search+Music&q=%22" . urlencode($album) . "%22+%22" . urlencode($artist) . "%22");
    $contents = $snoopy->results;
    unset($snoopy);
    // Now let's fix up the name
    $albumName = str_replace("&", "&", $album);
    $artist = str_replace("&", "&", $artist);
    // First let's get the image
    $contents = substr($contents, strpos($contents, "All albums with matching titles shown"));
    $contents = substr($contents, strpos($contents, "<img src=") + strlen("<img src="));
    $image = substr($contents, 0, strpos($contents, " "));
    // Now let's get the rating
    $rating = substr_count($contents, "showtimes-star-on.gif");
    // Now let's return
    if (!$return) {
        writeAlbumMetaData($node, "", $image, "", "", $rating, "", "", $displayOutput);
        return true;
    } else {
        if ($return == "array") {
            $retArr['image'] = $image;
            $retArr['rating'] = $rating;
            return $retArr;
        } else {
            return ${$return};
        }
    }
}
Ejemplo n.º 2
0
function SERVICE_GETALBUMMETADATA_yahoo($node, $displayOutput = true, $return = false)
{
    global $include_path;
    // Ok, now we need to see if we are reading a album or an artist
    $album = $node->getName();
    $parent = $node->getParent();
    $artist = $parent->getName();
    include_once $include_path . "lib/snoopy.class.php";
    // First let's get the artist page
    $snoopy = new Snoopy();
    $snoopy->fetch("http://search.music.yahoo.com/search/?m=album&x=15&y=7&p=" . urlencode($album));
    $contents = $snoopy->results;
    unset($snoopy);
    // Did we get anything?
    if (stristr($contents, "no matches found")) {
        return false;
    }
    // Now let's fix up the name
    $albumName = str_replace("&", "&amp;", $album);
    $artist = str_replace("&", "&amp;", $artist);
    // Ok, now let's see if we got a direct hit or a link
    if (!stristr($contents, $artist) or !stristr($contents, $album)) {
        // Ok, we missed let's try to mangle the name and try again?
        $album = trim(substr($album, 0, strpos($album, " -")));
        $snoopy = new Snoopy();
        $snoopy->fetch("http://search.music.yahoo.com/search/?m=album&x=15&y=7&p=" . urlencode($album));
        $contents = $snoopy->results;
        unset($snoopy);
    }
    if (!stristr($contents, $artist) or !stristr($contents, $album)) {
        // Ok, we missed let's try to mangle the name and try again?
        $album = trim(substr($album, 0, strpos($album, "[")));
        $snoopy = new Snoopy();
        $snoopy->fetch("http://search.music.yahoo.com/search/?m=album&x=15&y=7&p=" . urlencode($album));
        $contents = $snoopy->results;
        unset($snoopy);
    }
    if (!stristr($contents, $artist) or !stristr($contents, $album)) {
        // Ok, we missed let's try to mangle the name and try again?
        $album = trim(substr($album, 0, strpos($album, "(")));
        $snoopy = new Snoopy();
        $snoopy->fetch("http://search.music.yahoo.com/search/?m=album&x=15&y=7&p=" . urlencode($album));
        $contents = $snoopy->results;
        unset($snoopy);
    }
    if (!stristr($contents, $artist) or !stristr($contents, $album)) {
        return false;
    }
    // Now let's move up to the artist and back
    $link = substr($contents, strpos($contents, $artist) - 300);
    $link = substr($link, strpos($link, "<a href=http://music.yahoo.com/release") + 8);
    $link = substr($link, 0, strpos($link, ' '));
    if (stristr($link, ">")) {
        $link = substr($link, 0, strpos($link, '>'));
    }
    // Now let's get that page
    $contents = @file_get_contents($link);
    // Now let's get the image
    $contents = substr($contents, strpos($contents, 'onClick="ext_link'));
    $contents = substr($contents, strpos($contents, 'Album Release Date') - 400);
    $image = substr($contents, strpos($contents, '<img src="http://') + 10);
    $image = substr($image, 0, strpos($image, '"'));
    if (!stristr($image, ".jpg") or !stristr($image, "http://")) {
        $image = "";
    }
    // Now let's get the release year
    $year = substr($contents, strpos($contents, 'Album Release Date:&nbsp;') + strlen('Album Release Date:&nbsp;'));
    $year = substr($year, 0, strpos($year, '</td>'));
    if (!$return) {
        writeAlbumMetaData($node, $year, $image, false, false, false, false, false, $displayOutput);
    } else {
        if ($return == "array") {
            $retArr['year'] = $year;
            $retArr['image'] = $image;
            $retArr['review'] = false;
            $retArr['rating'] = false;
            return $retArr;
        } else {
            return ${$return};
        }
    }
}
Ejemplo n.º 3
0
 }
 // Ok, now should we do the description?
 if ($item->getDescription() == "" and $arr['review'] != "") {
     writeAlbumMetaData($item, false, false, false, $arr['review']);
     usleep(250000);
 } else {
     unset($arr['review']);
 }
 // Ok, now should we do the year?
 if ($item->getYear() == "") {
 } else {
     unset($arr['year']);
 }
 // Ok, now should we do the rating?
 if ($arr['rating'] != "") {
     writeAlbumMetaData($item, false, false, false, false, $arr['rating']);
     usleep(250000);
 }
 // Now let's write the ID to the database
 if ($arr['id'] != "" and $arr['id'] != "NULL") {
     if ($allow_filesystem_modify == "true") {
         $fName = $item->getDataPath("String") . "/album.id";
         $handle = @fopen($fName, "w");
         @fwrite($handle, $arr['id']);
         @fclose($handle);
     }
     $item->setID($arr['id']);
 }
 // Did they want to write this to the id3 tags?
 if ($allow_id3_modify == "true" and (isset($arr['year']) or isset($arr['image']))) {
     // Now let's set the meta fields so they get updated for all the tracks
Ejemplo n.º 4
0
function SERVICE_GETALBUMMETADATA_rs($node, $displayOutput = true, $return = false)
{
    global $include_path;
    // Ok, now we need to see if we are reading a album or an artist
    $album = $node->getName();
    $parent = $node->getAncestor("artist");
    $artist = $parent->getName();
    include_once $include_path . "lib/snoopy.class.php";
    $snoopy = new Snoopy();
    $snoopy->fetch("http://www.rollingstone.com/?searchtype=RSAlbum&query=" . urlencode($album));
    $contents = $snoopy->results;
    unset($snoopy);
    $retVal = 0;
    // Now let's fix up the name
    $albumName = str_replace("&", "&amp;", $album);
    $artist = str_replace("&", "&amp;", $artist);
    // Ok, let's see if we got the exact album or a page of possibles
    $link = false;
    if (strpos($contents, $artist)) {
        // Ok, we found the album (or we think) now let's move to it
        $contents = substr($contents, strpos($contents, '"<strong>') + 10);
        $contents = substr($contents, strpos($contents, '<tr>') + 4);
        // Now let's build an array so we can find the right link
        $linkArray = explode("</tr>", $contents);
        for ($i = 0; $i < count($linkArray); $i++) {
            // Now let's see if this one has our artist
            if (stristr($linkArray[$i], $artist)) {
                // Ok, we've got our block, let's get the link
                $link = substr($linkArray[$i], strpos($linkArray[$i], 'href="') + 6);
                $link = substr($link, 0, strpos($link, '"'));
                break;
            }
        }
    }
    // Ok, did we find a link?
    if ($link) {
        $snoopy = new Snoopy();
        $snoopy->fetch($link . "?rnd=1107178952184&has-player=true&version=6.0.12.1040");
        $contents = $snoopy->results;
        unset($snoopy);
        // Alright, now let's parse this out
        if (strlen($contents) > 0 && strlen($artist) > 0 && stristr($contents, $artist) and stristr($contents, $album)) {
            // First let's get the album art
            $image = substr($contents, strpos($contents, "http://image.listen.com"));
            $image = substr($image, 0, strpos($image, '"'));
            // Now let's get the year
            $year = substr($contents, strpos($contents, "Originally released:") + strlen("Originally released:"));
            $year = trim(substr($year, 0, strpos($year, "<")));
            // Now let's get the tracks
            $tracks = substr($contents, strpos($contents, "Track List"));
            $tracks = substr($tracks, 0, strpos($tracks, "Download</a> this album"));
            $tArray = explode("</table>", $tracks);
            $e = 0;
            for ($i = 0; $i < count($tArray); $i++) {
                // Let's get the track number
                $tNum = substr($tArray[$i], strpos($tArray[$i], "<td"));
                $tNum = substr($tNum, strpos($tNum, '">') + 2);
                $tNum = substr($tNum, 0, strpos($tNum, '</'));
                // Let's get the track name
                $tName = substr($tArray[$i], strpos($tArray[$i], 'alt="Audio') + 10);
                $tName = substr($tName, strpos($tName, '<a') + 2);
                $tName = substr($tName, strpos($tName, '">') + 2);
                $tName = substr($tName, 0, strpos($tName, '</'));
                $trackArray[$e]['number'] = $tNum;
                $trackArray[$e]['name'] = $tName;
                $e++;
            }
            // Now let's get the rating
            $rating = false;
            if (!stristr($contents, "http://i.rollingstone.com/rs/images/ratings/notrated_left_small.gif")) {
                $rating = substr($contents, strpos($contents, "http://i.rollingstone.com/rs/images/ratings") + strlen("http://i.rollingstone.com/rs/images/ratings") + 1);
                $rating = substr($rating, 0, strpos($rating, '"'));
                $rating = substr($rating, 0, 1) / 2;
            }
            // Now let's get the review
            $review = substr($contents, strpos($contents, '<div id="storyContainer">') + strlen('<div id="storyContainer">'));
            $review = substr($review, strpos($review, '<p>') + 3);
            $review = trim(substr($review, 0, strpos($review, ' (RS')));
            $review = str_replace("</p>", "", $review);
            $review = str_replace("<p>", "<br><br>", $review);
            if ($review == "") {
                $review = false;
            }
            // Now that we have all the data we should write it back out
            if (!$return) {
                writeAlbumMetaData($node, $year, $image, $trackArray, $review, $rating, false, false, $displayOutput);
                return true;
            } else {
                if ($return == "array") {
                    $retArr['year'] = $year;
                    $retArr['image'] = $image;
                    $retArr['review'] = $review;
                    $retArr['rating'] = $rating;
                    return $retArr;
                } else {
                    return ${$return};
                }
            }
        }
    }
    if ($displayOutput) {
        ?>
		<SCRIPT LANGUAGE=JAVASCRIPT><!--\
			als.innerHTML = 'Status: Album not found';					
			-->
		</SCRIPT>
		<?php 
        flushdisplay();
    }
    return false;
}
Ejemplo n.º 5
0
function SERVICE_GETALBUMMETADATA_musicbrainz($node, $displayOutput = true, $return = false)
{
    global $include_path;
    // Ok, now we need to see if we are reading a album or an artist
    $album = $node->getName();
    $parent = $node->getParent();
    $artist = $parent->getName();
    // Ok, now let's include the musicbrainz classes
    include_once $include_path . "services/services/metadata/musicbrainz/phpBrainz.class.php";
    // Let's setup our object
    $queryObj = new mbQuery();
    // Now let's get the artist info so we can get the artist ID
    $results = $queryObj->getArtistByName($artist, 10);
    $found = false;
    if (count($results) > 0) {
        foreach ($results as $result) {
            if ($result['title'] == $artist) {
                $artistID = substr($result['artistid'], strrpos($result['artistid'], "/") + 1);
                break;
            }
        }
        if ($artistID != "") {
            // Now let's get the album info
            $results = $queryObj->getAlbumByName($album, 10);
            // Now let's make sure we got results
            if (count($results) > 0) {
                foreach ($results as $result) {
                    $albumArtistID = substr($result['creator']['artistid'], strrpos($result['creator']['artistid'], "/") + 1);
                    // Now let's see if we got a match on the artist
                    if ($artistID == $albumArtistID) {
                        $found = true;
                        $image = $result['coverArt']['large'];
                        // Now let's get the track details
                        $tracks = $result['trackList'];
                        $albumID = substr($result['albumid'], strrpos($result['albumid'], "/") + 1);
                        foreach ($tracks as $track) {
                            $trackID = substr($track, strrpos($track, "/") + 1);
                            $data = $queryObj->getQuickTrackInfoFromID($trackID, $albumID);
                            $tArray[] = $data['trackName'];
                            if (!isset($year) and isset($data['releaseDateList'])) {
                                foreach ($data['releaseDateList'] as $date) {
                                    if (strlen($date['date']) == 4) {
                                        $year = $date['date'];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Did we find anything?
    if ($found) {
        // Now let's convert
        $tracks = $tArray;
        if (!$return) {
            writeAlbumMetaData($node, $year, $image, $tracks, false, false, false, false, $displayOutput);
            return true;
        } else {
            if ($return == "array") {
                $retArr['year'] = $year;
                $retArr['image'] = $image;
                $retArr['review'] = $review;
                $retArr['rating'] = $rating;
                return $retArr;
            } else {
                return ${$return};
            }
        }
    } else {
        if ($displayOutput) {
            ?>
			<SCRIPT LANGUAGE=JAVASCRIPT><!--\
				als.innerHTML = 'Album not found!';					
				-->
			</SCRIPT>
			<?php 
            flushdisplay();
        }
        return false;
    }
}
Ejemplo n.º 6
0
function SERVICE_GETALBUMMETADATA_webmosher($node, $displayOutput = true, $return = false)
{
    global $include_path, $matchAlbumWeight;
    global $test_php4;
    $test_php4 = false;
    $link_url = 'http://www.amazon.com/dp/';
    $parent = $node->getParent();
    $search_tracking = array();
    // Normally, we are probably not overriding our values, so just procede.
    if (empty($_POST[descOVERRIDE]) && empty($_POST[imgOVERRIDE])) {
        // Next we pre-process the album and artist information from the JZ node
        // that is assigned to this meta data request. This is done to try and
        // simplify the data before it is sent off to Amazon, but also maintain
        // the original so that matching can be correlated correctly.
        // Setup the incoming Album/Artist information
        $album = trim($node->getName());
        $orig_album = $album;
        $artist = trim($parent->getName());
        $orig_artist = $artist;
        //Strip down the album a bit
        $album = preg_replace('/[\\(\\[][^\\)\\]]+[\\)\\]]/', '', $album);
        // Remove text in parenthesis & brackets
        $album = preg_replace('/[-_,]/', ' ', $album);
        // Convert - and _ to space
        $album = preg_replace('/([A-Z])/', " \$1", $album);
        // Pad a space before capitol letters
        $album = preg_replace('/\\s+/', ' ', $album);
        // Remove extra space
        // Stop word filtering removes extra words that may not be found in the
        // result and will cause a lower correlation value.
        $stopwords = array('the', 'a', 'and');
        foreach ($stopwords as $word) {
            $album = preg_replace('/\\b' . $word . '\\b/i', '', $album);
            // Remove stopwords
        }
        $album = preg_replace('/[^\\w\\s]/u', '', utf8_decode($album));
        // Remove non-word characters & UTF8 handling
        $album = trim($album);
        // We utilize the idea of "Meta-tagging" in the album names to allow
        // better search results. Amazon uses a similar system to mark album
        // entries, so it fits well with their system. Essentially, if any album
        // has a tag enclosed in [] that matches the items below, the artist
        // value is modified to improve searching. This is most effective for
        // soundtracks & compilations.
        $various = array('Soundtrack' => array('orig_artist' => 'Soundtrack', 'artist' => 'Various'), 'Various' => array('orig_artist' => 'Various Artists', 'artist' => 'Various'), 'Compilation' => array('orig_artist' => 'Various Artists', 'artist' => 'Various'), 'Single' => array('orig_artist' => $orig_artist, 'artist' => $artist));
        // We want to keep track of the postfixes in case they can be matched to
        // the search.
        $postfix = '';
        foreach ($various as $key => $val) {
            if (preg_match('/\\[' . $key . '\\]/', $orig_album)) {
                $artist = $val['artist'];
                $orig_artist = $val['orig_artist'];
                $orig_album = preg_replace('/\\s*[\\(\\[][^\\)\\]]+[\\)\\]]/', '', $orig_album);
                $postfix .= $key . ' ';
            }
        }
        // Some artists seem to like to release multiple albums with the same
        // name, but in different years. Using the year value in a meta tag will
        // allow the search to add more correlation for that release year.
        if (preg_match('/\\[(\\d\\d\\d\\d)\\]$/', $orig_album, $match)) {
            $exact_year = $match[1];
            $orig_album = preg_replace('/\\s*[\\(\\[][^\\)\\]]+[\\)\\]]/', '', $orig_album);
        } else {
            $exact_year = false;
        }
        // Now, we do the same thing to the artist.
        $artist = preg_replace('/\\s*[\\(\\[][^\\)\\]]+[\\)\\]]/', '', $artist);
        // Remove text in parenthesis & brackets
        $artist = preg_replace('/[-_,]/', ' ', $artist);
        // Convert - and _ to space
        $artist = preg_replace('/\\s+/', ' ', $artist);
        // Remove extra space
        foreach ($stopwords as $word) {
            $artist = preg_replace('/\\b' . $word . '\\b/i', '', $artist);
            // Remove stopwords
        }
        $artist = preg_replace('/[^\\w\\s\']/u', '', utf8_decode($artist));
        // Remove non-word characters & UTF8 handling
        $artist = trim($artist);
        // Lastly, we attempt to normalize any unicode in the artist text and if
        // its different, we will flag this as an additional search.
        // TODO
        // Configure a standard ordered search list
        $searches = array();
        // A fully exact search is the default. If this one matches something, we
        // usually ignore the rest.
        $searches[] = array(name => "All Exact", artist => $orig_artist, album => $orig_album, exact_artist => true, exact_album => true, exact_year => $exact_year, postfix => $postfix);
        $searches[] = array(name => "General Album", artist => '', album => $album, exact_artist => false, exact_album => false, exact_year => $exact_year, threshhold => 4800, postfix => $postfix);
        $searches[] = array(name => "General Artist", artist => $artist, album => '', exact_artist => false, exact_album => false, exact_year => $exact_year, threshhold => 8400, postfix => $postfix);
        // We attempt to normalize any unicode in the album/artist text and if
        // its different, we will flag this as an additional search.
        include_once $include_path . "lib/utfnormal/UtfNormal.php";
        $utffix = new UTFNormal();
        $artistUTFNormal = preg_replace('/[^\\w\\s]/', '', $utffix->toNFKD(utf8_encode($artist)));
        $albumUTFNormal = preg_replace('/[^\\w\\s]/', '', $utffix->toNFKD(utf8_encode($album)));
        if ($artist != $artistUTFNormal && $album != $albumUTFNormal) {
            $searches[] = array(name => "Normalized Artist", artist => $artistUTFNormal, album => $albumUTFNormal, exact_artist => false, exact_album => false, exact_year => $exact_year, postfix => $postfix);
        } elseif ($artist != $artistUTFNormal) {
            $searches[] = array(name => "Normalized Album", artist => $artistUTFNormal, album => $album, exact_artist => false, exact_album => false, exact_year => $exact_year, postfix => $postfix);
        } elseif ($album != $albumUTFNormal) {
            $searches[] = array(name => "Normalized Album", artist => $artist, album => $albumUTFNormal, exact_artist => false, exact_album => false, exact_year => $exact_year, postfix => $postfix);
        }
        // Album & artist were modified, so we need to add a general search.
        if ($orig_album != $album && $orig_artist != $artist) {
            $searches[] = array(name => "All General", artist => $artist, album => $album, exact_artist => false, exact_album => false, exact_year => $exact_year, postfix => $postfix);
        }
        if ($orig_album != $album) {
            $searches[] = array(name => "Exact Artist", artist => $orig_artist, album => $album, exact_artist => true, exact_album => false, exact_year => $exact_year, postfix => $postfix);
        }
        if ($orig_artist != $artist) {
            $searches[] = array(name => "Exact Album", artist => $artist, album => $orig_album, exact_artist => false, exact_album => true, exact_year => $exact_year, postfix => $postfix);
        }
        // Set search defaults
        $lastSearchWeight = 0;
        // Calculate the best weightings, if we match this, we are done.
        $maxSearchWeight = $matchAlbumWeight['album']['exact'] * 8 + $matchAlbumWeight['artist']['exact'] * 8 + $matchAlbumWeight['year']['exact'] + $matchAlbumWeight['image']['exact'] + $matchAlbumWeight['review']['exact'] + ($exact_year ? 80 : 0);
        // We pro-rate a bit more if we need an exact year.
        $baseSearchWeight = $matchAlbumWeight['album']['general'] + $matchAlbumWeight['artist']['general'] + ($exact_year ? 80 : 0);
        // We pro-rate a bit more if we need an exact year.
        $maxPages = 3;
        $searchItem = '';
        $fix_jz_path = urlencode(implode('/', $node->getPath()));
        print "<form action=\"popup.php?action=popup&ptype=getmetadata&jz_path={$fix_jz_path}\" method=\"post\">\n";
        print "<input type=\"hidden\" name=\"edit_search_all_albums\" value=\"on\"/>\n";
        print "<input type=\"hidden\" name=\"edit_search_all_artists\" value=\"off\"/>\n";
        print "<input type=\"hidden\" name=\"metaSearchSubmit\" value=\"Search\"/>\n";
        print "<input type=\"hidden\" name=\"edit_search_images_miss\" value=\"always\"/>\n";
        print "<input type=\"hidden\" name=\"edit_search_desc_miss\" value=\"always\"/>\n";
        while (list($key, $search) = each($searches)) {
            $currentPage = 1;
            $totalPages = 1;
            $weight = 1;
            // We don't bother with the following searches:
            if ($search[artist] == 'Various' && $search[album] == '') {
                continue;
            } elseif (isset($search[threshhold]) && $search[threshhold] < $lastSearchWeight) {
                continue;
            }
            print '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
            print "<tr><td>Searching for {$search['name']}...</td></tr>\n";
            $currentSearch = 'Title=' . urlencode($search[album]) . '&Artist=' . urlencode($search[artist]);
            while ($currentPage <= $totalPages) {
                // Do the XML data retrieval searching
                if ($xml = getXMLData($currentSearch)) {
                } else {
                    print "No content received from Amazon, please retry.";
                    break;
                }
                $totalPages = xml_data($xml->Items->TotalPages) <= $maxPages ? xml_data($xml->Items->TotalPages) : $maxPages;
                // Did we just get one match, or more than one?
                if (xml_data($xml->Items->TotalResults) == 1) {
                    $item = $xml->Items->Item;
                    $weight = weightMatch($search, $item);
                    // Check the weighting values
                    if ($weight >= $maxSearchWeight) {
                        $searchItem = $item;
                        break;
                    } elseif ($weight > $baseSearchWeight && $weight > $lastSearchWeight) {
                        $searchItem = $item;
                        $lastSearchWeight = $weight;
                    }
                } elseif (xml_data($xml->Items->TotalResults) > 1) {
                    // If we found multiple results, we need to look through them all.
                    foreach ($xml->Items->Item as $item) {
                        $weight = weightMatch($search, $item);
                        // Check the weighting values
                        if ($weight >= $maxSearchWeight) {
                            $searchItem = $item;
                            break;
                        } elseif ($weight > $baseSearchWeight && $weight > $lastSearchWeight) {
                            $searchItem = $item;
                            $lastSearchWeight = $weight;
                        }
                    }
                    $currentSearch = "ItemPage=" . $currentPage;
                }
                $currentPage++;
                if ($weight >= $maxSearchWeight) {
                    break;
                }
                sleep(1);
                // Prevent "SPAMMING" Amazon?
            }
            print "</table>\n";
            if ($weight >= $maxSearchWeight) {
                break;
            }
            flushdisplay();
        }
        if (empty($searchItem)) {
            print "Match result not found. You may override the result by selecting override items above.<br\\>\n";
            unset($item);
        } else {
            print "Found as Amazon ID: [<a href=\"{$link_url}" . xml_data($searchItem->ASIN) . "\" target=\"_blank\">" . xml_data($searchItem->ASIN) . "</a>], setting data.<br/><br/>\n";
            print "<script><!--\n";
            print "document.getElementById(\"" . xml_data($searchItem->ASIN) . "\").setAttribute('bgcolor', '#000080');\n";
            print "//-->\n</script>\n";
            $item = $searchItem;
        }
        print "<div align=\"center\"><input type=\"submit\" value=\"Override Default\" class=\"jz_submit\"/></div>";
        print "</form>";
        flushdisplay();
        print "<div align=\"center\"><input type=\"submit\" value=\"Override Default\" class=\"jz_submit\"/></div>";
        // Here, we start an override of the original retrieval.
    } else {
        $item = albumOverride();
    }
    $id = xml_data($item->ASIN);
    $year = substr(xml_data($item->ItemAttributes->ReleaseDate), 0, 4);
    if (isset($item->LargeImage->URL) && xml_data($item->LargeImage->URL) != '') {
        $image = xml_data($item->LargeImage->URL);
    } elseif (isset($item->MediumImage->URL) && xml_data($item->MediumImage->URL) != '') {
        $image = $item->MediumImage->URL;
    }
    $review = xml_data($item->EditorialReviews->EditorialReview->Content);
    // TODO: Rating does not seem to set unless override is chosen.
    $rating = sprintf(xml_data($item->CustomerReviews->AverageRating));
    if (is_array($item->BrowseNodes->BrowseNode)) {
        $genre = xml_data($item->BrowseNodes->BrowseNode[0]->Ancestors->BrowseNode->Name);
    } else {
        $genre = xml_data($item->BrowseNodes->BrowseNode->Ancestors->BrowseNode->Name);
    }
    $ListPrice = sprintf(xml_data($item->ItemAttributes->ListPrice->FormattedPrice));
    $tracks = array();
    if (is_array($item->Tracks->Disc->Track)) {
        foreach ($item->Tracks->Disc->Track as $track) {
            $tracks[] = sprintf(xml_data($track));
        }
    }
    if (!$return) {
        writeAlbumMetaData($node, $year, $image, $tracks, $review, $rating, $ListPrice, $genre, true);
        return true;
    } else {
        if ($return == "array") {
            $retArr['year'] = $year;
            $retArr['image'] = $image;
            $retArr['review'] = $review;
            $retArr['rating'] = $rating;
            $retArr['id'] = $id;
            return $retArr;
        } else {
            return ${$return};
        }
    }
    return true;
}