summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f783fe4)
raw | patch | inline | side by side (parent: f783fe4)
author | Andy Spencer <andy753421@gmail.com> | |
Tue, 24 Nov 2009 15:48:25 +0000 (15:48 +0000) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 24 Nov 2009 16:05:55 +0000 (17:05 +0100) |
Rename lyrics plugins to x0-plugin instead of 0x-plugin to allow additional
plugins to be added between provided plugins.
plugins to be added between provided plugins.
Makefile.am | patch | blob | history | |
lyrics/01-hd.sh | [deleted file] | patch | blob | history |
lyrics/02-lyricwiki.rb | [deleted file] | patch | blob | history |
lyrics/03-leoslyrics.py | [deleted file] | patch | blob | history |
lyrics/10-hd.sh | [new file with mode: 0755] | patch | blob |
lyrics/20-lyricwiki.rb | [new file with mode: 0755] | patch | blob |
lyrics/30-leoslyrics.py | [new file with mode: 0755] | patch | blob |
diff --git a/Makefile.am b/Makefile.am
index 531954593cc6c94c058c636e20976b391d9c5ab0..1fdb6167d9bffb251551efcc8d4ac9c5a2511275 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
# lyrics plugins
#
-lyrics_plugins = lyrics/01-hd.sh lyrics/02-lyricwiki.rb lyrics/03-leoslyrics.py
+lyrics_plugins = lyrics/10-hd.sh lyrics/20-lyricwiki.rb lyrics/30-leoslyrics.py
if ENABLE_LYRICS_SCREEN
diff --git a/lyrics/01-hd.sh b/lyrics/01-hd.sh
--- a/lyrics/01-hd.sh
+++ /dev/null
@@ -1,30 +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
-#
-
-FILENAME=~/.lyrics/"$1 - $2".txt
-
-if [ -e "$FILENAME" ] ; then
- exec cat "$FILENAME"
-else
- exit 69
-fi
diff --git a/lyrics/02-lyricwiki.rb b/lyrics/02-lyricwiki.rb
--- a/lyrics/02-lyricwiki.rb
+++ /dev/null
@@ -1,51 +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 lyrics.wikia.com, formerly lyricwiki.org
-#
-
-require 'uri'
-require 'net/http'
-require 'cgi'
-
-url = "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong" + \
- "&artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}"
-response = Net::HTTP.get(URI.parse(url))
-
-if not response =~ /<url>\s*(.*?)\s*<\/url>/im
- $stderr.puts "No URL in response!"
- exit(1)
-end
-
-url = $1
-exit(69) if url =~ /action=edit$/
-
-response = Net::HTTP.get(URI.parse(url))
-if not response =~ /<div class='lyricbox'>\s*(.*?)\s*<!--/im
- $stderr.puts "No <div class='lyricbox'> in lyrics page!\n"
- exit(1)
-end
-
-if not $1 =~ /^.*<\/div>(.*?)$/im
- $stderr.puts "Couldn't remove leading XML tags in lyricbox!\n"
- exit(1)
-end
-
-puts CGI::unescapeHTML($1.gsub(/<br \/>/, "\n"))
diff --git a/lyrics/03-leoslyrics.py b/lyrics/03-leoslyrics.py
--- a/lyrics/03-leoslyrics.py
+++ /dev/null
@@ -1,92 +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, stderr
-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)
- try:
- parser.parse(f)
- except SAXException:
- stderr.write("Failed to parse the search result!\n")
- exit(1)
- 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)
- try:
- parser.parse(f)
- except SAXException:
- stderr.write("Failed to parse the lyrics!\n")
- exit(1)
- return handler.text
-
-hid = search(argv[1], argv[2])
-if hid is None:
- exit(69)
-print lyrics(hid).encode('utf-8').rstrip()
diff --git a/lyrics/10-hd.sh b/lyrics/10-hd.sh
--- /dev/null
+++ b/lyrics/10-hd.sh
@@ -0,0 +1,30 @@
+#!/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
+#
+
+FILENAME=~/.lyrics/"$1 - $2".txt
+
+if [ -e "$FILENAME" ] ; then
+ exec cat "$FILENAME"
+else
+ exit 69
+fi
diff --git a/lyrics/20-lyricwiki.rb b/lyrics/20-lyricwiki.rb
--- /dev/null
+++ b/lyrics/20-lyricwiki.rb
@@ -0,0 +1,51 @@
+#!/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 lyrics.wikia.com, formerly lyricwiki.org
+#
+
+require 'uri'
+require 'net/http'
+require 'cgi'
+
+url = "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong" + \
+ "&artist=#{URI.escape(ARGV[0])}&song=#{URI.escape(ARGV[1])}"
+response = Net::HTTP.get(URI.parse(url))
+
+if not response =~ /<url>\s*(.*?)\s*<\/url>/im
+ $stderr.puts "No URL in response!"
+ exit(1)
+end
+
+url = $1
+exit(69) if url =~ /action=edit$/
+
+response = Net::HTTP.get(URI.parse(url))
+if not response =~ /<div class='lyricbox'>\s*(.*?)\s*<!--/im
+ $stderr.puts "No <div class='lyricbox'> in lyrics page!\n"
+ exit(1)
+end
+
+if not $1 =~ /^.*<\/div>(.*?)$/im
+ $stderr.puts "Couldn't remove leading XML tags in lyricbox!\n"
+ exit(1)
+end
+
+puts CGI::unescapeHTML($1.gsub(/<br \/>/, "\n"))
diff --git a/lyrics/30-leoslyrics.py b/lyrics/30-leoslyrics.py
--- /dev/null
+++ b/lyrics/30-leoslyrics.py
@@ -0,0 +1,92 @@
+#!/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, stderr
+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)
+ try:
+ parser.parse(f)
+ except SAXException:
+ stderr.write("Failed to parse the search result!\n")
+ exit(1)
+ 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)
+ try:
+ parser.parse(f)
+ except SAXException:
+ stderr.write("Failed to parse the lyrics!\n")
+ exit(1)
+ return handler.text
+
+hid = search(argv[1], argv[2])
+if hid is None:
+ exit(69)
+print lyrics(hid).encode('utf-8').rstrip()