function do_covers_db_style() { global $count; global $albums_without_cover; global $allfiles; $alist = get_list_of_artists(); foreach ($alist as $artist) { print '<div class="cheesegrater" name="artistname' . $artist['Artistindex'] . '">'; print '<div class="albumsection crackbaby">'; print '<div class="tleft"><h2>' . $artist['Artistname'] . '</h2></div><div class="tright rightpad"><button onclick="getNewAlbumArt(\'#album' . $count . '\')">' . get_int_text("albumart_getthese") . '</button></div>'; print "</div>\n"; print '<div id="album' . $count . '" class="fullwidth bigholder">'; print '<div class="containerbox covercontainer" id="covers' . $count . '">'; $colcount = 0; $blist = get_list_of_albums($artist['Artistindex']); foreach ($blist as $album) { print '<div class="expand containerbox vertical albumimg closet">'; print '<div class="albumimg fixed">'; $class = "clickable clickicon clickalbumcover droppable"; $src = ""; if ($album['Image'] && $album['Image'] !== "") { $src = $album['Image']; if (($key = array_search($src, $allfiles)) !== false) { unset($allfiles[$key]); } } else { $class = $class . " notexist"; $albums_without_cover++; } print '<input type="hidden" value="' . get_album_directory($album['Albumindex'], $album['AlbumUri']) . '" />'; print '<input type="hidden" value="' . rawurlencode($artist['Artistname'] . " " . munge_album_name($album['Albumname'])) . '" />'; print '<img class="' . $class . '" name="' . $album['ImgKey'] . '" height="82px" width="82px" '; if ($src != "") { print 'src="' . $src . '" '; } print '/>'; print '</div>'; print '<div class="albumimg fixed"><table><tr><td align="center">' . $album['Albumname'] . '</td></tr></table></div>'; print '</div>'; $colcount++; if ($colcount == 8) { print "</div>\n" . '<div class="containerbox covercontainer">'; $colcount = 0; } $count++; } print "</div></div></div>\n"; } }
function tryLastFM() { global $artist; global $album; global $mbid; global $delaytime; $retval = ""; $pic = ""; $al = munge_album_name($album); debuglog(" Trying last.FM for " . $artist . " " . $al, "GETALBUMCOVER"); $xml = loadXML("http://ws.audioscrobbler.com", "/2.0/?method=album.getinfo&api_key=15f7532dff0b8d84635c757f9f18aaa3&album=" . rawurlencode($al) . "&artist=" . rawurlencode($artist) . "&autocorrect=1"); if ($xml === false) { debuglog(" Received error response from Last.FM", "GETALBUMCOVER"); return ""; } else { foreach ($xml->album->image as $i => $image) { $attrs = $image->attributes(); $pic = $image; if ($attrs['size'] == "large") { $retval = $image; } } if ($retval == "") { $retval = $pic; } if ($mbid == "") { $mbid = $xml->album->mbid; debuglog(" Last.FM gave us the MBID of " . $mbid, "GETALBUMCOVER"); } } if ($retval != "") { debuglog(" Last.FM gave us " . $retval, "GETALBUMCOVER"); } else { debuglog(" No cover found on Last.FM", "GETALBUMCOVER"); } $delaytime = 1000; return $retval; }
function wikipedia_album_search($album, $artist) { $album = munge_album_name($album); debuglog("Searching Wikipedia for " . $album . " (album)", "WIKIPEDIA ALBUM"); $xml = wikipedia_request('http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=' . rawurlencode($album . " (album)") . '&srprop=score&format=xml'); $albuminfo = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); $page = null; foreach ($albuminfo->query->search->p as $id) { $searchstring = prepare_string($album) . '\\s+\\(' . prepare_string($artist) . ' album\\)'; // debuglog("1. Checking page ".$id['title']." against ".$searchstring, "WIKIDEBUG"); if (preg_match('/^\\s*' . $searchstring . '/i', $id['title'])) { debuglog("Found Page : " . $id['title'], "WIKIPEDIA"); $page = $id['title']; break; } } if ($page == null) { foreach ($albuminfo->query->search->p as $id) { $searchstring = prepare_string($album) . '\\s+\\(album\\)'; // debuglog("2. Checking page ".$id['title']." against ".$searchstring, "WIKIDEBUG"); if (preg_match('/^\\s*' . $searchstring . '/i', $id['title'])) { debuglog("Found Page : " . $id['title'], "WIKIPEDIA"); $page = $id['title']; break; } } } if ($page == null) { foreach ($albuminfo->query->search->p as $id) { $searchstring = prepare_string($album) . '\\s+\\(\\d+ album\\)'; // debuglog("2. Checking page ".$id['title']." against ".$searchstring, "WIKIDEBUG"); if (preg_match('/^\\s*' . $searchstring . '/i', $id['title'])) { debuglog("Found Page : " . $id['title'], "WIKIPEDIA"); $page = $id['title']; break; } } } if ($page == null) { foreach ($albuminfo->query->search->p as $id) { $searchstring = prepare_string($album); // debuglog("3. Checking page ".$id['title']." against ".$searchstring, "WIKIDEBUG"); if (preg_match('/^\\s*' . $searchstring . '\\s*$/i', $id['title'])) { debuglog("Found Page : " . $id['title'], "WIKIPEDIA"); $page = $id['title']; break; } } } if ($page == null) { debuglog("Searching Wikipedia for " . $album, "WIKIPEDIA ALBUM"); $xml = wikipedia_request('http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=' . rawurlencode($album) . '&srprop=score&format=xml'); $album2info = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); foreach ($album2info->query->search->p as $id) { $searchstring = prepare_string($album); // debuglog("3. Checking page ".$id['title']." against ".$searchstring, "WIKIDEBUG"); if (preg_match('/^\\s*' . $searchstring . '\\s*$/i', $id['title'])) { debuglog("Found Page : " . $id['title'], "WIKIPEDIA"); $page = $id['title']; break; } } } if ($page == null) { return null; } debuglog("Album search found page " . $page, "WIKIPEDIA ALBUM"); return get_wikipedia_page(preg_replace('/ /', '_', $page), "en.wikipedia.org", true); }