summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nephilim/clPlugin.py2
-rw-r--r--nephilim/mpclient.py49
-rw-r--r--nephilim/plugins/AlbumCover.py6
-rw-r--r--nephilim/plugins/Filebrowser.py2
-rw-r--r--nephilim/plugins/Library.py4
-rw-r--r--nephilim/plugins/Lyrics.py2
-rw-r--r--nephilim/plugins/Notify.py2
-rw-r--r--nephilim/plugins/PlayControl.py6
-rw-r--r--nephilim/plugins/Playlist.py4
-rw-r--r--nephilim/plugins/Systray.py8
-rw-r--r--nephilim/winMain.py6
-rw-r--r--nephilim/winSettings.py4
12 files changed, 47 insertions, 48 deletions
diff --git a/nephilim/clPlugin.py b/nephilim/clPlugin.py
index ed1ed69..5849634 100644
--- a/nephilim/clPlugin.py
+++ b/nephilim/clPlugin.py
@@ -59,7 +59,7 @@ class Plugin:
if len(self.listeners):
logging.debug("removing %s listeners"%(len(self.listeners)))
for listener in self.listeners:
- self.mpclient.removeListener(listener[0], listener[1])
+ self.mpclient.remove_listener(listener[0], listener[1])
self._unload()
dock_widget = self.getDockWidget()
diff --git a/nephilim/mpclient.py b/nephilim/mpclient.py
index 291ae05..055574d 100644
--- a/nephilim/mpclient.py
+++ b/nephilim/mpclient.py
@@ -75,7 +75,7 @@ class MPClient(QtCore.QObject):
self._update_current_song()
self._timer_id = self.startTimer(500)
- self._raiseEvent('onStateChange', {'oldState':'stop', 'newState':self.getStatus()['state']})
+ self._raiseEvent('onStateChange', {'oldState':'stop', 'newState':self.status()['state']})
self._raiseEvent('onReady', None)
return True
@@ -86,29 +86,29 @@ class MPClient(QtCore.QObject):
self._client.disconnect()
self._client = None
- def isConnected(self):
+ def is_connected(self):
"""Returns True if connected to MPD, False otherwise."""
return self._client != None
- def listPlaylist(self):
+ def playlist(self):
"""Returns the current playlist."""
- if not self.isConnected():
+ if not self.is_connected():
return []
return self._cur_playlist
- def listLibrary(self):
+ def library(self):
"""Returns current library."""
- if not self.isConnected():
+ if not self.is_connected():
return []
return self._cur_lib
- def getCurrentSong(self):
+ def current_song(self):
"""Returns the current playing song."""
- if not self.isConnected():
+ if not self.is_connected():
return None
return self._cur_song
- def updateDB(self, paths = None):
+ def update_db(self, paths = None):
"""Starts MPD database update."""
if not paths:
return self._client.update()
@@ -117,9 +117,9 @@ class MPClient(QtCore.QObject):
self._client.update(path)
self._client.command_list_end()
- def getStatus(self):
+ def status(self):
"""Get current status"""
- if self.isConnected() == False:
+ if self.is_connected() == False:
return None
ret = self._retrieve(self._client.status)
if 'time' in ret:
@@ -132,9 +132,9 @@ class MPClient(QtCore.QObject):
ret['time'] = 0
return ret
- def get_outputs(self):
+ def outputs(self):
"""Returns an array of configured MPD audio outputs."""
- if self.isConnected():
+ if self.is_connected():
return self._retrieve(self._client.outputs)
else:
return []
@@ -147,7 +147,7 @@ class MPClient(QtCore.QObject):
def urlhandlers(self):
"""Returns an array of available url handlers."""
- if not self.isConnected():
+ if not self.is_connected():
return []
else:
return self._client.urlhandlers()
@@ -163,10 +163,9 @@ class MPClient(QtCore.QObject):
val = 1 if val else 0
self._client.random(val)
-
- def isPlaying(self):
+ def is_playing(self):
"""Returns True if MPD is playing, False otherwise."""
- return self.getStatus()['state'] == 'play'
+ return self.status()['state'] == 'play'
def play(self, id = None):
"""Play song with ID id or next song if id is None."""
@@ -203,19 +202,19 @@ class MPClient(QtCore.QObject):
if self._cur_songid > 0:
self._client.seekid(self._cur_songid, time)
- def deleteFromPlaylist(self, list):
+ def delete(self, list):
"""Remove all song IDs in list from the playlist."""
self._client.command_list_ok_begin()
for id in list:
self._client.deleteid(id)
self._client.command_list_end()
self._update_playlist()
- def clear_playlist(self):
+ def clear(self):
"""Clear current playlist."""
self._client.clear()
self._update_playlist()
- def addToPlaylist(self, paths):
+ def add(self, paths):
"""Add all files in paths to the current playlist."""
try:
self._client.command_list_ok_begin()
@@ -228,19 +227,19 @@ class MPClient(QtCore.QObject):
except mpd.CommandError:
logging.error('Cannot add some files, check permissions.')
- def setVolume(self, volume):
+ def volume(self):
+ return int(self.status()['volume'])
+ def set_volume(self, volume):
"""Set volume to volume."""
volume = min(100, max(0, volume))
self._client.setvol(volume)
- def getVolume(self):
- return int(self.getStatus()['volume'])
def add_listener(self, event, callback):
"""Add callback to the listeners for event."""
if not(event in self.events):
raise Exception("Unknown event "+event)
self._listeners[event].append(callback)
- def removeListener(self, event, callback):
+ def remove_listener(self, event, callback):
"""Remove callback from listeners for event."""
if not(event in self.events):
raise Exception("Unknown event "+event)
@@ -301,7 +300,7 @@ class MPClient(QtCore.QObject):
def timerEvent(self, event):
"""Check for changes since last check."""
- status = self.getStatus()
+ status = self.status()
if status == None:
self._client = None
diff --git a/nephilim/plugins/AlbumCover.py b/nephilim/plugins/AlbumCover.py
index ee51903..5330189 100644
--- a/nephilim/plugins/AlbumCover.py
+++ b/nephilim/plugins/AlbumCover.py
@@ -67,7 +67,7 @@ class wgAlbumCover(QtGui.QLabel):
def refresh(self):
logging.info("refreshing cover")
- song = self.p.mpclient.getCurrentSong()
+ song = self.p.mpclient.current_song()
if not song:
self.clear()
self.cover_loaded = False
@@ -108,7 +108,7 @@ class wgAlbumCover(QtGui.QLabel):
self.set_cover(cover, write)
def fetch_local_manual(self):
- song = self.p.mpclient.getCurrentSong()
+ song = self.p.mpclient.current_song()
if not song:
return
@@ -157,7 +157,7 @@ class wgAlbumCover(QtGui.QLabel):
return None
def fetch_amazon_manual(self):
- song = self.p.mpclient.getCurrentSong()
+ song = self.p.mpclient.current_song()
if not song:
return
cover = self.fetch_amazon(song)
diff --git a/nephilim/plugins/Filebrowser.py b/nephilim/plugins/Filebrowser.py
index b4d055d..5faa678 100644
--- a/nephilim/plugins/Filebrowser.py
+++ b/nephilim/plugins/Filebrowser.py
@@ -62,7 +62,7 @@ class wgFilebrowser(QtGui.QWidget):
paths = []
for index in self.view.selectedIndexes():
paths.append(u'file://' + unicode(self.model.filePath(index)))
- self.plugin.mpclient.addToPlaylist(paths)
+ self.plugin.mpclient.add(paths)
def path_changed(self):
if os.path.isdir(self.path.text()):
diff --git a/nephilim/plugins/Library.py b/nephilim/plugins/Library.py
index 24fab35..ebc49ab 100644
--- a/nephilim/plugins/Library.py
+++ b/nephilim/plugins/Library.py
@@ -97,7 +97,7 @@ class LibraryWidget(QtGui.QWidget):
#build a tree from library
tree = [{},self.library.invisibleRootItem()]
- for song in self.plugin.mpclient.listLibrary():
+ for song in self.plugin.mpclient.library():
cur_item = tree
for part in str(self.modes.currentText()).split('/'):
tag = song.getTag(part)
@@ -141,7 +141,7 @@ class LibraryWidget(QtGui.QWidget):
paths = []
for item in self.library.selectedItems():
self.item_to_playlist(item, paths)
- self.plugin.mpclient.addToPlaylist(paths)
+ self.plugin.mpclient.add(paths)
def item_to_playlist(self, item, add_queue):
if item.type() == 1000:
diff --git a/nephilim/plugins/Lyrics.py b/nephilim/plugins/Lyrics.py
index e0ca09f..c0b0fe3 100644
--- a/nephilim/plugins/Lyrics.py
+++ b/nephilim/plugins/Lyrics.py
@@ -58,7 +58,7 @@ class Lyrics(Plugin):
def refresh(self, params = None):
lyrics = None
- song = self.mpclient.getCurrentSong()
+ song = self.mpclient.current_song()
if not song:
self.o.set_lyrics(None, None)
return
diff --git a/nephilim/plugins/Notify.py b/nephilim/plugins/Notify.py
index b784534..f086693 100644
--- a/nephilim/plugins/Notify.py
+++ b/nephilim/plugins/Notify.py
@@ -98,7 +98,7 @@ class Notify(Plugin):
return "Show interesting events in a popup window."
def onSongChange(self, params):
- song = self.mpclient.getCurrentSong()
+ song = self.mpclient.current_song()
if not song:
return
self.settings.beginGroup(self.name)
diff --git a/nephilim/plugins/PlayControl.py b/nephilim/plugins/PlayControl.py
index e8dda8c..3ff7170 100644
--- a/nephilim/plugins/PlayControl.py
+++ b/nephilim/plugins/PlayControl.py
@@ -85,7 +85,7 @@ class wgPlayControl(QtGui.QToolBar):
self.queuedSongs.extend(songs)
def onStateChange(self, params):
- status = self.p.mpclient.getStatus()
+ status = self.p.mpclient.status()
if status['state'] == 'play':
self.btnPlayPause.changeIcon('gfx/media-playback-pause.svg')
@@ -98,7 +98,7 @@ class wgPlayControl(QtGui.QToolBar):
self.slrVolume.setValue(params['newVolume'])
def onBtnPlayPauseClick(self):
- status=self.p.mpclient.getStatus()
+ status=self.p.mpclient.status()
if status['state']=='play':
self.p.mpclient.pause()
logging.info("Toggling playback")
@@ -118,7 +118,7 @@ class wgPlayControl(QtGui.QToolBar):
logging.info("Playing next")
def onVolumeSliderChange(self):
v=self.slrVolume.value()
- self.p.mpclient.setVolume(v)
+ self.p.mpclient.set_volume(v)
if v<=1:
mode='mute'
else:
diff --git a/nephilim/plugins/Playlist.py b/nephilim/plugins/Playlist.py
index 230486c..e57c9ac 100644
--- a/nephilim/plugins/Playlist.py
+++ b/nephilim/plugins/Playlist.py
@@ -71,7 +71,7 @@ class PlaylistWidget(QtGui.QWidget):
def fill(self):
columns = self.plugin.settings.value(self.plugin.getName() + '/columns').toStringList()
self.clear()
- for song in self.plugin.mpclient.listPlaylist():
+ for song in self.plugin.mpclient.playlist():
item = QtGui.QTreeWidgetItem()
for i in range(len(columns)):
item.setText(i, unicode(song.getTag(str(columns[i]))))
@@ -84,7 +84,7 @@ class PlaylistWidget(QtGui.QWidget):
for item in self.selectedItems():
ids.append(item.data(0, QtCore.Qt.UserRole).toPyObject().getID())
- self.plugin.mpclient.deleteFromPlaylist(ids)
+ self.plugin.mpclient.delete(ids)
else:
QtGui.QTreeWidget.keyPressEvent(self, event)
diff --git a/nephilim/plugins/Systray.py b/nephilim/plugins/Systray.py
index 1a9eca8..4a3c45d 100644
--- a/nephilim/plugins/Systray.py
+++ b/nephilim/plugins/Systray.py
@@ -29,7 +29,7 @@ class Systray(Plugin):
if type(event)==QtGui.QWheelEvent:
numDegrees=event.delta() / 8
numSteps=5*numDegrees/15
- self.plugin.mpclient.setVolume(self.plugin.mpclient.getVolume() + numSteps)
+ self.plugin.mpclient.set_volume(self.plugin.mpclient.volume() + numSteps)
event.accept()
return True
return False
@@ -51,7 +51,7 @@ class Systray(Plugin):
return "Display the mpclientpc icon in the systray."
def update(self, params):
- status = self.mpclient.getStatus()
+ status = self.mpclient.status()
if not status:
return
@@ -61,7 +61,7 @@ class Systray(Plugin):
values['length'] = sec2min(status['length'])
values['time'] = sec2min(status['time'])
- song = self.mpclient.getCurrentSong()
+ song = self.mpclient.current_song()
if song:
self.o.setToolTip(expand_tags(self.format, (song,)))
else:
@@ -93,7 +93,7 @@ class Systray(Plugin):
else:
w.setVisible(True)
elif reason == QtGui.QSystemTrayIcon.MiddleClick:
- if self.mpclient.isPlaying():
+ if self.mpclient.is_playing():
self.mpclient.pause()
else:
self.mpclient.resume()
diff --git a/nephilim/winMain.py b/nephilim/winMain.py
index 6ba3595..934ecf1 100644
--- a/nephilim/winMain.py
+++ b/nephilim/winMain.py
@@ -253,8 +253,8 @@ class winMain(QtGui.QMainWindow):
self.setStatus('Updating the database. Please wait ...')
def update_state_messages(self, params = None):
- song = self.mpclient.getCurrentSong()
- if song and self.mpclient.isPlaying():
+ song = self.mpclient.current_song()
+ if song and self.mpclient.is_playing():
self.setWindowTitle('%s by %s - %s'%(song.getTitle(), song.getArtist(), APPNAME))
self.statuslabel.setText('Now playing %s by %s on %s'%(song.getTitle(), song.getArtist(),song.getAlbum()))
else:
@@ -265,7 +265,7 @@ class winMain(QtGui.QMainWindow):
self.mpclient.seek(self.time_slider.value())
def on_song_change(self, params):
- status = self.mpclient.getStatus()
+ status = self.mpclient.status()
self.time_slider.setMaximum(status['length'])
self.time_slider.setEnabled(True)
self.time_label.duration = sec2min(status['length'])
diff --git a/nephilim/winSettings.py b/nephilim/winSettings.py
index 9f4d804..832aaf1 100644
--- a/nephilim/winSettings.py
+++ b/nephilim/winSettings.py
@@ -45,7 +45,7 @@ class winSettings(QtGui.QWidget):
def change_state(self, state):
self.mpclient.set_output(self.id, state)
- for output in self.mpclient.get_outputs():
+ for output in self.mpclient.outputs():
box = Output(output['outputname'])
if output['outputenabled'] == '1':
box.setChecked(True)
@@ -71,7 +71,7 @@ class winSettings(QtGui.QWidget):
self.settings.endGroup()
def update_db(self):
- self.mpclient.updateDB()
+ self.mpclient.update_db()
def __init__(self, winMain, parent=None):
QtGui.QWidget.__init__(self, parent)