/** * Returns an array of similar artists * * @author Ross Carlson, Ben Dodson * @version 01/14/05 * @since 01/14/05 * @param $node The node for the artist/album * @param $limit Limit the number of results */ function SERVICE_SIMILAR_msnmusic($element, $limit = false) { global $include_path; // Let's setup the root node $root = new jzMediaNode(); $artist = $element->getName(); // Let's make sure we've flushed up to here since this thing is slow flushdisplay(); // Now let's search music.msn.com include_once $include_path . "lib/snoopy.class.php"; $snoopy = new Snoopy(); $snoopy->fetch("http://music.msn.com/search/all/?ss=" . urlencode($artist)); $contents = $snoopy->results; unset($snoopy); // Ok, now let's see if we got a direct hit or a link if (stristr($contents, $artist)) { // Now let's see if we can get the right link $contents = substr($contents, strpos($contents, $artist . "</a>") - 50); $link = substr($contents, strpos($contents, "href") + 6); $link = substr($link, 0, strpos($link, '"')); // Now let's get that page back $snoopy = new Snoopy(); $snoopy->fetch("http://music.msn.com" . $link); $contents = $snoopy->results; unset($snoopy); // Now let's find the artist image $contents = substr($contents, strpos($contents, "Listeners Also Liked")); $contents = substr($contents, strpos($contents, "<tr>")); // Now let's build an array we can search through $arr = explode("\n", $contents); for ($e = 0; $e < count($arr); $e++) { if (stristr($arr[$e], 'href="/artist/?')) { $artist = substr($arr[$e], strpos($arr[$e], '">') + 2); $artist = substr($artist, 0, strpos($artist, '</a>')); $retArray[] = $artist; } } // Now let's return return $retArray; } else { return false; } }
/** * Displays the status information on screen * during an update. * * @author Ben Dodson * @version 11/13/04 * @since 11/13/04 */ function showStatus($path = false) { global $word_importing; // Let's set our display items $media_display = str_replace("'", "", $path); // Now let's truncate the media_display if (strlen($media_display) > 60) { $media_display = substr($media_display, 0, 60) . "..."; } switch ($_SESSION['jz_import_progress']) { case "30": $val = ". "; $_SESSION['jz_import_progress'] = 0; break; default: $i = 0; $val = ""; while ($i < $_SESSION['jz_import_progress']) { $val .= ". "; $i++; } break; } $_SESSION['jz_import_progress']++; if ($media_display != "") { ?> <script language="javascript"> d.innerHTML = '<nobr><b><?php echo word("Directory"); ?> :</b> <?php echo $media_display; ?> <nobr>'; --> </SCRIPT> <?php } // Now let's figure out what's left if ($_SESSION['jz_import_full_ammount'] != 0) { $left = round($_SESSION['jz_import_full_progress'] / $_SESSION['jz_import_full_ammount'] * 100); } if ($left > 0) { $left = $left - 1; } // Ok, now let's figure out the time // First how much time has elapsed $elapsed = time() - $_SESSION['jz_import_start_time']; if ($elapsed == 0) { $elapsed = 1; } // Ok, now how many files did we do in that time? $perTime = round($_SESSION['jz_import_full_progress'] / $elapsed); if ($perTime == 0) { $perTime = 1; } // Now how much is left $ammountLeft = $_SESSION['jz_import_full_ammount'] - $_SESSION['jz_import_full_progress']; // Now time left? $timeLeft = convertSecMins(round($ammountLeft / $perTime)); ?> <script language="javascript"> p.innerHTML = '<b><?php echo word("Processing files") . ": " . $_SESSION['jz_import_full_progress'] . " (" . $left . "% - " . $timeLeft . ") " . $val; ?> </b>'; --> </SCRIPT> <?php flushdisplay(); }
t.innerHTML = '<nobr><?php echo word("Proceeding, please stand by..."); ?> </nobr>'; tn.innerHTML = ' '; tnu.innerHTML = ' '; g.innerHTML = ' '; ar.innerHTML = ' '; al.innerHTML = ' '; s.innerHTML = ' '; p.innerHTML = ' '; gr.innerHTML = ' '; --> </SCRIPT> <?php flushdisplay(); // Now we need to setup our bogus form $arr = array(); $arr['action'] = "popup"; $arr['ptype'] = "retagger"; $arr['jz_path'] = $node->getPath("String"); echo '<form name="retagger" action="' . urlize($arr) . '" method="POST">'; echo '<input type="hidden" name="reGenre" value="' . $_POST['reGenre'] . '">'; echo '<input type="hidden" name="reGenre_filesystem" value="' . $_POST['reGenre_filesystem'] . '">'; echo '<input type="hidden" name="edit_reGenre_custom" value="' . $_POST['edit_reGenre_custom'] . '">'; echo '<input type="hidden" name="reArtist" value="' . $_POST['reArtist'] . '">'; echo '<input type="hidden" name="reArtist_filesystem" value="' . $_POST['reArtist_filesystem'] . '">'; echo '<input type="hidden" name="edit_reArtist_custom" value="' . $_POST['edit_reArtist_custom'] . '">'; echo '<input type="hidden" name="reAlbum" value="' . $_POST['reAlbum'] . '">'; echo '<input type="hidden" name="reAlbum_filesystem" value="' . $_POST['reAlbum_filesystem'] . '">'; echo '<input type="hidden" name="edit_reAlbum_custom" value="' . $_POST['edit_reAlbum_custom'] . '">';
/** * Displays the grid of nodes for a standard page. * * @author Ben Dodson, Ross Carlson * @version 3/22/05 * @since 3/22/05 **/ function nodeGrid($node, $distance = false) { global $hierarchy; $smarty = smartySetup(); $display = new jzDisplay(); $lvl = isset($_GET['jz_letter']) ? $_GET['jz_level'] + $node->getLevel() - 1 : $node->getLevel(); switch ($hierarchy[$lvl]) { case "genre": $pg_title = word("Genres"); break; case "artist": $pg_title = word("Artists"); break; case "album": $pg_title = word("Albums"); break; default: $pg_title = word("Genres"); break; } if (isset($_GET['jz_letter'])) { $retArray = $node->getAlphabetical($_GET['jz_letter'], "nodes", $_GET['jz_level']); $letter = $_GET['jz_letter']; } else { $retArray = $node->getSubNodes("nodes", $distance); } sortElements($retArray, "name"); if ($node->getName() != "") { $pg_title = $node->getName(); if ($node->getSubNodeCount("nodes") > 0) { $pg_title .= " (" . $node->getSubNodeCount("nodes"); if ($node->getSubNodeCount("tracks") > 0) { $pg_title .= "+"; } $pg_title .= ")"; } } else { if (count($retArray) != 0) { $pg_title .= " (" . count($retArray) . ")"; } } if ($display->startCache("nodeGrid", $node->getName(), $letter)) { return; } $_SESSION['jz_node_distance'] = $distance; $smarty->assign('jz_bg_color', jz_bg_color); $smarty->assign('title', $pg_title); $smarty->display(SMARTY_ROOT . 'templates/slick/nodegrid.tpl'); // Now lets finish out the cache $display->endCache(); flushdisplay(); }
/** * Writes out the meta data of an artist * * @author Ross Carlson * @version 08/10/04 * @param string $link the link of where the data is */ function writeArtistMetaData($node, $image = false, $bio = false, $displayOutput) { global $web_root, $root_dir, $media_dir, $allow_filesystem_modify, $allow_id3_modify, $include_path, $backend, $include_path; // Let's write the bio if ($bio) { if ($displayOutput) { ?> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ ars.innerHTML = 'Status: Writing Description'; --> </SCRIPT> <?php flushdisplay(); usleep(250000); } // Now let's write this data to the node $node->addDescription($bio); // Now let's write it to a file if we should if ($allow_filesystem_modify == "true" and !stristr($backend, "id3")) { $bioFile = $node->getFilePath() . "/" . $node->getName() . ".txt"; $handle = @fopen($bioFile, "w"); @fwrite($handle, $bio); @fclose($handle); } } // Now let's write out the image $imgFile = ""; if (stristr($image, ".jpg")) { include_once $include_path . "lib/snoopy.class.php"; $snoopy = new Snoopy(); $snoopy->fetch($image); $imageData = $snoopy->results; unset($snoopy); // Now let's make sure that was valid if (strlen($imageData) < 2000) { //$imageData = ""; } } else { $imageData = ""; } //echo strlen($imageData); // Now let's write it out if ($imageData != "") { if ($displayOutput) { ?> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ ars.innerHTML = 'Status: Writing Image'; --> </SCRIPT> <?php flushdisplay(); usleep(250000); } // Ok, now can we write to the filesystem? if ($allow_filesystem_modify == "false" or stristr($backend, "id3")) { $imgFile = $include_path . "data/images/" . str_replace("/", "--", $node->getPath("String")) . "--" . $node->getName() . ".jpg"; } else { $imgFile = $node->getFilePath() . "/" . $node->getName() . ".jpg"; } // Now let's write it out if (writeImage($imgFile, $imageData)) { $node->addMainArt($imgFile); } if ($displayOutput) { ?> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ ars.innerHTML = 'Status: Writing Image - Success'; --> </SCRIPT> <?php flushdisplay(); usleep(250000); } $retVal = 1; } return true; }
/** * The installer function for this jukebox * * @author Ross Carlson * @version 11/20/05 * @since 11/20/05 * @param $step int The step of the install process we are on */ function jbInstall($step) { global $jbArr; echo "<strong>MPD Jukebox Installer</strong><br><br>"; // Now which step are we on? switch ($step) { case "2": // Now let's create the step 2 page ?> Please complete the following to setup MPD with Jinzora.<br><br> <strong>NOTE:</strong> MPD must already be running and have imported the same media folder(s)<br>that Jinzora has in order for MPD to function properly with Jinzora.<br><br> <form method="post"> <table> <tr> <td> Server: </td> <td> <input type="text" value="localhost" name="edit_server" class="jz_input"> </td> </tr> <tr> <td> Port: </td> <td> <input type="text" value="6600" name="edit_port" class="jz_input"> </td> </tr> <tr> <td> Password: </td> <td> <input type="password" value="" name="edit_password" class="jz_input"> (optional) </td> </tr> <tr> <td> Name: </td> <td> <input type="text" value="MPD Player" name="edit_description" class="jz_input"> </td> </tr> <tr> <td></td> <td> <br> <input type="submit" value="Test Connection and Write Settings" name="edit_finish" class="jz_submit"> <br><br> </td> </tr> </table> <input type="hidden" name="edit_step" value="3"> <input type="hidden" name="edit_jukebox_type" value="mpd"> </form> <?php exit; break; case "3": // Let's test the connection to the player // First let's set all the variables for it $jbArr[0]['server'] = $_POST['edit_server']; $jbArr[0]['port'] = $_POST['edit_port']; $jbArr[0]['description'] = $_POST['edit_description']; $jbArr[0]['password'] = $_POST['edit_password']; $jbArr[0]['type'] = "mpd"; $_SESSION['jb_id'] = 0; echo "Testing connection to MPD...<br>"; if (playerConnect()) { echo word("Success! Please wait while we write the settings...") . "<br><br>"; flushdisplay(); sleep(1); } else { echo word("Failed! Jinzora had an issue communicating with MPD, ensure that it's running and that you've specified the proper settings"); exit; } // Ok, let's create the settings file $content = "<?" . "php\n"; $content .= "\$" . "jbArr[0]['server'] = '" . $_POST['edit_server'] . "';\n"; $content .= "\$" . "jbArr[0]['port'] = '" . $_POST['edit_port'] . "';\n"; $content .= "\$" . "jbArr[0]['description'] = '" . $_POST['edit_description'] . "';\n"; $content .= "\$" . "jbArr[0]['password'] = '******'edit_password'] . "';\n"; $content .= "\$" . "jbArr[0]['type'] = 'mpd';\n"; $content .= "?>"; // Now let's write it out IF we can $filename = getcwd() . "/jukebox/settings.php"; if (is_writable($filename)) { $handle = fopen($filename, "w"); fwrite($handle, $content); fclose($handle); ?> <form method="post"> <input type="submit" name="continue" value="Continue to the Jukebox interface" class="jz_submit"><br><br> </form> <?php exit; } else { echo 'It looks like your jukebox settings file at "' . $filename . '" is not writeable.<br>You must make it writeable to proceed!'; echo '<br><br>If you are on Linux you can execute "chmod 666 ' . $filename . '" at a shell to make it writeable.<br><br>'; echo "Or copy and paste the below information into the file at: " . getcwd() . "/jukebox/settings.php<br><br>"; echo str_replace(" ", " ", nl2br(str_replace("<?php", "<php", $content))); echo "<br><br>"; exit; } break; } }
/** * Grabs the data that was parsed from a Podcast * * @author Ross Carlson * @since 11/02/2005 * @param $item An array with all the values to grab * @param $folder The subfolder to store the file in * @return boolean true|false * **/ function getPodcastData($item, $folder) { global $include_path, $podcast_folder; if ($item['file'] == "") { return false; } $be = new jzBackend(); $display = new jzDisplay(); // Let's clean the new folder name $folder = trim(cleanFileName($folder)); // Let's grab the file and save it to disk $ext = substr($item['file'], strlen($item['file']) - 3, 3); $track = trim(cleanFileName($item['title'] . "." . $ext)); if (substr($podcast_folder, 0, 1) != "/") { $dir = str_replace("\\", "/", getcwd()) . "/" . $podcast_folder . "/" . $folder; } else { $dir = $podcast_folder . "/" . $folder; } $track = $dir . "/" . $track; // Now let's create the directory we need makedir($dir); // Now let's see if the file already exists if (!is_file($track)) { ?> <script language="javascript"> t.innerHTML = '<?php echo word("Downloading") . ": " . $display->returnShortName($item['title'], 45); ?> '; --> </SCRIPT> <?php flushdisplay(); // Now let's grab the file and write it out $fName = str_replace("&", "&", $item['file']); $data = file_get_contents($fName); $handle = fopen($track, "w"); fwrite($handle, $data); fclose($handle); ?> <script language="javascript"> t.innerHTML = '<?php echo word("Download Complete!"); ?> '; --> </SCRIPT> <?php flushdisplay(); } else { ?> <script language="javascript"> t.innerHTML = '<?php echo word("Exists - moving to next track..."); ?> '; --> </SCRIPT> <?php flushdisplay(); } return $track; }
/** * Searches for meta data of the given node but shows the results step by step * * @author Ross Carlson * @version 01/18/05 * @since 01/18/05 * @param $node The node we are looking at */ function stepMetaSearch($node) { global $jzSERVICES, $row_colors, $allow_id3_modify, $include_path, $allow_filesystem_modify; echo '<div id="artist"></div>'; echo '<div id="arStatus"></div>'; echo '<div id="count"></div>'; echo '<div id="art"></div>'; ?> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ ar = document.getElementById("artist"); ars = document.getElementById("arStatus"); c = document.getElementById("count"); i = document.getElementById("art"); --> </SCRIPT> <?php flushdisplay(); // Now let's search, first we need to get all the nodes from here down $nodes = $node->getSubNodes("nodes", -1); // Now let's add the node for what we are viewing $nodes = array_merge(array($node), $nodes); $total = count($nodes); $c = 0; $start = time(); foreach ($nodes as $item) { ?> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ ar.innerHTML = '<nobr><?php echo word("Item"); ?> : <?php echo $item->getName(); ?> </nobr>'; ars.innerHTML = '<?php echo word("Status: Searching..."); ?> '; --> </SCRIPT> <?php flushdisplay(); // Is this an artist? if ($item->getPType() == 'artist') { } // Is this an album? if ($item->getPType() == 'album') { // Now let's loop all the services $sArr = array("jinzora", "yahoo", "rs", "musicbrainz", "google"); foreach ($sArr as $service) { ?> <SCRIPT><!--\ ars.innerHTML = '<?php echo word("Searching") . ": " . $service; ?> ' --> </SCRIPT> <?php flushdisplay(); include_once $include_path . "services/services/metadata/" . $service . ".php"; $func = "SERVICE_GETALBUMMETADATA_" . $service; $itemData = $func($item, false, "array"); if ($itemData['image'] != "") { echo '<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr><td>'; echo '<img width="75" align="left" src="' . $itemData['image'] . '" border="0">'; if (!isNothing($itemData['year'])) { echo $itemData['year'] . "<br>"; } if (!isNothing($itemData['rating'])) { echo $itemData['rating']; } echo $itemData['review']; echo '</td></tr><tr><td><input class="jz_submit" type="button" name="edit_download_image" value="' . word("Download") . " - " . $service . '">'; echo "<br><br></td></tr></table>"; } unset($itemData); flushdisplay(); } } } ?> <br> <SCRIPT LANGUAGE=JAVASCRIPT><!--\ ars.innerHTML = ' '; c.innerHTML = ' '; --> </SCRIPT> <?php echo "<br><center>"; $this->closeButton(true); exit; }
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("&", "&", $album); $artist = str_replace("&", "&", $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; }
/** * * Generates an XML list of all artists * * @author Ross Carlson * @since 3/31/05 * @return Returns a XML formatted list of all genres * **/ function listAllSubNode($type, $params) { global $this_site, $root_dir, $jzSERVICES; $limit = $params['limit']; // Let's setup the display object $display = new jzDisplay(); // Let's echo out the XML header echoXMLHeader(); // Let's get all the nodes $node = new jzMediaNode(); // Now let's get each genre $nodes = $node->getSubNodes("nodes", distanceTo($type), false, $limit); sortElements($nodes, "name"); foreach ($nodes as $item) { echo ' <' . $type . ' name="' . xmlUrlClean($item->getName()) . '">' . "\n"; echo ' <link>' . $this_site . xmlUrlClean($display->link($item, false, false, false, true, true)) . '</link>' . "\n"; // Now did they want full details? if (isset($_REQUEST['full']) && $_REQUEST['full'] == "true") { if (($art = $item->getMainArt(false, true, "audio", true)) !== false) { $image = xmlUrlClean($display->returnImage($art, false, false, false, "limit", false, false, false, false, false, "0", false, true)); } else { $image = ""; } echo ' <image>' . $image . '</image>' . "\n"; echo ' <desc><![CDATA[' . $item->getDescription() . ']]></desc>' . "\n"; } // Now let's close out echo " </" . $type . ">\n"; flushdisplay(); } echoXMLFooter(); }
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; } }
function SERVICE_GETARTISTMETADATA_webmosher($node = false, $return = false, $artistName = false) { global $include_path; include_once $include_path . "lib/utfnormal/UtfNormal.php"; $utffix = new UTFNormal(); // let's set the artist we're looking at if (is_object($node)) { $artist = $node->getName(); } else { $artist = $node['artist']; } $artist = preg_replace("/\\&/", 'and', $artist); $items = array(); // Normally, we are probably not overriding our values, so just procede. if (empty($_POST[descOVERRIDE]) && empty($_POST[imgOVERRIDE])) { $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=\"off\"/>\n"; print "<input type=\"hidden\" name=\"edit_search_all_artists\" value=\"on\"/>\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"; $search_artist = urlencode(strtolower(preg_replace('/[^\\w\\s]/', '', $utffix->toNFKD($artist)))); $yahoo_search = "http://search.music.yahoo.com/search/?m=artist&x=0&y=0&p=" . $search_artist; $content_y = getHTMLData($yahoo_search); $items['yahoo'] = parseYahooArtist($content_y, $artist); print "<h2>YAHOO!</h2>\n"; print "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n"; print "<tr>\n"; print "<td align=\"center\" valign=\"top\"><img width=\"150px\" src=\"" . $items['yahoo']['image'] . "\"/></td>\n"; print "<td align=\"left\" valign=\"top\">" . substr($items['yahoo']['bio'], 0, 200) . "</td>\n"; print "</tr><tr>\n"; print "<td width=\"50%\" align=\"center\"><input type=\"radio\" name=\"imgOVERRIDE\" value=\"" . $items['yahoo']['image'] . "\">Override Image</td>\n"; print "<td width=\"50%\" align=\"center\"><input type=\"radio\" name=\"descOVERRIDE\" value=\"" . $items['yahoo']['bio'] . "\">Override Bio</td>\n"; print "</table><hr/>\n"; // Rhapsody has some very specific artist name search requirements. $search_artist = urlencode(strtolower(preg_replace('/[^\\w]/', '', $utffix->toNFKD($artist)))); $rhaps_search = "http://www.rhapsody.com/" . strtolower(preg_replace('/[^\\w]/', '', $search_artist)) . "/more.html"; $content_r = getHTMLData($rhaps_search, $artist); $items['rhaps'] = parseRhapsodyArtist($content_r, $artist); print "<h2>Rhapsody</h2>\n"; print "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n"; print "<tr>\n"; print "<td align=\"center\" valign=\"top\"><img width=\"150px\" src=\"" . $items['rhaps']['image'] . "\"/></td>\n"; print "<td align=\"left\" valign=\"top\">" . substr($items['rhaps']['bio'], 0, 200) . "</td>\n"; print "</tr><tr>\n"; print "<td width=\"50%\" align=\"center\"><input type=\"radio\" name=\"imgOVERRIDE\" value=\"" . $items['rhaps']['image'] . "\">Override Image</td>\n"; print "<td width=\"50%\" align=\"center\"><input type=\"radio\" name=\"descOVERRIDE\" value=\"" . $items['rhaps']['bio'] . "\">Override Bio</td>\n"; print "</table><hr/>\n"; if (isset($items['yahoo']['bio']) && $items['yahoo']['bio'] != 'Not available.') { $bio = $items['yahoo']['bio']; } elseif (isset($items['rhaps']['bio']) && $items['rhaps']['bio'] != 'Not available.') { $bio = $items['rhaps']['bio']; } else { $bio = ''; } if (isset($items['yahoo']['image']) && $items['yahoo']['image'] != '') { $image = $items['yahoo']['image']; } elseif (isset($items['rhaps']['image']) && $items['rhaps']['image'] != '') { $image = $items['rhaps']['image']; } else { $image = ''; } print "<div align=\"center\"><input type=\"submit\" value=\"Override Default\" class=\"jz_submit\"/></div>"; print "</form>"; flushdisplay(); } else { $retArr = artistOverride(); print "<h2>OVERRIDE</h2>\n"; print "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n"; print "<tr>\n"; print "<td align=\"center\" valign=\"top\"><img width=\"150px\" src=\"" . (isset($retArr['image']) ? $retArr['image'] : $image) . "\"/></td>\n"; print "<td align=\"left\" valign=\"top\">" . (isset($retArr['bio']) ? $retArr['bio'] : $bio) . "</td>\n"; print "</tr><tr>\n"; print "</table><hr/>\n"; } // Now let's write the data if ($return) { if ($return == "array") { if (empty($retArr['bio'])) { $retArr['bio'] = $bio; } if (empty($retArr['image'])) { $retArr['image'] = $image; } return $retArr; } else { return ${$return}; } return ${$return}; } else { $artReturn = writeArtistMetaData($node, $image, $bio, $displayOutput); } return false; }