[rhythmbox] lyrics: use a single lyrics search site list
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] lyrics: use a single lyrics search site list
- Date: Sun, 20 Dec 2009 10:44:07 +0000 (UTC)
commit b587ef37b90191739ca6900af6a420114d46e178
Author: Jonathan Matthew <jonathan d14n org>
Date: Sun Dec 20 20:41:23 2009 +1000
lyrics: use a single lyrics search site list
Rather than having the list of sites in the UI file, in the
configuration dialog code, and in the search code, now we have a single
list that we use to do everything.
Since the LyricWiki search doesn't work and shows no sign of ever
working again, it has been removed from the list (bug #603876).
plugins/lyrics/lyrics/LyricsConfigureDialog.py | 41 +++++++++++------------
plugins/lyrics/lyrics/LyricsParse.py | 39 ++++++++--------------
plugins/lyrics/lyrics/LyricsSites.py | 39 ++++++++++++++++++++++
plugins/lyrics/lyrics/Makefile.am | 1 +
po/POTFILES.in | 1 +
5 files changed, 75 insertions(+), 46 deletions(-)
---
diff --git a/plugins/lyrics/lyrics/LyricsConfigureDialog.py b/plugins/lyrics/lyrics/LyricsConfigureDialog.py
index aab0a3e..1a5877d 100644
--- a/plugins/lyrics/lyrics/LyricsConfigureDialog.py
+++ b/plugins/lyrics/lyrics/LyricsConfigureDialog.py
@@ -25,7 +25,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
+from LyricsSites import lyrics_sites
import gobject, gtk
import gconf
@@ -41,11 +41,6 @@ class LyricsConfigureDialog (object):
self.dialog = builder.get_object("preferences_dialog")
- self.toggle1 = builder.get_object("engine1")
- self.toggle2 = builder.get_object("engine2")
- self.toggle3 = builder.get_object("engine3")
- self.toggle4 = builder.get_object("engine4")
- self.toggle5 = builder.get_object("engine5")
self.choose_button = builder.get_object("choose_button")
self.path_display = builder.get_object("path_display")
@@ -57,11 +52,18 @@ class LyricsConfigureDialog (object):
if self.folder is None:
self.folder = '~/.lyrics'
self.path_display.set_text(self.folder)
- self.toggle1.set_active('astraweb.com' in engines)
- self.toggle2.set_active('lyrc.com.ar' in engines)
- self.toggle3.set_active('leoslyrics.com' in engines)
- self.toggle4.set_active('lyricwiki.org' in engines)
- self.toggle5.set_active('winampcn.com' in engines)
+
+ # build site list
+ site_box = builder.get_object("sites")
+ self.site_checks = {}
+ for s in lyrics_sites:
+ site_id = s['id']
+ checkbutton = gtk.CheckButton(label = s['name'])
+ checkbutton.set_active(s['id'] in engines)
+ self.site_checks[site_id] = checkbutton
+ site_box.pack_start(checkbutton)
+
+ site_box.show_all()
def dialog_response(self, dialog, response):
if response == gtk.RESPONSE_OK:
@@ -75,16 +77,13 @@ class LyricsConfigureDialog (object):
def set_values(self):
engines = []
- if self.toggle1.get_active():
- engines.append('astraweb.com')
- if self.toggle2.get_active():
- engines.append('lyrc.com.ar')
- if self.toggle3.get_active():
- engines.append('leoslyrics.com')
- if self.toggle4.get_active():
- engines.append('lyricwiki.org')
- if self.toggle5.get_active():
- engines.append('winampcn.com')
+ for s in lyrics_sites:
+ check = self.site_checks[s['id']]
+ if check is None:
+ continue
+
+ if check.get_active():
+ engines.append(s['id'])
if len(self.path_display.get_text()) is not 0:
self.folder = self.path_display.get_text()
diff --git a/plugins/lyrics/lyrics/LyricsParse.py b/plugins/lyrics/lyrics/LyricsParse.py
index b321ffe..1636b72 100644
--- a/plugins/lyrics/lyrics/LyricsParse.py
+++ b/plugins/lyrics/lyrics/LyricsParse.py
@@ -31,21 +31,7 @@ import gobject
import gconf
import rb
-from LyrcParser import LyrcParser
-from AstrawebParser import AstrawebParser
-from LeoslyricsParser import LeoslyricsParser
-from LyricWikiParser import LyricWikiParser
-from WinampcnParser import WinampcnParser
-
-
-engines_map = {
- 'lyrc.com.ar': LyrcParser,
- 'astraweb.com': AstrawebParser,
- 'leoslyrics.com': LeoslyricsParser,
- 'lyricwiki.org': LyricWikiParser,
- 'winampcn.com': WinampcnParser
-}
-
+from LyricsSites import lyrics_sites
class Parser (object):
def __init__(self, gconf_keys, artist, title):
@@ -61,19 +47,22 @@ class Parser (object):
self.engines = []
def searcher(self, plexer, callback, *data):
- for e in self.engines:
+ for site in lyrics_sites:
+ if site['id'] not in self.engines:
+ print site['id'] + " search is disabled"
+ continue
+
plexer.clear()
- if e in engines_map:
- parser = engines_map[e] (self.artist, self.title)
- print "searching " + e + " for lyrics"
+ parser = site['class'] (self.artist, self.title)
+ print "searching " + site['id'] + " for lyrics"
- parser.search(plexer.send())
- yield None
+ parser.search(plexer.send())
+ yield None
- _, (lyrics,) = plexer.receive()
- if lyrics is not None:
- callback (lyrics, *data)
- return
+ _, (lyrics,) = plexer.receive()
+ if lyrics is not None:
+ callback (lyrics, *data)
+ return
callback (None, *data)
diff --git a/plugins/lyrics/lyrics/LyricsSites.py b/plugins/lyrics/lyrics/LyricsSites.py
new file mode 100644
index 0000000..971b3dc
--- /dev/null
+++ b/plugins/lyrics/lyrics/LyricsSites.py
@@ -0,0 +1,39 @@
+# -*- Mode: python; coding: utf-8; tab-width: 8; indent-tabs-mode: t; -*-
+#
+# Copyright (C) 2009 Jonathan Matthew
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# The Rhythmbox authors hereby grant permission for non-GPL compatible
+# GStreamer plugins to be used and distributed together with GStreamer
+# and Rhythmbox. This permission is above and beyond the permissions granted
+# by the GPL license by which Rhythmbox is covered. If you modify this code
+# you may extend this exception to your version of the code, but you are not
+# obligated to do so. If you do not wish to do so, delete this exception
+# statement from your version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+from LyrcParser import LyrcParser
+from AstrawebParser import AstrawebParser
+from LeoslyricsParser import LeoslyricsParser
+from WinampcnParser import WinampcnParser
+
+lyrics_sites = [
+ { 'id': 'lyrc.com.ar', 'class': LyrcParser, 'name': _("Lyrc (lyrc.com.ar)") },
+ { 'id': 'astraweb.com', 'class': AstrawebParser, 'name': _("Astraweb (www.astraweb.com)") },
+ { 'id': 'leoslyrics.com', 'class': LeoslyricsParser, 'name': _("Leo's Lyrics (www.leoslyrics.com)") },
+ { 'id': 'winampcn.com', 'class': WinampcnParser, 'name': _("WinampCN (www.winampcn.com)") }
+]
+
diff --git a/plugins/lyrics/lyrics/Makefile.am b/plugins/lyrics/lyrics/Makefile.am
index 87bf6f4..e4c4137 100644
--- a/plugins/lyrics/lyrics/Makefile.am
+++ b/plugins/lyrics/lyrics/Makefile.am
@@ -3,6 +3,7 @@
plugindir = $(PLUGINDIR)/lyrics
plugin_PYTHON = \
LyricsParse.py \
+ LyricsSites.py \
LyricsConfigureDialog.py \
__init__.py \
LyrcParser.py \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 97c7b2d..3c0ad7d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -110,6 +110,7 @@ plugins/lyrics/lyrics/LeoslyricsParser.py
plugins/lyrics/lyrics/LyrcParser.py
plugins/lyrics/lyrics/LyricsConfigureDialog.py
plugins/lyrics/lyrics/LyricsParse.py
+plugins/lyrics/lyrics/LyricsSites.py
[type: gettext/ini]plugins/lyrics/lyrics.rb-plugin.in
[type: gettext/glade]plugins/lyrics/lyrics-prefs.ui
[type: gettext/glade]plugins/magnatune/magnatune-loading.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]