Jump to content

Recommended Posts

Posted (edited)

This is a lyrics finder ported from my other project.

It's a straightforward script. You enter the song name and artist, and it retrieves lyrics and album art.

Screenshot:

Posted Image

Posted Image

Posted Image

Source:

Download ( Updated Nov 21, 2010 )

Lyrics Finder.au3

Issues:

iexplore.exe doesn't close properly when exiting Lyric Finder.

Comments? Criticisms? Voice your opinions!

Edited by Foxhound
Posted

Sorry ;)

I was unsure whether I should comment that out or not. If you use the tray tip menu to pause/exit the script, the IE Object stays open and plays music after you closed the script.

A easy solution is to close all windows who have api.chartlyrics.com in the title ! it's more proper Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

A easy solution is to close all windows who have api.chartlyrics.com in the title ! it's more proper Posted Image

Yeah but the browser window doesn't show a title. The site just returns an XML file

<GetLyricResult>
<TrackId>0</TrackId>
<LyricChecksum>bbef9b7274a64fef61ce689f8c7c6647</LyricChecksum>
<LyricId>232085</LyricId>
<LyricSong>Dream on Little Dreamer</LyricSong>
<LyricArtist>Perry Como</LyricArtist>
−
<LyricUrl>
http://www.chartlyrics.com/S0eCAR2K0EadD-bfNTM16g/Dream+on+Little+Dreamer.aspx
</LyricUrl>
−
<LyricCovertArtUrl>
http://ec2.images-amazon.com/images/P/B000024FAG.03.MZZZZZZZ.jpg
</LyricCovertArtUrl>
<LyricRank>4</LyricRank>
−
<LyricCorrectUrl>
http://www.chartlyrics.com/app/correct.aspx?lid=MgAzADIAMAA4ADUA
</LyricCorrectUrl>
−
<Lyric>
Dream on little dreamer dreamer on
Dream on little dreamer dreamer on
I get a heart full of butterflies, lookin' into your dreamy eyes
Dream on ( Dream on! ) little dreamer dreamer on!

Dream on little dreamer dreamer on
Dream on little dreamer dreamer on
Dream about a love so true, dream about how I love you
Dream on ( Dream on! ) little dreamer dreamer on!

You know I love you,
I love you, I need you so bad
Each night I realize,
when you close your dreamy eyes

Dream on little dreamer dreamer on
Dream on little dreamer dreamer on
Dream about a love so fine, sweet as apple berry wine
Dream on ( Dream on! ) little dreamer dreamer on!

. . . little dreamer dreamer on!
</Lyric>
</GetLyricResult>
Posted (edited)

For example i ask for white horse of taylor swift

your script create an hidden window of ie with the title :

"http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=taylor swift&song=white horse - Windows Internet Explorer"

So there is well "api.chartlyrics.com" in the title ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted (edited)

This may work like this and only for hidden window ! Posted Image

_CloseWindowWithString ( 'api.chartlyrics.com' )

Func _CloseWindowWithString ( $_String )
    $_WinList = WinList ( )
    For $_I = 1 To $_WinList[0][0]
        If StringInStr ( $_WinList[$_I][0], $_String ) <> 0 And Not BitAnd ( WinGetState ( $_WinList[$_I][1] ), 2 ) Then WinClose ( $_WinList[$_I][1] )
    Next
EndFunc ;==> _CloseWindowWithString ( )
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

  • 2 months later...
Posted (edited)

This tool is cool.

Thanks

No problem. Thanks for bumping this up cause now I finally got around to updating it. I worked out the kinks so the IE Obj isn't used.

Try it !

OnAutoItExitRegister("_exit")
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <INet.au3>

Global $lyricData[2],$lyricOBJ

$Form1 = GUICreate("Lyric Finder", 625, 443, 294, 186)
$Edit1 = GUICtrlCreateEdit("", 272, 96, 337, 289,BitOR($ES_CENTER,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetFont(-1, 13, 800, 0, "vernada")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetLimit(-1, 35)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH)
GUICtrlSetData(-1, "")
$Pic1 = GUICtrlCreatePic("", 8, 96, 249, 289, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label2 = GUICtrlCreateLabel("Song name:", 28, 32, 61, 17)
$Label3 = GUICtrlCreateLabel("Artist name:", 28, 56, 56, 17)
$songInput = GUICtrlCreateInput("", 88, 32, 249, 21)
$ArtistInput = GUICtrlCreateInput("", 88, 56, 249, 21)
$Button1 = GUICtrlCreateButton("Search", 344, 24, 105, 57, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Exit", 464, 24, 105, 57, $WS_GROUP)
$Label4 = GUICtrlCreateLabel("By Foxhound. Lyric data provided through Chart Lyrics API. ", 64, 416, 400, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
Case $Button2
    Exit
Case $Button1
    ;array 0 = lyrics
    ;array 1 = Album Art
    $a= GUICtrlRead($ArtistInput)
    $s= GUICtrlRead($songInput)
    $rawData = getLyrics($a,$s)
FileDelete(@TempDir&"\CoverData.jpg")
InetGet($rawData[1],@TempDir&"\coverData.jpg")
GUICtrlSetData($Edit1,$rawData[0])
GUICtrlSetImage($Pic1,@TempDir&"\coverData.jpg")
EndSwitch
WEnd

Func getLyrics($a="",$s="")

$lyricURL = "http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist="&$a&"&song="&$s&"- CHART LYRICS API"
$data = _INetGetSource($lyricURL)
$lyricData[0] = _StringBetween2($data,"<Lyric>","</Lyric>")
$lyricData[1] = _StringBetween2($data,"<LyricCovertArtUrl>","</LyricCovertArtUrl>")
if StringLen($lyricData[0]) == 0 Then $lyricData[0] = "Lyrics not found. "
Return($lyricData)
EndFunc

Func _StringBetween2($s, $from, $to)
    ;This helpful function taken from: http://www.autoitscript.com/forum/index.php?sho wtopic=89554
    $x = StringInStr($s, $from) + StringLen($from)
    $y = StringInStr(StringTrimLeft($s, $x), $to)
    Return StringMid($s, $x, $y)
EndFunc

Func _exit()
    FileDelete(@TempDir&"\CoverData.jpg")
    Exit
EndFunc
Edited by Foxhound

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...