/** * Creates an RAM compliant playlist and returns it for playing * * @author Ross Carlson * @version 2/24/05 * @since 2/24/05 * @param $list The list of tracks to use when making the playlist * @param $return Returns the porperly formated list */ function SERVICE_CREATE_PLAYLIST_QT($list) { global $allow_resample, $this_site, $root_dir; // Let's get the track so we can send it directly $list->flatten(); $data = $list->getList(); // Now let's open the embedded player $jzSERVICES = new jzServices(); $jzSERVICES->loadService("players", "qt"); $jzSERVICES->openPlayer($list); return; echo $data[0]->getFileName("user"); exit; header("Location: " . $data[0]->getFileName("user")); exit; // Now let's return return $content; }
/** * Sets the artist that the user is browsing for tracking purposes * * @author Ross Carlson * @version 01.11.05 * @since 01.11.05 * @param string $user_id the user id that is viewing */ function getRecommendations($user_id = false) { return; // Ok, first let's get their entire browsing history if ($user_id === false) { $user_id = $this->getID(); } $dp = $this->data_dir . "/" . $user_id . ".tracking"; $prevArray = unserialize(@file_get_contents($dp)); // Now let's setup our service $service = new jzServices(); $service->loadService("similar", "echocloud"); $artistList = ""; for ($i = 0; $i < count($prevArray); $i++) { if ($prevArray[$i]['artist'] != "") { $artistList .= $prevArray[$i]['artist'] . "|"; } } $favList = ""; $c = 0; for ($i = 0; $i < count($prevArray); $i++) { if ($prevArray[$i]['artist'] != "") { if (!stristr($favList, $prevArray[$i]['artist'])) { $favArray[$c]['count'] = substr_count($artistList, $prevArray[$i]['artist']); $favArray[$c]['artist'] = $prevArray[$i]['artist']; $c++; $favList .= $prevArray[$i]['artist']; } } } $root = new jzMediaNode(); @usort($favArray, "track_cmp"); // Now let's trim this to only 6 artists $favArray = @array_slice($favArray, 0, 6); for ($i = 0; $i < count($favArray); $i++) { returnSimilar($favArray[$i]['artist'], 1); } }
$jzService = new jzServices(); $jzService->loadService("metadata", "msnmusic"); $image = $jzService->getAlbumMetadata($node, false, "image"); if (strlen($image) != 0) { echo '<img src="' . $image . '" border="0"><br>'; echo $display->returnImageDimensions($image); echo '<br><br>'; echo '<input type="hidden" value="' . $image . '" name="edit_image_' . $i . '">'; echo '<input type="submit" name="edit_download_' . $i . '" value="' . word('Download') . '" class="jz_submit"><br><br><br>'; $i++; } flushdisplay(); // Now let's get a link from Musicbrainz unset($jzService); unset($image); $jzService = new jzServices(); $jzService->loadService("metadata", "musicbrainz"); $image = $jzService->getAlbumMetadata($node, false, "image"); if (strlen($image) != 0) { echo '<img src="' . $image . '" border="0"><br>'; echo $display->returnImageDimensions($image); echo '<br><br>'; echo '<input type="hidden" value="' . $image . '" name="edit_image_' . $i . '">'; echo '<input type="submit" name="edit_download_' . $i . '" value="' . word('Download') . '" class="jz_submit"><br><br><br>'; $i++; } flushdisplay(); echo "<br>"; $this->closeButton(); echo "</form></center>"; $this->closeBlock();
if (!checkStreamLimit($el)) { sendMedia("playlists/messages/streaming-limit-exceeded.mp3", word("Limit Reached")); exit; } if (!isset($_GET['sid'])) { $_GET['sid'] = "none"; } if (!isset($_SERVER['HTTP_RANGE'])) { // Now let's update the playcount if ($be->allowPlaycountIncrease($_GET['jz_user'], $el, $_GET['sid']) !== false) { $el->increasePlayCount(); } // Now let's update audioscrobbler $el->setStartTime(time()); if ($enable_audioscrobbler == "true") { $jzSERVICES->loadService("reporting", "audioscrobbler"); $jzSERVICES->updatePlayCountReporting($el); } } $meta = $el->getMeta(); if ($meta['artist'] != "" and $meta['artist'] != "-") { $title = $meta['artist'] . " - " . $el->getName(); } else { $title = $el->getName(); } if (isset($_GET['jz_user'])) { $be->setPlaying($_GET['jz_user'], $el, $_GET['sid']); } session_write_close(); // Close session while file is streaming sendMedia($el->getFileName("host"), $title, $resample);
/** * Actually sends the data in the specified file. * * * @author Ben Dodson, PHP.net * @version 11/11/04 * @since 11/11/04 */ function streamFile($path, $name, $limit = false, $resample = "", $download = false, $contentTypeFor = false) { global $always_resample, $allow_resample, $always_resample_rate, $jzUSER; // Let's ignore if they abort, that way we'll know when the track stops... ignore_user_abort(TRUE); $jzSERVICES = new jzServices(); $jzSERVICES->loadStandardServices(); $status = false; if ($limit === false) { $speed_limit = 1 * 1024; } else { $speed_limit = $limit; } // limit is passed as a param because we may want to limit it for downloads // but not for streaming / image viewing. // Also, we may want to write a different function for resampling, // but I don't know yet. // IF NO SPEED LIMIT: // the 'speed_limit' from above is the amount // of buffer used while sending the file. // but with no speed limit, there is no 'sleep' issued. // this makes seeking in a file much faster. // Let's get the extension of the real file $extArr = explode(".", $path); $ext = $extArr[count($extArr) - 1]; if (!is_file($path) || connection_status() != 0) { return false; } $meta = $jzSERVICES->getTagData($path); $do_resample = false; if (!isNothing($resample)) { $do_resample = true; } if ($allow_resample == "true" && stristr($always_resample, $ext)) { $do_resample = true; } if ($meta['type'] == "mp3") { if (!isNothing($resample) && $resample >= $meta['bitrate']) { $do_resample = false; } } if ($download) { $do_resample = false; } // Are they resampling or transcoding? if ($do_resample) { // Ok, if resampling isn't set let's go with the default if ($resample == "") { $resample = $always_resample_rate; } // Now let's load up the resampling service $jzSERVICES = new jzServices(); $jzSERVICES->loadService("resample", "resample"); $jzSERVICES->resampleFile($path, $name, $resample); // Now let's unset what they are playing $be = new jzBackend(); $be->unsetPlaying($_GET['jz_user'], $_GET['sid']); return; } // Now we need to know if this is an ID3 image or not // First let's get their limit $limit = "7"; $size = filesize($path); $range = getContentRange($size); if ($range !== false) { $range_from = $range[0]; $range_to = $range[1]; } else { $range_from = 0; $range_to = $size - 1; } $ps3 = false; $allheaders = getallheaders(); if (isset($allheaders['User-Agent']) && $allheaders['User-Agent'] == "PLAYSTATION 3") { $ps3 = true; } if ($ps3) { // ps3 is picky and bizarre. if ($range_from > $size) { // This happens if the ps3 thinks the file // is larger than it is, and sending a // This is supposed to be a read of the id3v1 tag at // the end of a file (128 bytes), or the lyrics tag // (138 bytes) $requested = $range_to - $range_from + 1; $range_from = $size - $requested; $range_to = $size - 1; header("HTTP/1.1 206 Partial content"); } else { if ($range_from == 0 && $size == $range_to + 1) { header("HTTP/1.1 200 OK"); } else { header("HTTP/1.1 206 Partial content"); header("CONTENT-RANGE: bytes {$range_from}-{$range_to}/{$size}"); } } header("transferMode.dlna.org: Streaming"); header("contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=017000 00000000000000000000000000"); header("Accept-Ranges: bytes"); header("Connection: keep-alive"); header("Content-Length: " . ($size - $range_from)); } else { if ($range === false) { // Content length has already been sent header("Content-Length: " . (string) $size); } else { header("HTTP/1.1 206 Partial Content"); header("Accept-Range: bytes"); header("Content-Length: " . ($size - $range_from)); header("Content-Range: bytes {$range_from}" . "-" . $range_to . "/{$size}"); } } if ($contentTypeFor !== false) { sendContentType($contentTypeFor); } if (!$ps3) { header("Content-Disposition: inline; filename=\"" . $name . "\""); header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s", filemtime($path)) . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); } if ($file = fopen($path, 'rb')) { @set_time_limit(0); fseek($file, $range_from); while (!feof($file) and connection_status() == 0 and ($cur_pos = ftell($file)) < $range_to + 1) { print fread($file, min(1024 * $speed_limit, $range_to + 1 - $cur_pos)); flush(); if ($limit !== false) { sleep(1); } } $status = connection_status() == 0; fclose($file); @set_time_limit(30); } // Now let's unset what they are playing $be = new jzBackend(); $be->unsetPlaying($_GET['jz_user'], $_GET['sid']); return $status; }
* - Code Purpose - * - Helps migrate artists to genres * -- COMPLETELY UNSUPPORTED!!!! - Use at your own risk! * * @since 01/28/05 * @author Ross Carlson <*****@*****.**> * */ // first let's include all the functions and stuff we'll need $include_path = str_replace("/extras", "", dirname(__FILE__)) . "/"; include_once '../settings.php'; include_once '../system.php'; include_once '../lib/general.lib.php'; include_once '../services/class.php'; $jzSERVICES = new jzServices(); $jzSERVICES->loadService("metadata", "amazon"); // Now let's see if they submitted the form if (isset($_POST['migrate'])) { echo '<br><strong>Beginning reorg of media, please stand by, this could take a while...</strong><br><br>'; echo "Scanning files"; flushdisplay(); // Let's read all the files into a big array $readCtr = 0; $retArray = readAllDirs($_POST['path'], $readCtr, $retArray, "false", "true", "false"); echo "<br>"; $master = "|||"; // Let's look at each file one by one to see what to do with it foreach ($retArray as $item) { // Let's strip the full path so we'll have just what we need $data = str_replace($_POST['path'] . "/", "", $item); // Now using our settings let's figure out what we're looking at
/** * * Echos out the XML header information * * @author Ross Carlson * @since 3/31/05 * **/ function getCurrentTrack() { global $jzUSER, $this_site, $root_dir; // What kind of output? if (isset($_REQUEST['type'])) { $type = $_REQUEST['type']; } else { $type = "xml"; } // Now let's set the width if (isset($_REQUEST['imagesize'])) { $imagesize = $_REQUEST['imagesize'] . "x" . $_REQUEST['imagesize']; } else { $imagesize = "150x150"; } // Now let's see when to stop if (isset($_REQUEST['count'])) { $total = $_REQUEST['count']; } else { $total = 1; } // Let's start the page if ($type == "xml") { echoXMLHeader(); } // Now let's get the data $be = new jzBackend(); $ar = $be->getPlaying(); $display = new jzDisplay(); $fullList = ""; $found = false; foreach ($ar as $user => $tracks) { $name = $jzUSER->getSetting("full_name"); if ($name == "") { $name = $jzUSER->lookupName($user); // that's the user name } $i = 0; foreach ($tracks as $time => $song) { // Now let's make sure this is the right user if ($name == $jzUSER->getName()) { // Now let's make sure we don't list this twice if (stristr($fullList, $song['path'] . "-" . $name . "\n")) { continue; } $fullList .= $song['path'] . "-" . $name . "\n"; // Now let's create the objects we need $node = new jzMediaNode($song['path']); $track = new jzMediaTrack($song['path']); $album = $node->getParent(); $artist = $album->getParent(); $meta = $track->getMeta(); // Now, now let's echo out the data switch ($type) { case "xml": echo " <item>\n"; echo " <title>" . $this_site . xmlUrlClean($meta['title']) . "</title>\n"; echo " <album>\n"; echo " <name>" . $this_site . xmlUrlClean($album->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </album>\n"; echo " <artist>\n"; echo " <name>" . $this_site . xmlUrlClean($artist->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </artist>\n"; echo " </item>\n"; break; case "html": if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "<center>"; } } echo $meta['title'] . "<br>"; echo $album->getName() . "<br>"; echo $this_site . $display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; echo $artist->getName() . "<br>"; echo $display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; break; case "mt": $art = $album->getMainArt($imagesize, true, "audio", true); if ($art) { // Now let's try to get the link from the amazon meta data service if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">'; } $display->image($art, $album->getName(), 150, false, "limit"); if ($_REQUEST['amazon_id'] != "") { echo '</a>'; } echo "<br>"; } echo $meta['title'] . "<br>"; if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">' . $album->getName() . "</a><br>"; } else { echo $album->getName() . "<br>"; } echo $artist->getName() . "<br>"; break; } $found = true; // Now should we stop? $i++; if ($i >= $total) { break; } } } } if (!$found) { // Ok, we didn't find anything so let's get the last thing they played... $be = new jzBackend(); $history = explode("\n", $be->loadData("playhistory-" . $jzUSER->getID())); $track = new jzMediatrack($history[count($history) - 1]); $album = $track->getParent(); $artist = $album->getParent(); $meta = $track->getMeta(); // Now, now let's echo out the data switch ($type) { case "xml": echo " <item>\n"; echo " <title>" . $this_site . xmlUrlClean($meta['title']) . "</title>\n"; echo " <album>\n"; echo " <name>" . $this_site . xmlUrlClean($album->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </album>\n"; echo " <artist>\n"; echo " <name>" . $this_site . xmlUrlClean($artist->getName()) . "</name>\n"; echo " <image>" . $this_site . xmlUrlClean($display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true)) . "</image>\n"; echo " </artist>\n"; echo " </item>\n"; break; case "html": if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "<center>"; } } echo $meta['title'] . "<br>"; echo $album->getName() . "<br>"; echo $this_site . $display->returnImage($album->getMainArt(false, true, "audio", true), $album->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; echo $artist->getName() . "<br>"; echo $display->returnImage($artist->getMainArt(false, true, "audio", true), $artist->getName(), false, false, "limit", false, false, false, false, false, "0", false, true, true) . "<br>"; break; case "mt": if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "<center>"; } } $art = $album->getMainArt($imagesize, true, "audio", true); if ($art) { // Now let's try to get the link from the amazon meta data service if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">'; } $display->image($art, $album->getName(), 150, false, "limit"); if ($_REQUEST['amazon_id'] != "") { echo '</a>'; } echo "<br>"; } echo $meta['title'] . "<br>"; if ($_REQUEST['amazon_id'] != "") { $jzService = new jzServices(); $jzService->loadService("metadata", "amazon"); $id = $jzService->getAlbumMetadata($album, false, "id"); echo '<a target="_blank" href="http://www.amazon.com/exec/obidos/tg/detail/-/' . $id . '/' . $_REQUEST['amazon_id'] . '/">' . $album->getName() . "</a><br>"; } else { echo $album->getName() . "<br>"; } echo $artist->getName() . "<br>"; break; } } // Now let's close out switch ($type) { case "xml": echoXMLFooter(); break; case "html": echo '<a target="_blank" title="Jinzora :: Free Your Media!" href="http://www.jinzora.com"><img src="http://www.jinzora.com/downloads/button-stream.gif" border="0"></a>'; break; case "mt": echo '<a target="_blank" title="Jinzora :: Free Your Media!" href="http://www.jinzora.com"><img src="http://www.jinzora.com/downloads/button-stream.gif" border="0"></a>'; break; } if (isset($_REQUEST['align'])) { if ($_REQUEST['align'] == "center") { echo "</center>"; } } }