summaryrefslogtreecommitdiff
path: root/plugins/Tabs.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Tabs.py')
-rw-r--r--plugins/Tabs.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/plugins/Tabs.py b/plugins/Tabs.py
index 8058c42..8ebf761 100644
--- a/plugins/Tabs.py
+++ b/plugins/Tabs.py
@@ -5,7 +5,6 @@ from thread import start_new_thread
from traceback import print_exc
from misc import *
-from clSettings import settings,mpdSettings
from clMonty import monty
from clPlugin import *
@@ -20,8 +19,9 @@ class AddHtmlEvent(QtCore.QEvent):
QtCore.QEvent.__init__(self,QtCore.QEvent.User)
self.html=html
-TABS_DEFAULT_ENGINE='http://www.google.com/search?q=tabs|chords+"$artist"+"$title"'
-TABS_DEFAULT_SITES='azchords.com <pre>(.*?)</pre>\n'\
+TABS_DIR_DEFAULT='/jammin'
+TABS_ENGINE_DEFAULT='http://www.google.com/search?q=tabs|chords+"$artist"+"$title"'
+TABS_SITES_DEFAULT='azchords.com <pre>(.*?)</pre>\n'\
'fretplay.com <P CLASS="tabs">(.*?)</P>\n'\
'guitaretab.com <pre style="COLOR: #000000; FONT-SIZE: 11px;">(.*)?</pre>'\
@@ -29,8 +29,9 @@ class wgTabs(QtGui.QWidget):
" contains the tabs"
txt=None
p=None # plugin
- def __init__(self, parent=None):
+ def __init__(self, p, parent=None):
QtGui.QWidget.__init__(self, parent)
+ self.p=p
self.txt=QtGui.QTextEdit(parent)
self.txt.setReadOnly(True)
@@ -70,7 +71,7 @@ class wgTabs(QtGui.QWidget):
QtCore.QCoreApplication.postEvent(self, ResetEvent(song))
# save the data to file!
- save_dir=settings.get('tabs.dir', '/holy_grail')
+ save_dir=self.p.getSetting('dir')
fInfo=QtCore.QFileInfo(save_dir)
if fInfo.isDir():
tabsFName=toAscii('%s/%s - %s.txt'%(save_dir,song.getArtist(),song.getTitle()))
@@ -90,13 +91,13 @@ class wgTabs(QtGui.QWidget):
# fetch from inet
QtCore.QCoreApplication.postEvent(self, AddHtmlEvent('<i>Searching tabs ...</i>'))
- lines=settings.get('tabs.sites', TABS_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('tabs.engine', TABS_DEFAULT_ENGINE)
+ SE=self.p.getSetting('engine')
try:
ret=fetch(SE, sites, song, {})
if ret:
@@ -137,8 +138,7 @@ class pluginTabs(Plugin):
self.addMontyListener('onReady', self.refresh)
self.addMontyListener('onDisconnect', self.onDisconnect)
def _load(self):
- self.o=wgTabs(None)
- self.o.p=self
+ self.o=wgTabs(self, None)
self.refresh(None)
def _unload(self):
self.o=None
@@ -155,11 +155,11 @@ class pluginTabs(Plugin):
def _getSettings(self):
sites=QtGui.QTextEdit()
- sites.insertPlainText(settings.get('tabs.sites', TABS_DEFAULT_SITES))
+ sites.insertPlainText(self.getSetting('sites'))
return [
- ['tabs.engine', 'Search engine', 'The URL that is used to search. $artist, $title and $album are replaced in the URL.', QtGui.QLineEdit(settings.get('tabs.engine', TABS_DEFAULT_ENGINE))],
+ ['tabs.engine', 'Search engine', 'The URL that is used to search. $artist, $title and $album are replaced in the URL.', QtGui.QLineEdit(self.getSetting('engine'))],
['tabs.sites', 'Sites & regexes', 'This field contains all sites, together with the regex needed to fetch the tabs.\nEvery line must look like this: $domain $regex-start(.*?)$regex-end\n$domain is the domain of the tabs website, $regex-start is the regex indicating the start of the tabs, $regex-end indicates the end. E.g. footabs.org <tabs>(.*?)</tabs>', sites],
- ['tabs.dir', 'Tabs directory', 'Directory where tabs should be stored and retrieved.', QtGui.QLineEdit(settings.get('tabs.dir'))],
+ ['tabs.dir', 'Tabs directory', 'Directory where tabs should be stored and retrieved.', QtGui.QLineEdit(self.getSetting('dir'))],
]
def afterSaveSettings(self):
self.o.onSongChange(None)