You are not logged in.

#1 2009-08-04 13:03:12

calle
Member
From: Germany
Registered: 2008-11-14
Posts: 45

Sonata Lyrics Fix

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

#2 2009-08-04 19:06:33

2_Thumbs_Up
Member
Registered: 2009-05-09
Posts: 22

Re: Sonata Lyrics Fix

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

#3 2009-08-04 20:55:20

Bob_Sheep
Member
From: Scotland
Registered: 2008-10-06
Posts: 27

Re: Sonata Lyrics Fix

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

#4 2009-08-04 21:33:53

tadzik
Member
From: &tadzik
Registered: 2009-07-17
Posts: 91

Re: Sonata Lyrics Fix

No need to make a patch, methinks. Sed will work just fine in here.

Offline

#5 2009-08-05 07:53:35

jelly
Administrator
From: /dev/null
Registered: 2008-06-10
Posts: 714

Re: Sonata Lyrics Fix

for much code a patch is nice  , for one line sed is fine .

Offline

#6 2009-08-06 00:19:08

cookies!
Member
Registered: 2009-07-21
Posts: 1

Re: Sonata Lyrics Fix

Thank you!  This is much appreciated.

Offline

#7 2009-08-15 02:28:08

Isengrin
Member
Registered: 2008-08-07
Posts: 166

Re: Sonata Lyrics Fix

Thanks a lot. smile
Saved my day.


The Wheel weaves as the Wheel wills, and we are only the thread of the Pattern."
—Moiraine Damodred

Offline

#8 2009-08-15 08:38:19

Nuz
Member
From: Latvia
Registered: 2008-11-29
Posts: 50

Re: Sonata Lyrics Fix

Thanks.


Arch64 | some tiling wm

Offline

#9 2009-09-02 11:14:38

xsoul
Member
Registered: 2009-08-18
Posts: 9

Re: Sonata Lyrics Fix

unfortunately this doesn't work for me
appears: fetching lyrics failed

Offline

#10 2009-09-16 06:47:00

mollison
Member
Registered: 2009-01-07
Posts: 15

Re: Sonata Lyrics Fix

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

#11 2009-09-17 09:26:17

hrabi
Member
Registered: 2006-11-02
Posts: 7

Re: Sonata Lyrics Fix

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

#12 2009-09-17 15:18:31

mollison
Member
Registered: 2009-01-07
Posts: 15

Re: Sonata Lyrics Fix

That works :-)

Offline

#13 2009-09-20 08:54:42

sputter
Member
From: NM
Registered: 2005-03-04
Posts: 23
Website

Re: Sonata Lyrics Fix

I just wanted to thank hrabi for this, it fixed my problem right up

Offline

#14 2009-09-22 10:56:45

silenc3r
Member
From: Poland
Registered: 2009-08-29
Posts: 149

Re: Sonata Lyrics Fix

Stupid question: how to apply this patch?

Edit: ok I patched it manually

Last edited by silenc3r (2009-09-22 11:05:37)

Offline

Board footer

Powered by FluxBB