diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-02-11 20:19:10 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-03-28 16:56:21 -0400 |
commit | 4b4e7decf647ec235d8c7dff0757e2e4924f0fb5 (patch) | |
tree | acf7e0dcaf03d73f21b33b00f524fc9c505ac5d5 | |
parent | 744e6bb99404b8455024488472a1ad02e5c87025 (diff) | |
download | ampache-4b4e7decf647ec235d8c7dff0757e2e4924f0fb5.tar.gz ampache-4b4e7decf647ec235d8c7dff0757e2e4924f0fb5.tar.bz2 ampache-4b4e7decf647ec235d8c7dff0757e2e4924f0fb5.zip |
Try to fix remote streaming
-rw-r--r-- | lib/class/catalog.class.php | 10 | ||||
-rw-r--r-- | play/index.php | 33 | ||||
-rw-r--r-- | server/xml.server.php | 2 |
3 files changed, 18 insertions, 27 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 929103be..88d63674 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1038,11 +1038,11 @@ class Catalog extends database_object { } // add_to_catalog /** - * _connect_remote + * connect * * Connects to the remote catalog that we are. */ - private function _connect_remote() { + public function connect() { try { $remote_handle = new AmpacheApi(array( 'username' => $this->remote_username, @@ -1074,7 +1074,7 @@ class Catalog extends database_object { * database. */ public function update_remote_catalog($type = 0) { - $remote_handle = $this->_connect_remote(); + $remote_handle = $this->connect(); if (!$remote_handle) { return false; } @@ -1110,7 +1110,7 @@ class Catalog extends database_object { } else { $data['song']['catalog'] = $this->id; - $data['song']['file'] = preg_replace('/ssid=.*&/', '', $data['song']['url']); + $data['song']['file'] = preg_replace('/ssid=.*?&/', '', $data['song']['url']); if (!Song::insert($data['song'])) { debug_event('remote_catalog', 'Insert failed for ' . $data['song']['self']['id'], 1); Error::add('general', T_('Unable to Insert Song - %s'), $data['song']['title']); @@ -1138,7 +1138,7 @@ class Catalog extends database_object { */ public function clean_remote_catalog() { //FIXME: Implement - $remote_handle = $this->_connect_remote(); + $remote_handle = $this->connect(); if (!$remote_handle) { return false; } diff --git a/play/index.php b/play/index.php index db965f33..13fc3187 100644 --- a/play/index.php +++ b/play/index.php @@ -37,9 +37,7 @@ $oid = $_REQUEST['oid'] // FIXME: Any place that doesn't use oid should be fixed ? scrub_in($_REQUEST['oid']) : scrub_in($_REQUEST['song']); -$otype = scrub_in($_REQUEST['otype']); $sid = scrub_in($_REQUEST['ssid']); -$xml_rpc = scrub_in($_REQUEST['xml_rpc']); $video = make_bool($_REQUEST['video']); $type = scrub_in($_REQUEST['type']); $transcode_to = scrub_in($_REQUEST['transcode_to']); @@ -70,11 +68,6 @@ if (empty($oid) && empty($demo_id) && empty($random)) { exit; } -// If we're XML-RPC and it's enabled, use system user -if ($xml_rpc == 1 && Config::get('xml_rpc') && empty($uid)) { - $uid = '-1'; -} - if (empty($uid)) { debug_event('play', 'No user specified', 2); header('HTTP/1.1 400 No User Specified'); @@ -213,30 +206,28 @@ if (Config::get('lock_songs')) { } } -/* Check to see if this is a 'remote' catalog */ if ($catalog->catalog_type == 'remote') { - - preg_match("/(.+)\/play\/index.+/",$media->file,$match); - - $token = xmlRpcClient::ampache_handshake($match['1'],$catalog->key); + $remote_handle = $catalog->connect(); // If we don't get anything back we failed and should bail now - if (!$token) { - debug_event('xmlrpc-stream','Error Unable to get Token from ' . $match['1'] . ' check target servers logs','1'); + if (!$remote_handle) { + debug_event('play', 'Connection to remote server failed', 1); exit; } - $sid = xmlRpcClient::ampache_create_stream_session($match['1'],$token); + $handshake = $remote_handle->info(); + $url = $media->file . '&ssid=' . $handshake['auth']; - $extra_info = "&xml_rpc=1&sid=$sid"; - header('Location: ' . $media->file . $extra_info); - debug_event('xmlrpc-stream',"Start XML-RPC Stream - " . $media->file . $extra_info,'5'); + header('Location: ' . $url); + debug_event('play', 'Started remote stream - ' . $url, 5); - /* If this is a voting tmp playlist remove the entry, we do this regardless of play amount */ - if ($demo_id) { $democratic->delete_from_oid($oid,'song'); } // if democratic + // Handle democratic removal + if ($demo_id) { + $democratic->delete_from_oid($oid, 'song'); + } exit; -} // end if remote catalog +} /* If we don't have a file, or the file is not readable */ if (!$media->file OR !is_readable($media->file)) { diff --git a/server/xml.server.php b/server/xml.server.php index 31a66458..4b814f6f 100644 --- a/server/xml.server.php +++ b/server/xml.server.php @@ -70,7 +70,7 @@ if (!Access::check_network('init-api', $username, 5)) { if ($_REQUEST['action'] != 'handshake' AND $_REQUEST['action'] != 'ping') { Session::extend($_REQUEST['auth']); - $GLOBALS['user'] = User::get_from_username($session['username']); + $GLOBALS['user'] = User::get_from_username($username); } // Get the list of possible methods for the Ampache API |