Kodi Community Forum
[RELEASE] CU Lyrics (Script) Addon - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Lyrics Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=146)
+---- Thread: [RELEASE] CU Lyrics (Script) Addon (/showthread.php?tid=62853)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26


- ronie - 2010-01-05

Amet Wrote:debug log?

how many do you want ? ;-)

issues observed with 0.7.5 so far
- while the script is searching for lyrics, it displays 'choose your song from the list'
- can't find lyrics for several songs that used to work with previous versions of the script.
- 50% of the time, i can't close the lyrics window !! help !!!

i think you've made some cu changes in the latest release. ;-p



edit:
here's a debug log

the song in question is Bruce Springsteen - Born To Run
it's trying (and fails) to fetch this url:
http://lyricwiki.org/index.php?title=Bruce%20Springsteen%3ABorn%20to%20Run&action=edit
though the lyrics are available:
http://lyrics.wikia.com/index.php?title=Bruce_Springsteen:Born_To_Run

this is really a big issue to me, cause without the lyrics i can't sing-along Sad



another edit:
since it's no fun listening to music this way i might as well make some screens for you

can't close window and it doesn't auto close at the end of the song:
Image

speaks for itself, no further comment needed:
Image


- paco - 2010-01-05

ronie Wrote:the song in question is Bruce Springsteen - Born To Run
it's trying (and fails) to fetch this url:
http://lyricwiki.org/index.php?title=Bruce%20Springsteen%3ABorn%20to%20Run&action=edit
though the lyrics are available:
http://lyrics.wikia.com/index.php?title=Bruce_Springsteen:Born_To_Run

this is really a big issue to me, cause without the lyrics i can't sing-along Sad

This script REQUIRES correct capitalization to retrieve lyrics. 'Born to Run' will not work, but if you edit your tag to be 'Born To Run' it will.

Initially Amet had the script capitalizing everything but it would also capitalize anything using punctuation (Can't became Can'T). That caused more songs to fail so the script was changed to be very dependent on the user having their songs 100% accurately named. I had to fix a few of my own songs that wouldn't work.

If you're not familiar with Tag editing, download MP3Tag.


- ZorMonkey - 2010-01-05

Couple things. I'm a python novice, but I think this is right. Huh

In gui.py, this looks backwards:

Code:
if (artist.find( "\'" )) or (song.find( "\'", )):
            quote = False
        else:
            quote = True

it should probably be

Code:
if (artist.find( "\'" )) or (song.find( "\'")):
            quote = True
        else:
            quote = False

Right?

But even better, I had better luck ignoring that bit and instead modifying the lyricwiki_format function in the LyricsFetcher class to this:
Code:
def lyricwiki_format(self, text):
        titleCase =lambda value: re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())
        return urllib.quote(str(unicode(titleCase(text))))

I got that lambda magic from http://bugs.python.org/issue7008. Its not perfect, but it catches a lot. I also modified the get_lyrics_thread function to only use lyricwiki_format, and also hopefully improved detecting failed searches. Here's my full function:

Code:
def get_lyrics_thread(self, artist, title,quote):
        try:
            url = "http://lyricwiki.org/index.php?title=%s:%s&fmt=js" % (self.lyricwiki_format(artist), self.lyricwiki_format(title))
            
            song_search = urllib.urlopen(url).read()
            if song_search.find("Click here to start this page!") >= 0:
                error = "Lyrics not found"
                return error
            
            song_title = song_search.split("<title>")[1].split("</title>")[0]
            print song_title
            song_clean_title = self.unescape(song_title.replace(" Lyrics - LyricWiki - Music lyrics from songs and albums",""))
            print "Title:[" + song_clean_title+"]"
            lyricpage = urllib.urlopen("http://lyricwiki.org/index.php?title=%s&action=edit" % (urllib.quote(song_clean_title),)).read()
            print ("http://lyricwiki.org/index.php?title=%s&action=edit" % (urllib.quote(song_clean_title),))
            
            content = re.split("<textarea[^>]*>", lyricpage)[1].split("</textarea>")[0]
            if content.startswith("#REDIRECT [["):
                addr = "http://lyricwiki.org/index.php?title=%s&action=edit" % urllib.quote(content.split("[[")[1].split("]]")[0])
                    content = urllib.urlopen(addr).read()
            try:
                lyrics = content.split("&lt;lyrics&gt;")[1].split("&lt;/lyrics&gt;")[0]
            except:
                lyrics = content.split("&lt;lyric&gt;")[1].split("&lt;/lyric&gt;")[0]
            return lyrics
        except:
            error = "Fetching lyrics failed"
            return error

