AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Music Lyric Grabber

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
wontstoptalking



Joined: 14 Dec 2008
Posts: 42

PostPosted: Sat Dec 20, 2008 8:56 pm    Post subject: Music Lyric Grabber Reply with quote

Even more useful than you might think.


Partial credit goes to me (I really only came up with the idea and got half way there with it) but the most credit goes to the wonderful helpers at the AHK IRC chat, specifically Skwire, who came up with the final gui layout of the current version; and ahklerner1, who told me how to make sure the input isn't caps sensitive Razz

Lyric Grabber grabs music lyrics from the Lyric Wiki site, displaying it in a simple manner.

Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
;;;;;;;;start code;;;;;;;;;
#persistent
#singleinstance
#NoTrayIcon
Gui, Margin, 10, 10
Gui, add, text  , xm     ym    w30  h20  Right 0x200            , Artist:
Gui, add, edit  , xm+35  ym    w100 h20              vArtist    ,
Gui, add, text  , xm+140 ym    w30  h20  Right 0x200            , Song:
Gui, add, edit  , xm+175 ym    w100 h20              vSong      ,
Gui, add, button, xm+280 ym    w50  h20  Default                , Search
Gui, Add, Edit  , xm     ym+30 w330 h400 ReadOnly    vLyrics_edt,
Gui, Add, Statusbar
SB_SetText( "Ready." )
; Gui, add, button, x90 y98, Cancel
Menu, FileMenu, Add, About, AboutFun
Menu, FileMenu, Add, Help, HelpFun
Menu, MenuBar, Add, Menu, :FileMenu
Menu, transmenu, Add, Low, Low
Menu, transmenu, Add, Medium, Medium
Menu, transmenu, Add, Full, Full
Menu, OptionsMenu, Add, Transparency, :transmenu
Menu, OptionsMenu, Add, Keep On Top, kot
Menu, MenuBar, Add, Options, :OptionsMenu
Gui, Menu, MenuBar
Gui, show, AutoSize Center, Lyric Grabber
Return

;;;;;;;;;;;;;;;;Button Actions;;;;;;;;;;;;;

AboutFun:
Msgbox, Made using AutoHotKey script
Return

HelpFun:
Msgbox, Song and artist titles MUST be capitilized and spelled properly or you will not achieve proper results. Otherwise, the problem is most likely because Lyricwiki.org does not have the song in archive.
Return

Low:
WinSet, Transparent, 100, Lyric Grabber
Menu, transmenu, check, Low
Menu, transmenu, Uncheck, Medium
Menu, transmenu, Uncheck, Full
Return

Medium:
Winset, Transparent, 200, Lyric Grabber
Menu, transmenu, check, Medium
Menu, transmenu, Uncheck, Low
Menu, transmenu, Uncheck, Full
Return

Full:
Winset, Transparent, Off, Lyric Grabber
Menu, transmenu, check, Full
Menu, transmenu, Uncheck, Medium
Menu, transmenu, Uncheck, Low
Return

kot:
Winset, AlwaysOnTop, Toggle
Menu, OptionsMenu, togglecheck, Keep On Top
Return

ButtonCancel:
exitapp
Return

GuiEscape:
GuiClose:
{
  ExitApp
}
Return

ButtonSearch:
Gui, submit, NoHide
StringUpper, Artist, Artist,T
StringUpper, Song, Song,T
GuiControl, Text, Lyrics_edt
SB_SetText( "Searching..." )
Sleep, 50
UrlDownloadToFile, http://lyricwiki.org/%Artist%:%Song%, lyrics.html
FileRead, v_FileData, lyrics.html
FileDelete, lyrics.html

loop, parse, v_FileData, `n, `r
{
  if A_LoopField contains <div class='lyricbox' >
  {
    Output:=A_LoopField
    Break
  }
}

Output:=Output " ENDEND"
RegExMatch(Output, "s)lyricbox' >(.+)ENDEND", Output)
Lyrics:=RegExReplace(Output1,"<br />" , "`n")
Lyrics2:=RegExReplace(Lyrics,"<i>" , "`n")
Lyrics3:=RegExReplace(Lyrics2,"</i>" , "`n")

SB_SetText( "Done." )
GuiControl, Text, Lyrics_edt, %Lyrics3%


Thanks again to the wonderful people at the AHK IRC.
Back to top
View user's profile Send private message
keybored



Joined: 18 Jun 2006
Posts: 343
Location: Phoenix, AZ

PostPosted: Sun Dec 21, 2008 12:49 am    Post subject: Wow! Reply with quote

I see you did it! Even the capitalization problem is resolved.
You could reduce the three lines of regest to one line by using the vertical bar "|" which separates two or more alternatives.

Lyrics3:=RegExReplace(Output1,"<br />|<i>|</i>" , "`n")
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group