You are not logged in.
Pages: 1
Hey,
maybe some of you have noticed that due to some restrictions imposed by people who have too much money sonata can no longer directly fetch lyrics from lyricswiki.org.
I found a patch to that, so that sonata fetches the lyrics not through the api but directly from the mainpage:
Open info.py in /usr/lib/python2.6/site-packages/sonata/ and go to line 420.
Change
lyrics = self.lyricServer.getSong(artist=self.lyricwiki_format(search_artist), song=self.lyricwiki_format(search_title))['return']["lyrics"]
to
lyrics = urllib.urlopen("http://lyricwiki.org/"+self.lyricwiki_format(search_artist)+":"+self.lyricwiki_format(search_title)).read().split("<div class='lyricbox' >")[1].split("<p><!--")[0].replace('<br />',"\n")
that's it.
originally found here: http://gist.github.com/161130, i just fixed a little bug that would show an unwanted html tag at the bottom.
Offline
Wow, I went to the forums to start a thread about this and you already posted the fix. Arch linux really is cutting edge. Thank you.
Last edited by 2_Thumbs_Up (2009-08-04 19:06:45)
Offline
I was bored so I modified the PKGBUILD created patch for sonata 1.6.2. Its the first time I've ever done this so I hope I got it right, but it seems to work here.
# $Id: PKGBUILD 33676 2009-04-04 15:52:37Z alexanderf $
# Maintainer: Alexander Fehr <pizzapunk gmail com>
# Contributor: William Rea <sillywilly@gmail.com>
pkgname=sonata
pkgver=1.6.2
pkgrel=1
pkgdesc="Elegant GTK+ music client for MPD"
arch=('i686' 'x86_64')
url="http://sonata.berlios.de/"
license=('GPL3')
depends=('pygtk' 'python-mpd')
optdepends=('gnome-python-extras: Enhanced system tray support'
'tagpy: Metadata editing support'
'zsi: Lyrics fetching support'
'dbus-python: Various extra functionality (e.g. multimedia keys support)')
source=(http://download2.berlios.de/sonata/sonata-$pkgver.tar.bz2
lyrics.patch)
md5sums=('f2bca0855fd2eb3d199f62fbd88af62f'
'95ee98ad2950cffab2b3c16e3da77d1c')
build() {
cd "$srcdir/sonata-$pkgver"
patch -p1 -i "${srcdir}/lyrics.patch" || return 1
python setup.py install --prefix=/usr --root="$pkgdir" || return 1
}
diff -crB sonata-1.6.2/sonata/info.py sonata-1.6.2-new/sonata/info.py
*** sonata-1.6.2/sonata/info.py 2009-04-02 04:57:18.000000000 +0100
--- sonata-1.6.2-new/sonata/info.py 2009-08-04 21:35:38.000000000 +0100
***************
*** 419,425 ****
try:
timeout = socketgettimeout()
socketsettimeout(consts.LYRIC_TIMEOUT)
! lyrics = self.lyricServer.getSong(artist=self.lyricwiki_format(search_artist), song=self.lyricwiki_format(search_title))['return']["lyrics"]
if lyrics.lower() != "not found":
lyrics = misc.unescape_html(lyrics)
lyrics = misc.wiki_to_html(lyrics)
--- 419,425 ----
try:
timeout = socketgettimeout()
socketsettimeout(consts.LYRIC_TIMEOUT)
! lyrics = urllib.urlopen("http://lyricwiki.org/"+self.lyricwiki_format(search_artist)+":"+self.lyricwiki_format(search_title)).read().split("<div class='lyricbox' >")[1].split("<p><!--")[0].replace('<br />',"\n")
if lyrics.lower() != "not found":
lyrics = misc.unescape_html(lyrics)
lyrics = misc.wiki_to_html(lyrics)
Offline
No need to make a patch, methinks. Sed will work just fine in here.
Offline
Offline
Thank you! This is much appreciated.
Offline
Thanks a lot.
Saved my day.
The Wheel weaves as the Wheel wills, and we are only the thread of the Pattern."
—Moiraine Damodred
Offline
Thanks.
Arch64 | some tiling wm
Offline
unfortunately this doesn't work for me
appears: fetching lyrics failed
Offline
It doesn't work for me, either.
I get "Fetching lyrics failed" when I start sonata with a song already playing; then I get "Couldn't connect to LyricWiki" when I swicth songs.
I apologize for not taking the time to try to fix this myself :-), but must finish homework.
BTW: using sonata 2.6.2-1 which is the latest in the arch extra repo.
Last edited by mollison (2009-09-16 06:48:52)
Offline
Just quick fix to get it worked. It is worthy a patch and more elaboration, but.... you know :E.
- if self.lyricServer is None:
+ if False:
- lyrics = urllib.urlopen("http://lyricwiki.org/"+self.lyricwiki_format(search_artist)+":"+self.lyricwiki_format(search_title)).read().split("<div class='lyricbox' >")[1].split("<p><!--")[0].replace('<br />',"\n")
+ lyrics = urllib.urlopen("http://lyricwiki.org/"+self.lyricwiki_format(search_artist)+":"+self.lyricwiki_format(search_title)).read().split("<div class='lyricbox' >")[1].split("<!--")[0].replace('<br />',"\n")
- lyrics = lyrics.encode("ISO-8859-1")
+ lyrics = lyrics.encode("utf-8")
- lyrics = _("Fetching lyrics failed")
+ lyrics = _(str(sys.exc_info()[1]) + "\nFetching lyrics failed")
Last edited by hrabi (2009-09-17 09:28:03)
Offline
That works :-)
Offline
I just wanted to thank hrabi for this, it fixed my problem right up
Offline
Stupid question: how to apply this patch?
Edit: ok I patched it manually
Last edited by silenc3r (2009-09-22 11:05:37)
Offline
Pages: 1