summaryrefslogtreecommitdiff
path: root/nephilim/plugins
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-05-12 20:33:02 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-05-12 20:33:02 +0200
commit023dfcba8e223c163e98256bfb608d2dd80b7a87 (patch)
treea2e35580d26aa9632bf00611e3146797dee831c5 /nephilim/plugins
parent0cd5cd718e97a9cf40295bd83939043199f94497 (diff)
Lyrics: support for loading stored lyrics.
also move function for generating metadata paths to misc.py.
Diffstat (limited to 'nephilim/plugins')
-rw-r--r--nephilim/plugins/AlbumCover.py16
-rw-r--r--nephilim/plugins/Lyrics.py22
2 files changed, 21 insertions, 17 deletions
diff --git a/nephilim/plugins/AlbumCover.py b/nephilim/plugins/AlbumCover.py
index 39c750f..2c1fd55 100644
--- a/nephilim/plugins/AlbumCover.py
+++ b/nephilim/plugins/AlbumCover.py
@@ -23,7 +23,7 @@ import logging
import os
from ..plugin import Plugin
-from ..misc import APPNAME, expand_tags
+from ..misc import APPNAME, expand_tags, generate_metadata_path
# FETCH MODES
AC_NO_FETCH = 0
@@ -134,18 +134,8 @@ class wgAlbumCover(QtGui.QLabel):
logging.info("autorefreshing cover")
# generate filenames
- if QtCore.QDir.isAbsolutePath(song.filepath()):
- self._cover_dirname = os.path.dirname(song.filepath())
- self._cover_filepath = ''
- elif '://' in song.filepath(): # we are streaming
- self._cover_dirname = ''
- self._cover_filepath = ''
- else:
- dirname = self.plugin.settings().value(self.plugin.name() + '/coverdir').toString()
- self._cover_dirname = expand_tags(dirname, (self.plugin.parent(), song))
- filebase = self.plugin.settings().value(self.plugin.name() + '/covername').toString()
- self._cover_filepath = '%s/%s'%(self._cover_dirname,
- expand_tags(filebase, (self.plugin.parent(), song)).replace('/', '_'))
+ (self._cover_dirname, self._cover_filepath) = generate_metadata_path(self.plugin.parent(), song, self.plugin.settings().value(self.plugin.name() + '/coverdir').toString(),
+ self.plugin.settings().value(self.plugin.name() + '/covername').toString())
write = False
if not QtCore.QFile.exists(self._cover_filepath):
diff --git a/nephilim/plugins/Lyrics.py b/nephilim/plugins/Lyrics.py
index 3e693ea..bb14167 100644
--- a/nephilim/plugins/Lyrics.py
+++ b/nephilim/plugins/Lyrics.py
@@ -22,6 +22,7 @@ import logging
import socket
from ..plugin import Plugin
+from .. import misc
_available_sites = []
try:
@@ -68,10 +69,12 @@ class wgLyrics(QtGui.QWidget):
self.txtView.insertPlainText('Lyrics not found.')
class Lyrics(Plugin):
- o = None
- sites = []
- DEFAULTS = {'sites' : ['lyricwiki'], 'lyricdir' : '$musicdir/$songdir',
- 'lyricname' : '.lyric_mpclient_$artist_$album_$song'}
+ o = None
+ sites = []
+ lyrics_dir = None
+ lyrics_path = None
+ DEFAULTS = {'sites' : ['lyricwiki'], 'lyricdir' : '$musicdir/$songdir',
+ 'lyricname' : '.lyrics_nephilim_$artist_$album_$title', 'store' : True}
def _load(self):
self.o = wgLyrics(self)
@@ -103,6 +106,17 @@ class Lyrics(Plugin):
if not song:
return self.o.set_lyrics(None, None)
+ (self.lyrics_dir, self.lyrics_path) = misc.generate_metadata_path(self.parent(), song,
+ self.settings().value(self.name() + '/lyricdir').toString(),
+ self.settings().value(self.name() + '/lyricname').toString())
+ file = QtCore.QFile(self.lyrics_path)
+ if file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text):
+ lyrics = file.readAll()
+ file.close()
+ if lyrics:
+ return self.emit(QtCore.SIGNAL('new_lyrics_fetched'), song, QtCore.QString(lyrics))
+
+
thread = self.FetchThread(self, self._fetch_lyrics, song)
thread.start()