'; } } else { header('HTTP/1.1 400 Bad Request'); } ob_flush(); function get_bio_link($url) { $html = ''; $d = new url_downloader(array( 'url' => $url, 'cache' => 'allmusic', 'return_data' => true )); if ($d->get_data_to_file()) { $DOM = new DOMDocument; @$DOM->loadHTML($d->get_data()); $els = getElementsByClass($DOM, 'li', 'biography'); if (count($els) > 0) { $e = $els[0]; $links = $e->GetElementsByTagName('a'); for ($i = 0; $i < $links->length; $i++) { $link = $links->item($i)->getAttribute('href'); logger::log("AMBIO", "Found Bio Link",$link); } return 'http://www.allmusic.com'.$link; } else { return false; } } else { return false; } } function get_allmusic_page($url) { logger::log("AMBIO", "Getting allmusic Page",$url); $r = '
'; $d = new url_downloader(array( 'url' => $url, 'cache' => 'allmusic', 'return_data' => true )); if ($d->get_data_to_file()) { $DOM = new DOMDocument; @$DOM->loadHTML($d->get_data()); $els = getElementsByClass($DOM, 'div', 'text'); foreach ($els as $el) { $a = $el->getAttribute('itemprop'); if ($a == 'reviewBody') { logger::trace("AMBIO", "Found Review Body"); $r = $el->nodeValue; } } $r = ''.$r.'
Biography courtesy of AllMusic
'; } print preg_replace('/\n/', '',$r); } function getElementsByClass(&$parentNode, $tagName, $className) { $nodes=array(); $childNodeList = $parentNode->getElementsByTagName($tagName); for ($i = 0; $i < $childNodeList->length; $i++) { $temp = $childNodeList->item($i); if (stripos($temp->getAttribute('class'), $className) !== false) { $nodes[]=$temp; } } return $nodes; } ?>