summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMartyn Russell <martyn@lanedo.com>2013-03-15 10:10:39 +0000
committerMartyn Russell <martyn@lanedo.com>2013-03-15 10:10:39 +0000
commit5aeae0502ebd0065068fdef652a5da041174295a (patch)
treeb610b3086dc32fd66b54e599f18734afa997cc20 /utils
parentb2c924846e0bb864bdf5aee43d3c997a46f98463 (diff)
downloadtracker-5aeae0502ebd0065068fdef652a5da041174295a.tar.gz
utils/lyrics: Removed
This was unmaintained and unused. See original discussion here: https://mail.gnome.org/archives/tracker-list/2013-March/msg00007.html
Diffstat (limited to 'utils')
-rw-r--r--utils/Makefile.am1
-rw-r--r--utils/lyrics/Makefile.am6
-rwxr-xr-xutils/lyrics/lyrics.py89
3 files changed, 0 insertions, 96 deletions
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 83f5216c1..4a33c0019 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -2,7 +2,6 @@ include $(top_srcdir)/Makefile.decl
SUBDIRS = \
gtk-sparql \
- lyrics \
services \
data-generators \
mtp \
diff --git a/utils/lyrics/Makefile.am b/utils/lyrics/Makefile.am
deleted file mode 100644
index abd3a5c20..000000000
--- a/utils/lyrics/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-include $(top_srcdir)/Makefile.decl
-
-EXTRA_DIST = \
- lyrics.py
-
-CLEANFILES = *.pyc
diff --git a/utils/lyrics/lyrics.py b/utils/lyrics/lyrics.py
deleted file mode 100755
index 5fa7ccb7e..000000000
--- a/utils/lyrics/lyrics.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#
-# Copyright (C) 2008, Nokia <ivan.frade@nokia.com>
-#
-# 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., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import os
-import urllib
-import sys
-import re
-from xml.dom import minidom
-
-LYRIC_TITLE_STRIP = ["\(live[^\)]*\)", "\(acoustic[^\)]*\)", "\([^\)]*mix\)", "\([^\)]*version\)", "\([^\)]*edit\)", "\(feat[^\)]*\)"]
-LYRIC_TITLE_REPLACE = [("/", "-"), (" & ", " and ")]
-LYRIC_ARTIST_REPLACE = [("/", "-"), (" & ", " and ")]
-
-def get_lyrics(artist, title):
- # replace ampersands and the like
- for exp in LYRIC_ARTIST_REPLACE:
- p = re.compile (exp[0])
- artist = p.sub(exp[1], artist)
- for exp in LYRIC_TITLE_REPLACE:
- p = re.compile (exp[0])
- title = p.sub(exp[1], title)
-
- # strip things like "(live at Somewhere)", "(accoustic)", etc
- for exp in LYRIC_TITLE_STRIP:
- p = re.compile (exp)
- title = p.sub ('', title)
-
- # compress spaces
- title = title.strip()
- artist = artist.strip()
-
- url = "http://api.leoslyrics.com/api_search.php?auth=Rhythmbox&artist=%s&songtitle=%s" % (
- urllib.quote(artist.encode('utf-8')),
- urllib.quote(title.encode('utf-8')))
-
- data = urllib.urlopen(url).read()
- xmldoc = minidom.parseString(data).documentElement
-
- result_code = xmldoc.getElementsByTagName('response')[0].getAttribute('code')
- if result_code != '0':
- xmldoc.unlink()
- return
-
- matches = xmldoc.getElementsByTagName('result')[:10]
- hids = map(lambda x: x.getAttribute('hid'), matches)
- if len(hids) == 0:
- self.callback("Unable to find lyrics for this track.")
- xmldoc.unlink()
- return
-
- xmldoc.unlink()
-
- url = "http://api.leoslyrics.com/api_lyrics.php?auth=Rhythmbox&hid=%s" % (urllib.quote(hids[0].encode('utf-8')))
- data = urllib.urlopen(url).read()
- xmldoc = minidom.parseString(data).documentElement
-
- text = xmldoc.getElementsByTagName('title')[0].firstChild.nodeValue
- text += ' - ' + xmldoc.getElementsByTagName('artist')[0].getElementsByTagName('name')[0].firstChild.nodeValue + '\n\n'
- text += xmldoc.getElementsByTagName('text')[0].firstChild.nodeValue
-
- xmldoc.unlink()
- return text
-
-
-if __name__ == '__main__':
- if len(sys.argv) != 4:
- print 'usage: %s artist title output' % (sys.argv[0])
- sys.exit(1)
-
- f = open(sys.argv[3], 'w')
- lyrics = get_lyrics(sys.argv[1], sys.argv[2])
- f.write(lyrics.encode('utf-8'))
- f.close()