summaryrefslogtreecommitdiff
path: root/plugins/Lyrics.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Lyrics.py')
-rw-r--r--plugins/Lyrics.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/plugins/Lyrics.py b/plugins/Lyrics.py
index 56144aa..fe69b06 100644
--- a/plugins/Lyrics.py
+++ b/plugins/Lyrics.py
@@ -8,7 +8,6 @@ import webbrowser
import urllib
from misc import *
-from clSettings import settings,mpdSettings
from clMonty import monty
from clPlugin import *
@@ -23,10 +22,11 @@ class AddHtmlEvent(QtCore.QEvent):
QtCore.QEvent.__init__(self,QtCore.QEvent.User)
self.html=html
-LY_DEFAULT_ENGINE='http://www.google.com/search?q=lyrics+"$artist"+"$title"'
-LY_DEFAULT_SITES='azlyrics.com <br><br>.*?<br><br>(.*?)<br><br>\n'\
+LYRICS_ENGINE_DEFAULT='http://www.google.com/search?q=lyrics+"$artist"+"$title"'
+LYRICS_SITES_DEFAULT='azlyrics.com <br><br>.*?<br><br>(.*?)<br><br>\n'\
'oldielyrics.com song_in_top2.*?<br><br>(.*?)<script\n'\
- 'lyricstime.com phone-left.gif.*?<p>(.*?)</p>\n'\
+ 'lyricstime.com phone-left.gif.*?<p>(.*?)</p>\n'
+LYRICS_DIR_DEFAULT='/rabbit'
class wgLyrics(QtGui.QWidget):
" contains the lyrics"
@@ -38,8 +38,9 @@ class wgLyrics(QtGui.QWidget):
btnSearch=None
editMode=False
p=None # plugin
- def __init__(self, parent=None):
+ def __init__(self, p, parent=None):
QtGui.QWidget.__init__(self, parent)
+ self.p=p
self.curLyrics=""
self.btnEdit=Button("Edit lyrics", self.onBtnEditClick)
self.btnRefetch=Button("Refetch", self.onBtnRefetchClick)
@@ -70,7 +71,7 @@ class wgLyrics(QtGui.QWidget):
def onBtnSearch(self):
- SE=settings.get('lyrics.engine', LY_DEFAULT_ENGINE)
+ SE=self.p.getSetting('engine')
f=format.compile(SE)
SE_url=toAscii(f(format.params(monty.getCurrentSong())))
webbrowser.open(urllib.quote(SE_url, ":/+?="))
@@ -119,7 +120,7 @@ class wgLyrics(QtGui.QWidget):
self.txtView.insertHtml(event.html)
def getLyricsFilePath(self, song):
- save_dir=settings.get('lyrics.dir', '/holy_grail')
+ save_dir=self.p.getSetting('dir')
fInfo=QtCore.QFileInfo(save_dir)
if fInfo.isDir():
fName="%s - %s.txt"%(song.getArtist(), song.getTitle())
@@ -160,13 +161,13 @@ class wgLyrics(QtGui.QWidget):
QtCore.QCoreApplication.postEvent(self, AddHtmlEvent('<i>Searching lyrics ...</i>'))
self.p.extended("Fetch lyrics from internet")
- lines=settings.get('lyrics.sites', LY_DEFAULT_SITES).split('\n')
+ lines=self.p.getSetting('sites').split('\n')
sites={}
for line in lines:
if line.strip():
sites[line[0:line.find('\t')]]=line[line.find('\t'):].strip()
# construct URL to search!
- SE=settings.get('lyrics.engine', LY_DEFAULT_ENGINE)
+ SE=self.p.getSetting('engine')
try:
ret=fetch(SE, sites, song, {})
if ret:
@@ -214,8 +215,7 @@ class pluginLyrics(Plugin):
self.addMontyListener('onReady', self.refresh)
self.addMontyListener('onDisconnect', self.onDisconnect)
def _load(self):
- self.o=wgLyrics(None)
- self.o.p=self
+ self.o=wgLyrics(self, None)
self.o.refresh()
def _unload(self):
self.o=None
@@ -233,11 +233,11 @@ class pluginLyrics(Plugin):
def _getSettings(self):
sites=QtGui.QTextEdit()
- sites.insertPlainText(settings.get('lyrics.sites', LY_DEFAULT_SITES))
+ sites.insertPlainText(self.getSetting('sites'))
return [
- ['lyrics.engine', 'Search engine', 'The URL that is used to search. $artist, $title and $album are replaced in the URL.', QtGui.QLineEdit(settings.get('lyrics.engine', LY_DEFAULT_ENGINE))],
+ ['lyrics.engine', 'Search engine', 'The URL that is used to search. $artist, $title and $album are replaced in the URL.', QtGui.QLineEdit(self.getSetting('engine'))],
['lyrics.sites', 'Sites & regexes', 'This field contains all sites, together with the regex needed to fetch the lyrics.\nEvery line must look like this: $domain $regex-start(.*?)$regex-end\n$domain is the domain of the lyrics website, $regex-start is the regex indicating the start of the lyrics, $regex-end indicates the end. E.g. foolyrics.org <lyrics>(.*?)</lyrics>', sites],
- ['lyrics.dir', 'Lyrics directory', 'Directory where lyrics should be stored and retrieved.', QtGui.QLineEdit(settings.get('lyrics.dir'))],
+ ['lyrics.dir', 'Lyrics directory', 'Directory where lyrics should be stored and retrieved.', QtGui.QLineEdit(self.getSetting('dir'))],
]
def afterSaveSettings(self):
self.o.refresh()