summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f0cc4e8)
raw | patch | inline | side by side (parent: f0cc4e8)
author | Jeffrey Middleton <jefromi@gmail.com> | |
Tue, 10 Mar 2009 13:49:45 +0000 (08:49 -0500) | ||
committer | Jeffrey Middleton <jefromi@gmail.com> | |
Tue, 10 Mar 2009 13:49:45 +0000 (08:49 -0500) |
Lyrics plugins are tried in alphabetic order by filename. Numeric
prefixes make this clearer, and make it easier to keep hd.sh first.
I've moved LyricWiki ahead of Leo's Lyrics, mostly because it's easier
for a user to fix incorrect lyrics on a wiki, but also because Leo's
Lyrics appears to return partial matches if no full match is found (e.g.
a song with the same name and completely different artist)
prefixes make this clearer, and make it easier to keep hd.sh first.
I've moved LyricWiki ahead of Leo's Lyrics, mostly because it's easier
for a user to fix incorrect lyrics on a wiki, but also because Leo's
Lyrics appears to return partial matches if no full match is found (e.g.
a song with the same name and completely different artist)
Makefile.am | patch | blob | history | |
lyrics/01-hd.sh | [new file with mode: 0755] | patch | blob |
lyrics/02-lyricwiki.rb | [new file with mode: 0755] | patch | blob |
lyrics/03-leoslyrics.py | [new file with mode: 0755] | patch | blob |
lyrics/hd.sh | [deleted file] | patch | blob | history |
lyrics/leoslyrics.py | [deleted file] | patch | blob | history |
lyrics/lyricswiki.rb | [deleted file] | patch | blob | history |
diff --git a/Makefile.am b/Makefile.am
index 0c8de8a5a1b6ff32597071345039ce8cdfdc48d6..cb3149ff7bf15385a46fc9c4f1aab474b5d0ae9a 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
# lyrics plugins
#
-lyrics_plugins = hd.sh leoslyrics.py lyricswiki.rb
+lyrics_plugins = 01-hd.sh 02-lyricwiki.rb 03-leoslyrics.py
if ENABLE_LYRICS_SCREEN
diff --git a/lyrics/01-hd.sh b/lyrics/01-hd.sh
--- /dev/null
+++ b/lyrics/01-hd.sh
@@ -0,0 +1,24 @@
+#!/bin/sh -e
+#
+# (c) 2004-2008 The Music Player Daemon Project
+# http://www.musicpd.org/
+#
+# 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 of the License, or
+# (at your option) any later 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+#
+# Load lyrics from the user's home directory
+#
+
+cat ~/.lyrics/"$1 - $2".txt 2>/dev/null
diff --git a/lyrics/02-lyricwiki.rb b/lyrics/02-lyricwiki.rb
--- /dev/null
+++ b/lyrics/02-lyricwiki.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+#
+# (c) 2004-2008 The Music Player Daemon Project
+# http://www.musicpd.org/
+#
+# 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 of the License, or
+# (at your option) any later 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+#
+# Load lyrics from lyricwiki.org
+#
+
+require 'uri'
+require 'net/http'
+
+url = "http://lyricwiki.org/api.php" + \
+ "?artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}"
+response = Net::HTTP.get(URI.parse(url))
+
+exit(2) unless response =~ /<pre>\s*(.*?)\s*<\/pre>/im
+puts $1
diff --git a/lyrics/03-leoslyrics.py b/lyrics/03-leoslyrics.py
--- /dev/null
+++ b/lyrics/03-leoslyrics.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+#
+# (c) 2004-2008 The Music Player Daemon Project
+# http://www.musicpd.org/
+#
+# 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 of the License, or
+# (at your option) any later 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+#
+# Load lyrics from leoslyrics.com
+#
+
+from sys import argv, exit
+from urllib import urlencode, urlopen
+from xml.sax import make_parser, SAXException
+from xml.sax.handler import ContentHandler
+
+class SearchContentHandler(ContentHandler):
+ def __init__(self):
+ self.code = None
+ self.hid = None
+
+ def startElement(self, name, attrs):
+ if name == 'response':
+ self.code = int(attrs['code'])
+ elif name == 'result':
+ if self.hid is None or attrs['exactMatch'] == 'true':
+ self.hid = attrs['hid']
+
+def search(artist, title):
+ query = urlencode({'auth': 'ncmpc',
+ 'artist': artist,
+ 'songtitle': title})
+ url = "http://api.leoslyrics.com/api_search.php?" + query
+ f = urlopen(url)
+ handler = SearchContentHandler()
+ parser = make_parser()
+ parser.setContentHandler(handler)
+ parser.parse(f)
+ return handler.hid
+
+class LyricsContentHandler(ContentHandler):
+ def __init__(self):
+ self.code = None
+ self.is_text = False
+ self.text = None
+
+ def startElement(self, name, attrs):
+ if name == 'text':
+ self.text = ''
+ self.is_text = True
+ else:
+ self.is_text = False
+
+ def characters(self, chars):
+ if self.is_text:
+ self.text += chars
+
+def lyrics(hid):
+ query = urlencode({'auth': 'ncmpc',
+ 'hid': hid})
+ url = "http://api.leoslyrics.com/api_lyrics.php?" + query
+ f = urlopen(url)
+ handler = LyricsContentHandler()
+ parser = make_parser()
+ parser.setContentHandler(handler)
+ parser.parse(f)
+ return handler.text
+
+hid = search(argv[1], argv[2])
+if hid is None:
+ exit(2)
+print lyrics(hid).encode('utf-8')
diff --git a/lyrics/hd.sh b/lyrics/hd.sh
--- a/lyrics/hd.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh -e
-#
-# (c) 2004-2008 The Music Player Daemon Project
-# http://www.musicpd.org/
-#
-# 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 of the License, or
-# (at your option) any later 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-#
-# Load lyrics from the user's home directory
-#
-
-cat ~/.lyrics/"$1 - $2".txt 2>/dev/null
diff --git a/lyrics/leoslyrics.py b/lyrics/leoslyrics.py
--- a/lyrics/leoslyrics.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/python
-#
-# (c) 2004-2008 The Music Player Daemon Project
-# http://www.musicpd.org/
-#
-# 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 of the License, or
-# (at your option) any later 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-#
-# Load lyrics from leoslyrics.com
-#
-
-from sys import argv, exit
-from urllib import urlencode, urlopen
-from xml.sax import make_parser, SAXException
-from xml.sax.handler import ContentHandler
-
-class SearchContentHandler(ContentHandler):
- def __init__(self):
- self.code = None
- self.hid = None
-
- def startElement(self, name, attrs):
- if name == 'response':
- self.code = int(attrs['code'])
- elif name == 'result':
- if self.hid is None or attrs['exactMatch'] == 'true':
- self.hid = attrs['hid']
-
-def search(artist, title):
- query = urlencode({'auth': 'ncmpc',
- 'artist': artist,
- 'songtitle': title})
- url = "http://api.leoslyrics.com/api_search.php?" + query
- f = urlopen(url)
- handler = SearchContentHandler()
- parser = make_parser()
- parser.setContentHandler(handler)
- parser.parse(f)
- return handler.hid
-
-class LyricsContentHandler(ContentHandler):
- def __init__(self):
- self.code = None
- self.is_text = False
- self.text = None
-
- def startElement(self, name, attrs):
- if name == 'text':
- self.text = ''
- self.is_text = True
- else:
- self.is_text = False
-
- def characters(self, chars):
- if self.is_text:
- self.text += chars
-
-def lyrics(hid):
- query = urlencode({'auth': 'ncmpc',
- 'hid': hid})
- url = "http://api.leoslyrics.com/api_lyrics.php?" + query
- f = urlopen(url)
- handler = LyricsContentHandler()
- parser = make_parser()
- parser.setContentHandler(handler)
- parser.parse(f)
- return handler.text
-
-hid = search(argv[1], argv[2])
-if hid is None:
- exit(2)
-print lyrics(hid).encode('utf-8')
diff --git a/lyrics/lyricswiki.rb b/lyrics/lyricswiki.rb
--- a/lyrics/lyricswiki.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env ruby
-#
-# (c) 2004-2008 The Music Player Daemon Project
-# http://www.musicpd.org/
-#
-# 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 of the License, or
-# (at your option) any later 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-#
-# Load lyrics from lyricswiki.org
-#
-
-require 'uri'
-require 'net/http'
-
-url = "http://lyricwiki.org/api.php" + \
- "?artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}"
-response = Net::HTTP.get(URI.parse(url))
-
-exit(2) unless response =~ /<pre>\s*(.*?)\s*<\/pre>/im
-puts $1