It hasn't been tested very rigorously yet, but it's now finding lyrics that it wasnt before. Mostly it seems better because it's now title casing everything, so simple cases like "XTC:River of Orchids" is working.


- ronie - 2010-01-05

paco Wrote:This script REQUIRES correct capitalization to retrieve lyrics. 'Born to Run' will not work, but if you edit your tag to be 'Born To Run' it will.

thanx paco, i would never had though of that.
all my tags should be properly capitalized (i always make sure they are), but i guess this one slipped through somehow.


cheers.


- amet - 2010-01-05

I have just reverted the script back to 0.7.4 code, Please use SVN repo installer to install it. Sorry for the inconvenience Sad


- amet - 2010-01-05

ronie Wrote:how many do you want ? ;-)

issues observed with 0.7.5 so far
- while the script is searching for lyrics, it displays 'choose your song from the list'
- can't find lyrics for several songs that used to work with previous versions of the script.
- 50% of the time, i can't close the lyrics window !! help !!!

i think you've made some cu changes in the latest release. ;-p



edit:
here's a debug log

the song in question is Bruce Springsteen - Born To Run
it's trying (and fails) to fetch this url:
http://lyricwiki.org/index.php?title=Bruce%20Springsteen%3ABorn%20to%20Run&action=edit
though the lyrics are available:
http://lyrics.wikia.com/index.php?title=Bruce_Springsteen:Born_To_Run

this is really a big issue to me, cause without the lyrics i can't sing-along Sad



another edit:
since it's no fun listening to music this way i might as well make some screens for you

can't close window and it doesn't auto close at the end of the song:
Image

speaks for itself, no further comment needed:
Image

Sorry for the screw up in 0.7.6, I had it working fine on my side. Dont have too much time to play with it now so I am just reverting the code to previous working version.

When I get some time I will try to fix up all the issues.

Zeljko


- amet - 2010-01-05

ZorMonkey Wrote:Couple things. I'm a python novice, but I think this is right. Huh

In gui.py, this looks backwards:

Code:
if (artist.find( "\'" )) or (song.find( "\'", )):
            quote = False
        else:
            quote = True

it should probably be

Code:
if (artist.find( "\'" )) or (song.find( "\'")):
            quote = True
        else:
            quote = False

Right?

No, if we find " ' " in a song or artist name we dont want it to be capitalized but still urllib.quote it.
Code:
def lyricwiki_quote(self, text):
        return urllib.quote(str(unicode(text)))

admittedly the naming could have been better Smile

ZorMonkey Wrote:But even better, I had better luck ignoring that bit and instead modifying the lyricwiki_format function in the LyricsFetcher class to this:
Code:
def lyricwiki_format(self, text):
        titleCase =lambda value: re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())
        return urllib.quote(str(unicode(titleCase(text))))

I got that lambda magic from http://bugs.python.org/issue7008. Its not perfect, but it catches a lot. I also modified the get_lyrics_thread function to only use lyricwiki_format, and also hopefully improved detecting failed searches. Here's my full function:

Code:
def get_lyrics_thread(self, artist, title,quote):
        try:
            url = "http://lyricwiki.org/index.php?title=%s:%s&fmt=js" % (self.lyricwiki_format(artist), self.lyricwiki_format(title))
            
            song_search = urllib.urlopen(url).read()
            if song_search.find("Click here to start this page!") >= 0:
                error = "Lyrics not found"
                return error
            
            song_title = song_search.split("<title>")[1].split("</title>")[0]
            print song_title
            song_clean_title = self.unescape(song_title.replace(" Lyrics - LyricWiki - Music lyrics from songs and albums",""))
            print "Title:[" + song_clean_title+"]"
            lyricpage = urllib.urlopen("http://lyricwiki.org/index.php?title=%s&action=edit" % (urllib.quote(song_clean_title),)).read()
            print ("http://lyricwiki.org/index.php?title=%s&action=edit" % (urllib.quote(song_clean_title),))
            
            content = re.split("<textarea[^>]*>", lyricpage)[1].split("</textarea>")[0]
            if content.startswith("#REDIRECT [["):
                addr = "http://lyricwiki.org/index.php?title=%s&action=edit" % urllib.quote(content.split("[[")[1].split("]]")[0])
                    content = urllib.urlopen(addr).read()
            try:
                lyrics = content.split("&lt;lyrics&gt;")[1].split("&lt;/lyrics&gt;")[0]
            except:
                lyrics = content.split("&lt;lyric&gt;")[1].split("&lt;/lyric&gt;")[0]
            return lyrics
        except:
            error = "Fetching lyrics failed"
            return error

