summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl Vollmer <karl.vollmer@dal.ca>2011-11-28 11:22:47 -0400
committerKarl Vollmer <karl.vollmer@dal.ca>2011-11-28 11:22:47 -0400
commit2c06cb5440e7075721872538e661850932eaa55b (patch)
tree74e7ed06a126c0c9cb0c08af09f5256861b37844 /lib
parente862098f66d7959663715b7b7002cf087f0fe3cd (diff)
downloadampache-2c06cb5440e7075721872538e661850932eaa55b.tar.gz
ampache-2c06cb5440e7075721872538e661850932eaa55b.tar.bz2
ampache-2c06cb5440e7075721872538e661850932eaa55b.zip
Switched API to exceptions rather then trigger_error in most instances, more work on the
remote catalog indexing.
Diffstat (limited to 'lib')
-rw-r--r--lib/class/api.class.php2
-rw-r--r--lib/class/catalog.class.php27
2 files changed, 22 insertions, 7 deletions
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index 54fa0a94..7d1c8840 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -210,7 +210,7 @@ class Api {
$db_results = Dba::read($sql);
$playlist = Dba::fetch_assoc($db_results);
- $sql = "SELECT COUNT(`id`) AS `catalog` FROM `catalog`";
+ $sql = "SELECT COUNT(`id`) AS `catalog` FROM `catalog` WHERE `catalog_type`='local'";
$db_results = Dba::read($sql);
$catalog = Dba::fetch_assoc($db_results);
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 84471c33..de13c910 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -1290,11 +1290,19 @@ class Catalog extends database_object {
*/
public function get_remote_catalog($type=0) {
- $remote_handle = new AmpacheApi(array('username'=>'','password'=>'','server'=>''));
+ try {
+ $remote_handle = new AmpacheApi(array('username'=>$this->remote_username,'password'=>$this->remote_password,'server'=>$this->path,'debug'=>true));
+ } catch (Exception $e) {
+ Error::add('general',$e->getMessage());
+ Error::display('general');
+ flush();
+ return false;
+ }
- if ($remote_handle->state() != 'READY') {
+ if ($remote_handle->state() != 'CONNECTED') {
debug_event('APICLIENT','Error Unable to make API client ready','1');
Error::add('general',_('Error Connecting to Remote Server'));
+ Error::display('general');
return false;
}
@@ -1302,7 +1310,7 @@ class Catalog extends database_object {
$remote_catalog_info = $remote_handle->info();
// Tell em what we've found johnny!
- printf(_('%u remote catalogs found (%u songs)'),$remote_catalog_info['catalogs'],$remote_catalog_info['songs']);
+ printf(_('%u remote catalog(s) found (%u songs)'),$remote_catalog_info['catalogs'],$remote_catalog_info['songs']);
flush();
// Hardcoded for now
@@ -1313,9 +1321,16 @@ class Catalog extends database_object {
while ($total > $current) {
$start = $current;
$current += $step;
- $remote_handle->parse_response($remote_handle->send_command('songs',array('offset'=>$start,'limit'=>$step)));
- $songs = $remote_handle->get_response();
- }
+ // It uses exceptions so lets try this
+ try {
+ $remote_handle->parse_response($remote_handle->send_command('songs',array('offset'=>$start,'limit'=>$step)));
+ $songs = $remote_handle->get_response();
+ } catch (Exception $e) {
+ Error::add('general',$e->getMessage());
+ Error::display('general');
+ flush();
+ }
+ } // end while
echo "<p>" . _('Completed updating remote catalog(s)') . ".</p><hr />\n";
flush();