Buscar letras

Compartilhe seus scripts, funções, ferramentas e programas

Moderator: Gio

Post Reply
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Buscar letras

Post by garry » 20 Jan 2018, 05:09

Music lyric text search
EDIT : 20180120 Version-2

Image

Code: Select all

;- modified = 20180120 Version-2
;- created  = 20180119

;- click on listbox for test
;- first line is for search

;--------------------------------------------------------------------------------------------
;- search for music lyric    https://www.letras.mus.br/luiz-gonzaga/asa-branca
;                            https://www.letras.mus.br/teixeirinha-musicas/asa-branca
;                            https://www.letras.com.br/anacleto-rosas-jr/assim-como-o-rio
;                            http://lyrics.wikia.com/wiki/Jim_Reeves:Verre_Land?action=edit
;                            http://lyrics.wikia.com/wiki/Special:Search?search=Anna+Marie
;                            https://www.musixmatch.com/lyrics/Xiang-Lan-Li/Ye-Lai-Xiang
;--------------------------------------------------------------------------------------------

#warn
#NoEnv
setworkingdir,%a_scriptdir%
name1=Musica_Letras
transform,s,chr,32

Gui,2:default
Gui,2:  -DPIScale
Gui,2:Font,Cdefault,Fixedsys
Gui,2:Color,Black
Gui,2:Color,ControlColor, Black
i:=0
check:=0

xxx := ComObjCreate("WinHttp.WinHttpRequest.5.1")
ComObjError(false)    ;- script failure = off
xxx.Silent := True    ;- script failure = off
xxx.SetTimeouts(9000,9000,9000,9000)


;-------------------------------------------------
Menu,S1,add,LyricsGig              ,MH1a
Menu,S1,add,FlashLyrics            ,MH1a

menu,myMenuBar,Add,Search_Lyrics          ,:S1

gui,2:menu,MyMenuBar
;-------------------------------------------------


;--- listbox for examples ---------
e6x:=""
e6x:="
(Ltrim join|
socorro lira;pra minha aldeia
anacleto rosas jr;assim como o rio
jim reeves;the wild rose
jim reeves;verre land
jim reeves;the mighty everglades
jim reeves;distant drums
jim reeves;anna marie
teixeirinha;cantiga da saudade
teixeirinha;tropeiro velho
teixeirinha;desafio do martelo
teixeirinha;saudade da minha terra
teixeirinha;tordilho negro
teixeirinha;asa branca
teixeirinha;Foi tu que mexeu comigo
luiz gonzaga;asa branca
beatriz costa;aldeia da roupa branca
evert taube;fragancia
"
)
;------------------------------------


;---------------- first line ----------------------------------------------------------------------
searchx:=""
;searchx=Ye lai xiang
Gui,2:add,Text,    x10    y10             cGray       ,Search:
Gui,2:add,Edit,    x80    y10   w220  h25  cGray vSearch,           %searchx%

Gui,2:Add,Progress,x310   y10   w90   h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gMh2,<LetrasMus
Gui,2:Add,Progress,x410   y10   w90   h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gMh4,<LetrasCom
Gui,2:Add,Progress,x510   y10   w90   h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gMh5,<MusixMatch
Gui,2:Add,Progress,x610   y10   w70   h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gMh1,<WikiA
Gui,2:Add,Progress,x690   y10   w100  h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gMh3,<Teixeirinha
;--------------------------------------------------------------------------------------------



Gui,2:add,listbox ,x10 y50 w370 h95 cGray vLb1 gLb1a,%e6x%

Gui,2:add,Edit,    x400   y50  w170 h25  cGray vinp1 ,
Gui,2:add,Edit,    x400   y80  w170 h25  cGray vinp2 ,
Gui,2:add,Text,    x580   y50             cGray       ,Artist
Gui,2:add,Text,    x580   y80             cGray       ,Song
Gui,2:add,Text,    x660   y80  w170       cGray    vStatus   ,      ;-  status
Gui,2:add,Text,    x660   y100 w170       cGray    vStatus2   ,     ;-  status I

Gui,2:Font,Cdefault,Fixedsys
;--- colorbuttonx --------------------------------------------------
Gui,2:Add,Progress, x400  y120  w100  h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gA1,^Wiki
Gui,2:Add,Progress, x510  y120  w100  h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gA2,^letras-mus
Gui,2:Add,Progress, x620  y120  w100  h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gA3,^letras-com


Gui,2:Add,Progress, x700  y47   w75   h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gClear1,<Clear

