summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/localplay/mpd.controller.php44
-rw-r--r--modules/mpd/mpd.class.php16
-rw-r--r--modules/plugins/Lastfm.plugin.php3
3 files changed, 29 insertions, 34 deletions
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php
index a35678ae..e442c6f8 100644
--- a/modules/localplay/mpd.controller.php
+++ b/modules/localplay/mpd.controller.php
@@ -277,30 +277,17 @@ class AmpacheMpd extends localplay_controller {
} // add_songs
/**
- * delete_songs
- * This must take an array of ID's (as passed by get function) from Ampache
- * and delete them from MPD
+ * delete_track
+ * This must take a single ID (as passed by get function) from Ampache
+ * and delete it from the current playlist
*/
- public function delete($objects) {
+ public function delete_track($object_id) {
- /* Default to true */
- $return = true;
+ if (is_null($this->_mpd->PLRemove($object_id))) { return false; }
- /* This should be an array of UID's as returned by
- * the get function so that we can just call the class based
- * functions to remove them or if there isn't a uid for
- * the songs, then however ya'll have stored them
- * in this controller
- */
- foreach ($songs as $uid) {
-
- if (is_null($this->_mpd->PLRemove($uid))) { $return = false; }
-
- } // foreach of songs
-
- return $return;
+ return true;
- } // delete_songs
+ } // delete_track
/**
* clear_playlist
@@ -456,6 +443,11 @@ class AmpacheMpd extends localplay_controller {
*/
public function get() {
+ // If we don't have the playlist yet, pull it
+ if (!isset($this->_mpd->playlist)) {
+ $this->_mpd->GetPlaylist();
+ }
+
/* Get the Current Playlist */
$playlist = $this->_mpd->playlist;
@@ -474,10 +466,10 @@ class AmpacheMpd extends localplay_controller {
/* If we don't know it, look up by filename */
if (!$song->title) {
- $filename = sql_escape($entry['file']);
- $sql = "SELECT id FROM song WHERE file LIKE '%$filename'";
- $db_results = mysql_query($sql, dbh());
- if ($r = mysql_fetch_assoc($db_results)) {
+ $filename = Dba::escape($entry['file']);
+ $sql = "SELECT `id` FROM `song` WHERE `file` LIKE '%$filename'";
+ $db_results = Dba::query($sql);
+ if ($r = Dba::fetch_assoc($db_results)) {
$song = new Song($r['id']);
}
else {
@@ -486,7 +478,7 @@ class AmpacheMpd extends localplay_controller {
}
/* Make the name pretty */
- $song->format_song();
+ $song->format();
$data['name'] = $song->f_title . ' - ' . $song->f_album . ' - ' . $song->f_artist;
/* Optional Elements */
@@ -499,7 +491,7 @@ class AmpacheMpd extends localplay_controller {
return $results;
- } // get_songs
+ } // get
/**
* get_status
diff --git a/modules/mpd/mpd.class.php b/modules/mpd/mpd.class.php
index 529465fa..dc7d22ac 100644
--- a/modules/mpd/mpd.class.php
+++ b/modules/mpd/mpd.class.php
@@ -467,16 +467,15 @@ class mpd {
*
* Removes track <id> from the playlist.
*/
- function PLRemove($id) {
- if ( $this->debugging ) echo "mpd->PLRemove()\n";
+ public function PLRemove($id) {
if ( ! is_numeric($id) ) {
$this->errStr = "PLRemove() : argument 1 must be a numeric value";
return NULL;
}
if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLREMOVE,$id))) $this->RefreshInfo();
- if ( $this->debugging ) echo "mpd->PLRemove() / return\n";
+ debug_event('MPD',"mpd->PLRemove() / return",'5');
return $resp;
- }
+ } // PLRemove
/* SetRepeat()
*
@@ -970,13 +969,14 @@ class mpd {
* NOTE: This function really should not be used. Instead, use $this->playlist. The function
* will most likely be deprecated in future releases.
*/
- function GetPlaylist() {
- if ( $this->debugging ) echo "mpd->GetPlaylist()\n";
+ public function GetPlaylist() {
+
$resp = $this->SendCommand(MPD_CMD_PLLIST);
$playlist = $this->_parseFileListResponse($resp);
- if ( $this->debugging ) echo "mpd->GetPlaylist() / return ".print_r($playlist)."\n";
+ debug_event('MPD',"mpd->GetPlaylist() / return ".print_r($playlist,1),'5');
return $playlist;
- }
+
+ } // GetPlaylist
/* ClearPLIfStopped()
*
diff --git a/modules/plugins/Lastfm.plugin.php b/modules/plugins/Lastfm.plugin.php
index 0d9c4b18..0804bb26 100644
--- a/modules/plugins/Lastfm.plugin.php
+++ b/modules/plugins/Lastfm.plugin.php
@@ -101,6 +101,9 @@ class AmpacheLastfm {
debug_event('LastFM','Song less then 30 seconds not queueing','3');
return false;
}
+
+ // Make sure there's actually a username and password before we keep going
+ if (!$this->username || !$this->password) { return false; }
// Create our scrobbler with everything this time and then queue it
$scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge);