Commit 1a1b30fe892afc0c9c7988c4c928c27521640d02

fix lyricwiki script to work again.

many thanks for the patch go to jkummerow!
src/scripts/lyrics_lyricwiki/main.js
(31 / 5)
  
2727Importer.loadQtBinding( "qt.xml" );
2828
2929xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><lyric artist=\"{artist}\" title=\"{title}\">{lyrics}</lyric>";
30newxml = "";
3031
32function onFinished2( response )
33{
34 try
35 {
36 if( response.length == 0 )
37 Amarok.Lyrics.showLyricsError( "Unable to contact server - no website returned" ); // TODO: this should be i18n able
38 else
39 {
40 doc2 = new QDomDocument();
41 doc2.setContent( response );
42 textboxtext = doc2.elementsByTagName( "textarea" ).at( 0 ).toElement().text();
43 lyr = /<lyrics>(.*)<\/lyrics>/.exec(textboxtext)[1];
44 //Amarok.debug( "matched: " + lyr );
45 newxml = newxml.replace( "{lyrics}", Amarok.Lyrics.escape( lyr ) );
46 Amarok.Lyrics.showLyrics( newxml );
47 }
48 }
49 catch( err )
50 {
51 Amarok.Lyrics.showLyricsError( "Could not retrieve lyrics: " + err );
52 Amarok.debug( "error: " + err );
53 }
54}
55
3156function onFinished( dat )
3257{
3358 try
6363 {
6464 doc = new QDomDocument();
6565 doc.setContent( dat );
66 parsedContent = doc.elementsByTagName( "lyrics" ).at( 0 ).toElement().text();
67 parsedContent = parsedContent.replace( "<lyrics>", "" ).replace( "</lyrics>", "" ); // some lyrics have 2 lyrics in them...wtf?
6866 newxml = xml.replace( "{artist}", Amarok.Lyrics.escape( doc.elementsByTagName( "artist" ).at( 0 ).toElement().text() ) );
6967 newxml = newxml.replace( "{title}", Amarok.Lyrics.escape( doc.elementsByTagName( "song" ).at( 0 ).toElement().text() ) );
70 newxml = newxml.replace( "{lyrics}", Amarok.Lyrics.escape( parsedContent ) );
71 //Amarok.debug( "showing lyrics:" + newxml );
72 Amarok.Lyrics.showLyrics( newxml );
68 Amarok.debug( "returned real lyricwiki URL: " + doc.elementsByTagName( "url" ).at( 0 ).toElement().text());
69 var url = decodeURI(doc.elementsByTagName( "url" ).at( 0 ).toElement().text());
70 url = url.replace( /lyricwiki\.org\//, "lyricwiki.org/index.php?action=edit&title=" );
71 var url2 = new QUrl(url);
72 Amarok.debug( "request-2 URL: " + url2.toString() );
73 new Downloader( url2, onFinished2 );
7374 }
7475 }
7576 catch( err )

Comments

Add a new comment:

Login or create an account to post a comment

Add your comment