Results 1 to 4 of 4

Thread: code to get Lyrics from lyricswiki

  1. #1
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    2,140

    Default code to get Lyrics from lyricswiki

    I've been playing with LuaSOAP to get song lyrics from lyricswiki from G5:

    1) download luasoap from http://www.keplerproject.org/luasoap/
    2) put soap.lua in luascript\soap (don't use http.lua)
    3) put the following code in luascript\soap\http.lua

    Code:
     
    require "socket.http"
    require "ltn12"
    require "soap.soap"
    soap.http = {}
    function soap.http.call (posturl, namespace, method, entries, headers)
      local bodydata = soap.soap.encode (namespace, method, entries, headers);
      local t = {}
      local r, httperror = socket.http.request(
        { url = posturl,
          sink = ltn12.sink.table(t),
          method = 'POST',
          headers = {
            ["content-length"] = string.len(bodydata),
            ["Content-type"] = "text/xml",
            ["SOAPAction"] = '"'..method..'"',
          },
          source = ltn12.source.string(bodydata)
        }
      )
      if (r==1) and (httperror==200) then
        return soap.soap.decode (table.concat(t))
      else
        return httperror
      end
    end

    then, to get the lyrics, do something like this :

    Code:
    require "soap.http"
    local ns, meth, ent = soap.http.call ("http://lyricwiki.org/server.php", 
       "LyricWiki", 
       "getSong", 
        {
          {  tag = "artist", "Ani Difranco"  },  
          {  tag = "song", "Gravel"  },
        })
     
    if ent ~= nil then
      for i, elem in ipairs (ent[1]) do 
        if elem.tag=="lyrics" then
          print (elem[1]); -- can also return "Not Found"
          break;
        end
      end
    end

    Marcel
    Last edited by mhwlng; August 22nd, 2007 at 05:44 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Sydney, Australia
    Posts
    787

    Default

    This also works with G4, thanks Marcel!!
    XP + G4 + Lua = :)

  3. #3
    Join Date
    May 2004
    Location
    Dallas, TX
    Posts
    1,125

    Default

    Marcel,

    Great find. Just added this tonight. Works great.
    Rick

    Girder 6.0 - Elk M1 Gold - JRMC 11.1 w/ M-Audio Delta 410 - NetRemote - BlueIris DVR
    Girder 6 Plugins - Elk M1/EZ8, Pushover Connector and more on the way.


    Visit My Showcase

  4. #4
    Join Date
    May 2004
    Posts
    20

    Default

    Can someone please repeat that in english?
    I\d really love autolyrics on the PPC, will this code do that? and where do I put it? Im using JRMC.
    Fall down seven times, stand up eight!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •