diff options
-rw-r--r-- | nephilim/clSong.py | 10 | ||||
-rw-r--r-- | nephilim/misc.py | 8 | ||||
-rw-r--r-- | nephilim/plugins/AlbumCover.py | 4 | ||||
-rw-r--r-- | nephilim/winMain.py | 6 |
4 files changed, 20 insertions, 8 deletions
diff --git a/nephilim/clSong.py b/nephilim/clSong.py index 9b38076..c041b91 100644 --- a/nephilim/clSong.py +++ b/nephilim/clSong.py @@ -1,15 +1,11 @@ from PyQt4 import QtCore -from misc import ORGNAME, APPNAME, sec2min import os -# compare two songs with respect to their album -def isSameAlbum(song1, song2): - return song1.getAlbum()==song2.getAlbum() \ - and song1.getTag('date')==song2.getTag('date') +from misc import sec2min class Song: """The Song class offers an abstraction of a song.""" - _data=None + _data = None def __init__(self, data): self._data=data @@ -79,7 +75,9 @@ class Song: def expand_tags(self, str): """Expands tags in form $tag in str.""" ret = str + ret = ret.replace('$title', self.getTitle()) #to ensure that it is set to at least filename for tag in self._data: ret = ret.replace('$' + tag, unicode(self._data[tag])) + ret = ret.replace('$songdir', os.path.dirname(self.getFilepath())) return ret diff --git a/nephilim/misc.py b/nephilim/misc.py index b07360d..fc6af72 100644 --- a/nephilim/misc.py +++ b/nephilim/misc.py @@ -83,3 +83,11 @@ class Button(QtGui.QPushButton): icon=QtGui.QIcon() icon.addFile(iconPath, QtCore.QSize(self.iconSize, self.iconSize)) self.setIcon(icon) + +def expand_tags(str, expanders): + ret = str + + for expander in expanders: + ret = expander.expand_tags(ret) + + return ret diff --git a/nephilim/plugins/AlbumCover.py b/nephilim/plugins/AlbumCover.py index a858d25..a27dd6f 100644 --- a/nephilim/plugins/AlbumCover.py +++ b/nephilim/plugins/AlbumCover.py @@ -6,7 +6,7 @@ import shutil import logging from ..clPlugin import Plugin -from ..misc import ORGNAME, APPNAME +from ..misc import ORGNAME, APPNAME, expand_tags # FETCH MODES AC_NO_FETCH = 0 @@ -67,7 +67,7 @@ class wgAlbumCover(QtGui.QLabel): return dirname = unicode(self.p.settings.value(self.p.getName() + '/coverdir').toString()) - self.cover_dirname = dirname.replace('$musicdir', self.p.settings.value('MPD/music_dir').toString()).replace('$songdir', os.path.dirname(song.getFilepath())) + self.cover_dirname = expand_tags(dirname, (self.p.winMain, song)) filebase = unicode(self.p.settings.value(self.p.getName() + '/covername').toString()) self.cover_filepath = os.path.join(self.cover_dirname, song.expand_tags(filebase).replace(os.path.sep, '_')) self.fetchCover(song) diff --git a/nephilim/winMain.py b/nephilim/winMain.py index 51da107..2faa615 100644 --- a/nephilim/winMain.py +++ b/nephilim/winMain.py @@ -275,3 +275,9 @@ class winMain(QtGui.QMainWindow): if not self.time_slider.isSliderDown(): self.time_slider.setValue(params['newTime']) self.time_label.setText(sec2min(params['newTime']) + '/' + self.time_label.duration) + + def expand_tags(self, str): + # maybe there's a better place for this function + ret = str + ret = ret.replace('$musicdir', self.settings.value('MPD/music_dir').toString()) + return ret |