It hasn't been tested very rigorously yet, but it's now finding lyrics that it wasnt before. Mostly it seems better because it's now title casing everything, so simple cases like "XTC:River of Orchids" is working.

Thanks for the code, I will try to add it to the script as soon as possible.

Zeljko


- ronie - 2010-01-05

Amet Wrote:Sorry for the screw up in 0.7.6, I had it working fine on my side. Dont have too much time to play with it now so I am just reverting the code to previous working version.

When I get some time I will try to fix up all the issues.

Zeljko

no need to be sorry, i appreciate all the time you spend in getting the best out of this script.
you know where to find me if you need someone to do some more testing. ;-)


- amet - 2010-01-05

ronie Wrote:you know where to find me if you need someone to do some more testing. ;-)

under the camper fixing the suspension bits? Smile

I'll try to do something over the weekend and you can do the beta testing, but you need to donate first Smile


- ZorMonkey - 2010-01-05

Quote:
Quote:Originally Posted by ZorMonkey View Post
Couple things. I'm a python novice, but I think this is right.

In gui.py, this looks backwards:

Code:
<snip>
Right?
No, if we find " ' " in a song or artist name we dont want it to be capitalized but still urllib.quote it.

Code:
def lyricwiki_quote(self, text):
        return urllib.quote(str(unicode(text)))

admittedly the naming could have been better

Looking at it again, yeah, that makes sense (although, yeah, the naming could be better Smile ) But somehow "fixing" that made it work better I thought. Ah well, I was looking at it too late at night, so who knows what I was doing. Smile


- amet - 2010-01-05

ZorMonkey Wrote:Looking at it again, yeah, that makes sense (although, yeah, the naming could be better Smile ) But somehow "fixing" that made it work better I thought. Ah well, I was looking at it too late at night, so who knows what I was doing. Smile

but all that will go away when your code is implemented, thanks again Smile


- dny238 - 2010-01-06

Amet Wrote:but all that will go away when your code is implemented, thanks again Smile

Amet, where is the latest code? In the SVN or did I see something about private releases of the beta versions?


- amet - 2010-01-06

dny238 Wrote:Amet, where is the latest code? In the SVN or did I see something about private releases of the beta versions?

no private beta releases, its just the standing joke I have with ronie. Smile

as for the code, it will be added in the next release, if I have some time over the weekend I will try to do it then.

SVN repo installer has the latest version.

Zeljko


- ronie - 2010-01-06

I'm having some issues with last nights beta (v0.7.7b2)
Fetching of lyrics that are not properly capitalized is working fine now,
but the auto-sync is still a bit out-of-tune.

Loving all the new features though, especially the pause, resume and rewind controls are very nice. :-)

I still have to test it with my music videos, but i doubt i'll run into any new issues there.


cheers!


- dny238 - 2010-01-06

Amet Wrote:no private beta releases, its just the standing joke I have with ronie. Smile

as for the code, it will be added in the next release, if I have some time over the weekend I will try to do it then.

SVN repo installer has the latest version.

Zeljko

I found a setting to auto scroll, assuming that would cause the lyrics to roll during the duration of the song. But picking it doesn't have any apparent effect that I can see.

Also, having the capitalization problem I guess.
Another One Bites the Dust doesn't work, but Another One Bites The Dust does.
http://lyrics.wikia.com/index.php?title=Queen%3AAnother%20One%20Bites%20The%20Dust&action=edit

seems like a few keywords like 'a', 'the', 'of' could be CAPPED and tried a 2nd time to increase the success rate, or you could try CAPPING the entire title if the normal version fails to find lyrics. Have these approaches been discussed/tried already?

Is there a way to paypal a contribution for all your hardwork?
Rob