summaryrefslogtreecommitdiff
path: root/nephilim/plugins/Lyrics.py
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-05-18 19:28:16 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-05-18 19:28:16 +0200
commit054c89830726858edd40f12cae920921c9b4938f (patch)
tree5e2c3e51c7d99b09a1a1f234fc61857fce9a3bb3 /nephilim/plugins/Lyrics.py
parent46aaf7cc7735c11757a94b9d9d55af0edc0695ee (diff)
Lyrics: add some debugging messages.
Diffstat (limited to 'nephilim/plugins/Lyrics.py')
-rw-r--r--nephilim/plugins/Lyrics.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/nephilim/plugins/Lyrics.py b/nephilim/plugins/Lyrics.py
index 7eae646..d3663e0 100644
--- a/nephilim/plugins/Lyrics.py
+++ b/nephilim/plugins/Lyrics.py
@@ -18,7 +18,6 @@
from PyQt4 import QtGui,QtCore
from PyQt4.QtCore import QVariant
-import logging
import socket
from ..plugin import Plugin
@@ -34,9 +33,11 @@ except ImportError:
class wgLyrics(QtGui.QWidget):
txtView = None # text-object
p = None # plugin
+ logger = None
def __init__(self, p, parent=None):
QtGui.QWidget.__init__(self, parent)
self.p = p
+ self.logger = p.logger
self.curLyrics = ''
self.txtView = QtGui.QTextEdit(self)
@@ -64,8 +65,10 @@ class wgLyrics(QtGui.QWidget):
return
if lyrics:
+ self.logger.info('Setting new lyrics.')
self.txtView.insertPlainText(lyrics)
else:
+ self.logger.info('Lyrics not found.')
self.txtView.insertPlainText('Lyrics not found.')
class Lyrics(Plugin):
@@ -102,6 +105,7 @@ class Lyrics(Plugin):
self.fetch_func(self.song)
def refresh(self):
+ self.logger.info('Autorefreshing lyrics.')
song = self.mpclient().current_song()
if not song:
return self.o.set_lyrics(None, None)
@@ -110,21 +114,24 @@ class Lyrics(Plugin):
self.settings().value(self.name() + '/lyricdir').toString(),
self.settings().value(self.name() + '/lyricname').toString())
try:
+ self.logger.info('Trying to read lyrics from file %s.'%self.lyrics_path)
file = open(self.lyrics_path, 'r')
lyrics = file.read().decode('utf-8')
file.close()
if lyrics:
return self.emit(QtCore.SIGNAL('new_lyrics_fetched'), song, lyrics)
except IOError, e:
- logging.info('Error reading lyrics file: %s.'%e)
+ self.logger.info('Error reading lyrics file: %s.'%e)
thread = self.FetchThread(self, self._fetch_lyrics, song)
thread.start()
def _fetch_lyrics(self, song):
+ self.logger.info('Trying to download lyrics from internet.')
lyrics = None
for site in self.sites:
+ self.logger.info('Trying %s.'%site)
lyrics = eval('self.fetch_%s(song)'%site)
if lyrics:
try:
@@ -132,7 +139,7 @@ class Lyrics(Plugin):
file.write(lyrics.encode('utf-8'))
file.close()
except IOError, e:
- logging.error('Error saving lyrics: %s'%e)
+ self.logger.error('Error saving lyrics: %s'%e)
return self.emit(QtCore.SIGNAL('new_lyrics_fetched'), song, lyrics)
self.emit(QtCore.SIGNAL('new_lyrics_fetched'), song, None)
@@ -145,7 +152,7 @@ class Lyrics(Plugin):
try:
result = soap.getSong(req).Return.Lyrics.decode('utf-8').encode('iso8859').decode('utf-8')
except socket.error, e:
- logging.error('Error downloading lyrics from LyricWiki: %s.'%e)
+ self.logger.error('Error downloading lyrics from LyricWiki: %s.'%e)
return None
return result if result != 'Not found' else None