Gui,2:Font,s10,Lucida Console
Gui,2:add,Edit,   x10   y150   w680  h25  cGray vOutx  readonly,     ;- show url

Gui,2:Add,Progress, x700  y150   w75   h25  Disabled BackgroundGray
Gui,2:Add,Text,     xp    yp    wp    hp    cBlack  BackgroundTrans  Center 0x200 gRunUrl,<RUN-url

Gui,2:Font,Cdefault s12,Lucida Console
Gui,2:add,Edit,   x10   y190  w780 h620 cYellow vED3

Gui,2:Show,x1 y1 w800 h840 ,%name1%
Guicontrol,2:Focus,inp1
send,{end}

Return
;-------------------------------
2GuiClose:
ExitApp

RunUrl:
Gui,2:submit,nohide
if outx<>
  {
  stringreplace,outx,outx,`?action=edit,,all
  run,%outx%
  }
return

Lb1a:
Gui,2:submit,nohide
GuiControl,2:Text,inp1,
GuiControl,2:Text,inp2,
StringSplit,h,Lb1, `;
GuiControl,2:Text,inp1,%h1%
GuiControl,2:Text,inp2,%h2%
goto,A1
return


clear1:
Gui,2:submit,nohide
GuiControl,2:Text,inp1,
GuiControl,2:Text,inp2,
GuiControl,2:Text,outx
GuiControl,2:Text,ed3
GuiControl,2:Text,search
GuiControl,2:Text,status,
GuiControl,2:Text,status2,
Guicontrol,2:Focus,inp1
send,{end}
return

clear2:
Gui,2:submit,nohide
GuiControl,2:Text,inp1,
GuiControl,2:Text,inp2,
GuiControl,2:Text,outx
GuiControl,2:Text,ed3
GuiControl,2:Text,status,
GuiControl,2:Text,status2,
return


mh1a:
gui,2:submit,nohide
if search<>
 stringreplace,search,search,%s%,+,all
if A_thisMenuItem=LyricsGig
   run,http://www.lyricsgig.com/index.php?page=search&searchtext=%search%
if A_thisMenuItem=flashlyrics
   run,https://www.flashlyrics.com/lyrics/
return


mh1:
Gui,2:submit,nohide
gosub,clear2
stringlen,srl,search
if (srl>2)
 {
 stringreplace,search,search,%s%,+,all
 run,http://lyrics.wikia.com/wiki/Special:Search?query=%search%
 }
return

mh2:
Gui,2:submit,nohide
gosub,clear2
stringlen,srl,search
if (srl>2)
 {
 stringreplace,search,search,%s%,`%20,all
 search=`%22%search%`%22
 run,https://www.letras.mus.br/?q=%search%
 }
return

mh3:
Gui,2:submit,nohide
gosub,clear2
stringlen,srl,search
if (srl>2)
 {
 search1=%search%
 stringreplace,search,search,%s%,`%20,all
 search=`%22%search%`%22
 run,https://www.letras.mus.br/teixeirinha-musicas/%search%
 }
return

mh4:
Gui,2:submit,nohide
gosub,clear2
stringlen,srl,search
if (srl>2)
 {
 stringreplace,search,search,%s%,+,all
 ;run,https://www.letras.com.br/anacleto-rosas-jr/assim-como-o-rio
 ;run,https://www.letras.com.br/busca.htm?buscar=pra+minha+aldeia
 run,https://www.letras.com.br/busca.htm?buscar=%search%
 }
return

mh5:
Gui,2:submit,nohide
gosub,clear2
stringlen,srl,search
if (srl>2)
 {
 stringreplace,search,search,%s%,`%20,all
 search=`%22%search%`%22#
 run,https://www.musixmatch.com/pt/search/%search%
 }
return



;--------------------------------------------
a1:   ;-- wikia
Gui,2:submit,nohide
I:=1
GuiControl,2:Text,status,
url1a=http://lyrics.wikia.com/wiki/Special:Search?search=
gosub,checkx
if (check=1)
 {
 GuiControl,2:Text,status,1-searching...
 StringUpper,inp1,inp1,T
 StringUpper,inp2,inp2,T
 StringReplace,inp1,inp1,%a_space%,_,all
 StringReplace,inp2,inp2,%a_space%,_,all
 url1=http://lyrics.wikia.com/wiki/%inp1%:%inp2%?action=edit
 word1=<lyrics>
 word2=</lyrics>
 goto,a9a
 }
return
;--------------------------------------------


;--------------------------------------------
a2:   ;-- letras-mus
Gui,2:submit,nohide
GuiControl,2:Text,status,
url1a=https://www.letras.mus.br/
gosub,checkx
if (check=1)
 {
 GuiControl,2:Text,status,2-searching...
 StringReplace,inp1,inp1,%a_space%,-,all
 StringReplace,inp2,inp2,%a_space%,-,all
 if (inp1="teixeirinha")
    url1:="https://www.letras.mus.br/teixeirinha-musicas/" . inp2
 else
    url1=https://www.letras.mus.br/%inp1%/%inp2%
 word1=<article>         ;- begin
 word2=</article>        ;- end
 goto,a9a
 }
return
;--------------------------------------------


;--------------------------------------------
a3:   ;- letras-com
Gui,2:submit,nohide
GuiControl,2:Text,status,
url1a=https://www.letras.com.br/busca.htm?buscar=
gosub,checkx
if (check=1)
 {
 GuiControl,2:Text,status,3-searching...
 StringReplace,inp1,inp1,%a_space%,-,all
 StringReplace,inp2,inp2,%a_space%,-,all
 url1=https://www.letras.com.br/%inp1%/%inp2%
 word1= <div id="letra">
 word2= </div>
 goto,a9a
 }
return
;--------------------------------------------

;--------------------------------------------
checkx:
stringlen,L11,inp1
stringlen,L12,inp2
if ((L11<2) and (L12<2))
   {
   msgbox, 262208,Missing ,Missing=`nArtist`nSong
   return
   }
if (L11<2)     ;- artist's name is empty / search BY song
   {
   msgbox, 262208,Missing ARTIST,Artist=%inp1%`nSong=%inp2%`nNow search BY SONG
   StringReplace,inp2,inp2,%s%,+,all
   xxc=%url1a%%inp2%
   run,%xxc%
   return
   }
if (L12<2)     ;- song's name is empty / search BY artist
   {
   msgbox, 262208,Missing SONG ,Artist=%inp1%`nSong=%inp2%`nNow search BY ARTIST
   StringReplace,inp1,inp1,%s%,+,all
   xxc=%url1a%%inp1%
   run,%xxc%
   return
   }
check=1
return
;--------------------------------------------


a9a:
;msgbox, 262208,,%url1%,
GuiControl,2:Text,outx,%url1%
GuiControl,2:Text,ed3
GuiControl,2:Text,status2,I=%i%
xxx.Open("GET",URL1, false)
xxx.Send()
aac    := xxx.ResponseText
stringreplace,all1,aac,`n,`r`n,all

 new=
 stringlen,L1,word1
 StringGetPos, pos1, all1, %Word1%
 pos1:=pos1+L1
 stringtrimleft,all2,all1,pos1
 all2=%all2%
 StringGetPos, pos2, all2, %Word2%
 StringMid,new,all2,1,pos2
 stringreplace,new,new,</p><p>,`r`n`r`n,all
 stringreplace,new,new,</p>,,all
 stringreplace,new,new,<p>,,all
 stringreplace,new,new,<br/>,`r`n,all
 new=%new%

stringlen,lnew,new
if (lnew<100)
  {
  i++
  if (i=2)
    goto,a2
  if (i=3)
    goto,a3
  if (i>3)
    i=0
  ;run,%url1%
  }

GuiControl,2:Text,ed3,%new%
GuiControl,2:Text,status,%i%-Search END
new=
allx=
all1=
all2=
word1=
word2=
check=0
return
;================ END SCRIPT ========================================================
Last edited by garry on 20 Jan 2018, 15:15, edited 1 time in total.
User avatar
Gio
Posts: 1247
Joined: 30 Sep 2013, 10:54
Location: Brazil

Re: Buscar letras

Post by Gio » 20 Jan 2018, 09:50

Bem interessante, obrigado por compartilhar :thumbup:

A Gui está um pouco confusa, os botões de cima apenas abrem as páginas no navegador?
O botão teixeirinha é uma preferência pessoal? :lol:
Para pesquisar sem abrir o navegador tem que escrever em Artist e Song e depois clicando nos botões Wiki/Brasil e Brasil?
E a listbox, tem como o usuário adicionar/editar as opções?

No mais, ficou show, pra quem gosta de música e letra é uma mão na roda.
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: Buscar letras

Post by garry » 20 Jan 2018, 15:28

sorry, modified , was confusing with goto.. else ( spaghetti-code )
listbox is for test , when click on row tries 3-times search in :
https://www.letras.mus.br/
https://www.letras.com.br/
http://lyrics.wikia.com/wiki/
Post Reply

Return to “Scripts e Funções”