1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-06 03:49:56 +02:00

Add optional client name when playing

This commit is contained in:
Afterster 2013-12-07 09:41:20 +01:00
parent 51cff99ef6
commit f50d8a93a5
6 changed files with 47 additions and 37 deletions

View file

@ -287,7 +287,7 @@ class Plex_Api
$id = Plex_XML_Data::getAmpacheId($key);
$song = new Song($id);
if ($song->id) {
$url = Song::play_url($id);
$url = Song::play_url($id) . '&client=Plex';
header("Location: " . $url);
} else {
self::createError(404);

View file

@ -75,6 +75,7 @@ class Recommendation
$xml = self::get_lastfm_results('track.getsimilar', $query);
if ($xml->similartracks) {
foreach ($xml->similartracks->children() as $child) {
$name = $child->name;
$local_id = null;
@ -116,6 +117,7 @@ class Recommendation
break;
}
}
}
if (isset($results)) {
return $results;

View file

@ -197,7 +197,7 @@ class Session
$ip = $_SERVER['REMOTE_ADDR'] ? inet_pton($_SERVER['REMOTE_ADDR']) : '0';
$type = $data['type'];
$value = $data['value'];
$agent = substr($_SERVER['HTTP_USER_AGENT'], 0, 254);
$agent = (!empty($data['agent'])) ? $data['agent'] : substr($_SERVER['HTTP_USER_AGENT'], 0, 254);
if ($type == 'stream') {
$expire = time() + Config::get('stream_length');

View file

@ -284,7 +284,12 @@ class Stream
public static function _auto_init()
{
// Generate the session ID. This is slightly wasteful.
self::$session = Session::create(array('type' => 'stream'));
$data = array();
$data['type'] = 'stream';
if (isset($_REQUEST['client'])) {
$data['agent'] = $_REQUEST['client'];
}
self::$session = Session::create($data);
}
/**

View file

@ -777,7 +777,7 @@ class Subsonic_Api
$maxBitRate = $input['maxBitRate']; // For video streaming. Not supported.
$estimateContentLength = $input['estimateContentLength']; // Not supported.
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid));
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid)) . '&client=' . $input['c'];
self::follow_stream($url);
}
@ -792,7 +792,7 @@ class Subsonic_Api
$fileid = self::check_parameter($input, 'id', true);
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid)) . '&action=download';
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid)) . '&action=download' . '&client=' . $input['c'];
self::follow_stream($url);
}

View file

@ -55,6 +55,10 @@ if (empty($password)) {
$version = $_GET['v'];
$clientapp = $_GET['c'];
if (empty($_SERVER['HTTP_USER_AGENT'])) {
$_SERVER['HTTP_USER_AGENT'] = $clientapp;
}
if (empty($user) || empty($password) || empty($version) || empty($action) || empty($clientapp)) {
ob_end_clean();
Subsonic_Api::apiOutput2($f, Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM));
@ -82,12 +86,11 @@ if (!$auth['success']) {
if (!Access::check_network('init-api', $user, 5)) {
debug_event('Access Denied','Unauthorized access attempt to Subsonic API [' . $_SERVER['REMOTE_ADDR'] . ']', '3');
ob_end_clean();
Subsonic_Api::apiOutput2($f, Subsonic_XML_Data::createError(SSERROR_UNAUTHORIZED, 'Unauthorized access attempt to Subsonic API - ACL Error'));
Subsonic_Api::apiOutput2($f, Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_UNAUTHORIZED, 'Unauthorized access attempt to Subsonic API - ACL Error'));
exit();
}
$GLOBALS['user'] = User::get_from_username($user);
// Check server version
if (version_compare(Subsonic_XML_Data::API_VERSION, $version) < 0) {
ob_end_clean();