Un petit code qui permet de récupérer les paroles de chansons via l'API ChartLyrics.
Bon, la base n'est pas follement extraordinaire et les paroles ne sont parfois pas des plus exactes mais l'API est gratuite, ne nécessite pas d'inscription et est très simple d'utilisation (4 méthodes seulement !)
Code : Tout sélectionner
EnableExplicit
; ╔═════════════════════════════════════════════════════════════════════════════╗
; ║ STRUCTURES - ENUMERATIONS - CONSTANTES - MACROS - MAPS - VARIABLES GLOBALES ║
; ╚═════════════════════════════════════════════════════════════════════════════╝
;{ ════ PLUGINS ════
;- ════ PLUGINS
UsePNGImageDecoder()
UseJPEGImageDecoder()
;}
;{ ════ STRUCTURES ════
;- ════ STRUCTURES ════
Structure XMLCHARTLYRICS_SEARCHLYRICSRESULT ;{
TrackCheckSum.s
TrackId.l
LyricChecksum.s
LyricId.l
SongUrl.s
ArtistUrl.s
Artist.s
Song.s
SongRank.l
EndStructure ;}
Structure XMLCHARTLYRICS_GETLYRICSRESULT ;{
TrackCheckSum.s
TrackId.l
LyricChecksum.s
LyricId.l
LyricSong.s
LyricArtist.s
LyricUrl.s
LyricCovertArtUrl.s
LyricRank.s
LyricCorrectUrl.s
Lyric.s
EndStructure ;}
;}
;{ ════ ENUMERATIONS ════
;- ════ ENUMERATIONS ════
Runtime Enumeration Fenetres ;{
#FEN_RECHERCHEDB
#FEN_RESULTATS
EndEnumeration ;}
Runtime Enumeration Gadgets ;{ Gadgets fenêtre principale
#GAD_FP_CD_TYPERECHERCHE
#GAD_FP_LS_TYPESRECHERCHE
#GAD_FP_CD_PARAMETRESRECHERCHE
#GAD_FP_BM_PARAMETRES
#GAD_FP_CT_PARAMETRESTYPE01
#GAD_FP_BG_PARAMETRESTYPE01
#GAD_FP_LIB_PARAMTYPE01_ARTISTE
#GAD_FP_CP_PARAMTYPE01_ARTISTE
#GAD_FP_LIB_PARAMTYPE01_TITRE
#GAD_FP_CP_PARAMTYPE01_TITRE
#GAD_FP_CT_PARAMETRESTYPE02
#GAD_FP_BG_PARAMETRESTYPE02
#GAD_FP_LIB_PARAMTYPE02_PAROLES
#GAD_FP_CP_PARAMTYPE02_PAROLES
#GAD_FP_CT_PARAMETRESTYPE03
#GAD_FP_BG_PARAMETRESTYPE03
#GAD_FP_LIB_PARAMTYPE03_IDPAROLES
#GAD_FP_CP_PARAMTYPE03_IDPAROLES
#GAD_FP_LIB_PARAMTYPE03_SOMMECONTROLE
#GAD_FP_CP_PARAMTYPE03_SOMMECONTROLE
#GAD_FP_CT_PARAMETRESTYPE04
#GAD_FP_BG_PARAMETRESTYPE04
#GAD_FP_LIB_PARAMTYPE04_ARTISTE
#GAD_FP_CP_PARAMTYPE04_ARTISTE
#GAD_FP_LIB_PARAMTYPE04_TITRE
#GAD_FP_CP_PARAMTYPE04_TITRE
#GAD_FP_LIB_ELEMENTS
#GAD_FP_LIB_NBELEMENTS
#GAD_FP_LIB_PAGE
#GAD_FP_LIB_NBPAGES
#GAD_FP_BT_RECHERCHER
#GAD_FP_BP_JAUGE
EndEnumeration ;}
Runtime Enumeration Gadgets ;{ Gadgets fenêtre résultats
#GAD_FR_LS_DONNEES
#GAD_FR_BG_RESULTATS
#GAD_FR_LIB_ARTISTE
#GAD_FR_CP_ARTISTE
#GAD_FR_LIB_URLARTISTE
#GAD_FR_CP_URLARTISTE
#GAD_FR_BT_URLARTISTE
#GAD_FR_LIB_TITRE
#GAD_FR_CP_TITRE
#GAD_FR_LIB_URLTITRE
#GAD_FR_CP_URLTITRE
#GAD_FR_BT_URLTITRE
#GAD_FR_LIB_CLASSEMENTTITRE
#GAD_FR_CP_CLASSEMENTTITRE
#GAD_FR_LIB_IDPISTE
#GAD_FR_CP_IDPISTE
#GAD_FR_LIB_SOMMECONTPISTE
#GAD_FR_CP_SOMMECONTPISTE
#GAD_FR_LIB_URLPOCHETTE
#GAD_FR_CP_URLPOCHETTE
#GAD_FR_BT_URLPOCHETTE
#GAD_FR_IMG_POCHETTE
#GAD_FR_LIB_IDPAROLES
#GAD_FR_CP_IDPAROLES
#GAD_FR_LIB_SOMMECONTPAROLES
#GAD_FR_CP_SOMMECONTPAROLES
#GAD_FR_LIB_URLPAROLES
#GAD_FR_CP_URLPAROLES
#GAD_FR_BT_URLPAROLES
#GAD_FR_LIB_URLCORRECTION
#GAD_FR_CP_URLCORRECTION
#GAD_FR_BT_URLCORRECTION
#GAD_FR_LIB_PAROLES
#GAD_FR_ED_PAROLES
EndEnumeration ;}
Enumeration XML ;{
#ARBRE_XML
EndEnumeration ;}
Enumeration DialoguesXML ;{
#XML_FENPRINCIPALE
#XML_FENRESULTATS
EndEnumeration ;}
Enumeration JSON ;{
#JSON
EndEnumeration ;}
Enumeration Images ;{
#IMG_POCHETTE
#IMG_BTCHARTLYRICS
EndEnumeration ;}
Enumeration ExpressionsReg ;{
#REGEXP
EndEnumeration ;}
;}
;{ ════ CONSTANTES ════
;- ════ CONSTANTES ════
#CHARTLYRICSCHEMINAPI="http://api.chartlyrics.com/apiv1.asmx/"
#TITREBOITEDIALOGUE="Recherche de données CHARTLYRICS"
#TITREFENETRERESULTATS="Résultats de la recherche CHARTLYRICS"
#MOTSEXCLUS="about|after|all|also|an|and|another|any|are|as|at|be|because|been|before|being|between|both|but|by|came|can|come|could|did|do|does|each|else|for|from|get|got|had|has|have|he|her|here|him|himself|his|how|if|in|into|is|it|its|just|like|make|many|me|might|more|most|much|must|my|never|no|now|of|on|only|or|other|our|out|over|re|said|same|see|should|since|so|some|still|such|take|than|that|the|their|them|then|there|these|they|this|those|through|to|too|under|up|use|very|want|was|way|we|well|were|what|when|where|which|while|who|will|with|would|you|your"
#EXPRESSIONREG="(\A(\s("+#MOTSEXCLUS+")))|(\s("+#MOTSEXCLUS+")\s)|((\s("+#MOTSEXCLUS+"))$)|(\(|\)|\[|\]|'|!|\.|:|;|,|"+Chr(34)+"|\||~|\?|!)/ig"
;}
;{ ════ MACROS ════
; -════ MACROS ════
Macro Mc_FormatageXML(ArgChaine)
EscapeString(ArgChaine,#PB_String_EscapeXML)
EndMacro
Macro Mc_DeformatageXML(ArgChaine)
UnescapeString(ArgChaine,#PB_String_EscapeXML)
EndMacro
Macro Mc_FormatageChaineRecherche(ArgChaine)
ReplaceString(Trim(ArgChaine),Chr(32),"+")
EndMacro
Macro Mc_FormatageMessage(ArgChaine)
StringField(StringField(ArgChaine,2,"message"+Chr(34)+": "),1,"}")
EndMacro
;}
; ╔═════════════════════════════════════════╗
; ║ DECLARATIONS - FICHIERS INCLUS - IMAGES ║
; ╚═════════════════════════════════════════╝
;{ ════ DECLARATIONS ════
;- ════ DECLARATIONS ════
Declare.a Fc_FenResultats_Affichage(ArgTypeRecherche.a)
;}
;-══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
; ╔════════════╗
; ║ PROCEDURES ║
; ╚════════════╝
; ╔══════════════════════╗
; ║ PROCEDURES GENERALES ║
; ╚══════════════════════╝
Procedure Pc_Ouverture_LienInternet(ArgNoGadget.u)
Protected.u NoGadget=GetGadgetData(ArgNoGadget)
Protected.s LienInternet
Select GadgetType(NoGadget)
Case #PB_GadgetType_ListIcon
If GetGadgetState(NoGadget)>=0
LienInternet=GetGadgetItemText(NoGadget,GetGadgetState(NoGadget),GetGadgetData(NoGadget))
EndIf
Case #PB_GadgetType_String
LienInternet=GetGadgetText(NoGadget)
EndSelect
If LienInternet
RunProgram(LienInternet)
EndIf
EndProcedure
Procedure.q Fc_Requete_SiteInternet(ArgRequeteHTTP.s)
Protected *RetourRequeteHTTP
Protected.q IDRequeteHTTP
Protected.s MessageErreur
IDRequeteHTTP=HTTPRequest(#PB_HTTP_Get,ArgRequeteHTTP)
If IDRequeteHTTP
If HTTPInfo(IDRequeteHTTP,#PB_HTTP_StatusCode)="200"
*RetourRequeteHTTP=ReceiveHTTPMemory(ArgRequeteHTTP)
ProcedureReturn *RetourRequeteHTTP
Else
If HTTPInfo(IDRequeteHTTP,#PB_HTTP_StatusCode)<>"0":MessageErreur="Erreur : "+HTTPInfo(IDRequeteHTTP,#PB_HTTP_StatusCode):EndIf
If HTTPInfo(IDRequeteHTTP,#PB_HTTP_ErrorMessage)<>""
If MessageErreur:MessageErreur+"\n":EndIf
MessageErreur+"Message : "+HTTPInfo(IDRequeteHTTP,#PB_HTTP_ErrorMessage,#PB_UTF8)
EndIf
If HTTPInfo(IDRequeteHTTP,#PB_HTTP_Response)<>""
If MessageErreur:MessageErreur+"\n":EndIf
MessageErreur+"Réponse : "+Mc_FormatageMessage(HTTPInfo(IDRequeteHTTP,#PB_HTTP_Response,#PB_UTF8))
EndIf
MessageRequester("Requête HTTP",ArgRequeteHTTP+UnescapeString("\n\n"+MessageErreur),#PB_MessageRequester_Error)
EndIf
Else
MessageRequester("Requête HTTP",ArgRequeteHTTP+"\n\nLa requête a échoué !",#PB_MessageRequester_Error)
EndIf
EndProcedure
Procedure.l Fc_Telechargement_Image(ArgURLImage.s,ArgNoImage.u)
Protected *TamponImage
Protected.l IDImage
If ArgURLImage
*TamponImage=ReceiveHTTPMemory(URLEncoder(ArgURLImage))
If *TamponImage
If CatchImage(ArgNoImage,*TamponImage)
IDImage=ImageID(ArgNoImage)
EndIf
FreeMemory(*TamponImage)
EndIf
EndIf
ProcedureReturn IDImage
EndProcedure
Procedure.a Fc_Controle_ValiditeChaine(ArgChaine.s,ArgNomChamp.s)
Protected.a ValeurRetour=MatchRegularExpression(#REGEXP,ArgChaine)
If ValeurRetour
MessageRequester(#TITREBOITEDIALOGUE,"Le champ '"+ArgNomChamp+"' contient un ou plusieurs mots ou caractères interdits !"+Chr(10)+Chr(10)+"Mots exclus : "+#MOTSEXCLUS,#PB_MessageRequester_Error)
EndIf
ProcedureReturn ValeurRetour
EndProcedure
;
Procedure Pc_Reinitialisation_GadgetsFenetreResultats(ArgReinitialisationListeDonnees.a=#True)
If IsGadget(#GAD_FR_LS_DONNEES) And ArgReinitialisationListeDonnees:ClearGadgetItems(#GAD_FR_LS_DONNEES):EndIf
If IsGadget(#GAD_FR_CP_ARTISTE):SetGadgetText(#GAD_FR_CP_ARTISTE,""):EndIf
If IsGadget(#GAD_FR_CP_URLARTISTE):SetGadgetText(#GAD_FR_CP_URLARTISTE,""):EndIf
If IsGadget(#GAD_FR_CP_TITRE):SetGadgetText(#GAD_FR_CP_TITRE,""):EndIf
If IsGadget(#GAD_FR_CP_URLTITRE):SetGadgetText(#GAD_FR_CP_URLTITRE,""):EndIf
If IsGadget(#GAD_FR_CP_CLASSEMENTTITRE):SetGadgetText(#GAD_FR_CP_CLASSEMENTTITRE,""):EndIf
If IsGadget(#GAD_FR_CP_URLPOCHETTE):SetGadgetText(#GAD_FR_CP_URLPOCHETTE,""):EndIf
If IsGadget(#GAD_FR_CP_IDPISTE):SetGadgetText(#GAD_FR_CP_IDPISTE,""):EndIf
If IsGadget(#GAD_FR_CP_SOMMECONTPISTE):SetGadgetText(#GAD_FR_CP_SOMMECONTPISTE,""):EndIf
If IsGadget(#GAD_FR_CP_IDPAROLES):SetGadgetText(#GAD_FR_CP_IDPAROLES,""):EndIf
If IsGadget(#GAD_FR_CP_SOMMECONTPAROLES):SetGadgetText(#GAD_FR_CP_SOMMECONTPAROLES,""):EndIf
If IsGadget(#GAD_FR_CP_URLPAROLES):SetGadgetText(#GAD_FR_CP_URLPAROLES,""):EndIf
If IsGadget(#GAD_FR_CP_URLCORRECTION):SetGadgetText(#GAD_FR_CP_URLCORRECTION,""):EndIf
If IsGadget(#GAD_FR_ED_PAROLES):SetGadgetText(#GAD_FR_ED_PAROLES,""):EndIf
If IsGadget(#GAD_FR_IMG_POCHETTE):SetGadgetState(#GAD_FR_IMG_POCHETTE,0):EndIf
EndProcedure
Procedure Pc_Affichage_Image(ArgURLImage.s)
If IsImage(#IMG_POCHETTE)
FreeImage(#IMG_POCHETTE)
SetGadgetState(#GAD_FR_IMG_POCHETTE,0)
EndIf
SetGadgetState(#GAD_FR_IMG_POCHETTE,Fc_Telechargement_Image(ArgURLImage,#IMG_POCHETTE))
EndProcedure
Procedure Pc_Affichage_DonneesListe()
Protected *RetourCHARTLYRICS
Protected.XMLCHARTLYRICS_GETLYRICSRESULT DonneesRecuperation
Protected.l NoItem,IDXML
Protected.s RequeteHTTP,IDParoles,SommeControleParoles
NoItem=GetGadgetState(#GAD_FR_LS_DONNEES)
If NoItem>=0
IDParoles=GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,4)
SommeControleParoles=GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,5)
SetGadgetText(#GAD_FR_CP_ARTISTE,GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,0))
SetGadgetText(#GAD_FR_CP_TITRE,GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,1))
SetGadgetText(#GAD_FR_CP_IDPISTE,GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,2))
SetGadgetText(#GAD_FR_CP_SOMMECONTPISTE,GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,3))
SetGadgetText(#GAD_FR_CP_IDPAROLES,IDParoles)
SetGadgetText(#GAD_FR_CP_SOMMECONTPAROLES,SommeControleParoles)
SetGadgetText(#GAD_FR_CP_CLASSEMENTTITRE,GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,6))
SetGadgetText(#GAD_FR_CP_URLARTISTE,GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,7))
SetGadgetText(#GAD_FR_CP_URLTITRE,GetGadgetItemText(#GAD_FR_LS_DONNEES,NoItem,8))
If Val(IDParoles)>0 And SommeControleParoles
RequeteHTTP=#CHARTLYRICSCHEMINAPI+"GetLyric?lyricId="+IDParoles+"&lyricCheckSum="+SommeControleParoles
*RetourCHARTLYRICS=Fc_Requete_SiteInternet(RequeteHTTP)
If *RetourCHARTLYRICS
IDXML=CatchXML(#ARBRE_XML,*RetourCHARTLYRICS,MemorySize(*RetourCHARTLYRICS),#PB_XML_StreamStart,#PB_UTF8)
If IDXML
ExtractXMLStructure(MainXMLNode(#ARBRE_XML),@DonneesRecuperation,XMLCHARTLYRICS_GETLYRICSRESULT,#PB_XML_NoCase)
DonneesRecuperation\LyricCovertArtUrl=ReplaceString(DonneesRecuperation\LyricCovertArtUrl,"http:","https:",#PB_String_NoCase)
DonneesRecuperation\LyricCovertArtUrl=ReplaceString(DonneesRecuperation\LyricCovertArtUrl,"//images.amazon.com/","//ec1.images-amazon.com/",#PB_String_NoCase)
EndIf
EndIf
EndIf
SetGadgetText(#GAD_FR_CP_URLPOCHETTE,DonneesRecuperation\LyricCovertArtUrl)
SetGadgetText(#GAD_FR_CP_URLPAROLES,DonneesRecuperation\LyricUrl)
SetGadgetText(#GAD_FR_CP_URLCORRECTION,DonneesRecuperation\LyricCorrectUrl)
SetGadgetText(#GAD_FR_ED_PAROLES,DonneesRecuperation\Lyric)
Pc_Affichage_Image(DonneesRecuperation\LyricCovertArtUrl)
Else
Pc_Reinitialisation_GadgetsFenetreResultats(#False)
EndIf
EndProcedure
Procedure Pc_AffichageResultats_Recherche(List ArgDonnees.XMLCHARTLYRICS_SEARCHLYRICSRESULT())
Protected.s Chaine
Pc_Reinitialisation_GadgetsFenetreResultats()
ForEach ArgDonnees()
With ArgDonnees()
Chaine=\Artist+Chr(10)+\Song+Chr(10)+\TrackId+Chr(10)+\TrackCheckSum+Chr(10)+\LyricId+Chr(10)+\LyricChecksum+Chr(10)+\SongRank+Chr(10)+\ArtistUrl+Chr(10)+\SongUrl
AddGadgetItem(#GAD_FR_LS_DONNEES,-1,Chaine)
EndWith
Next
EndProcedure
Procedure Pc_AffichageResultats_Recuperation(*ArgDonnees.XMLCHARTLYRICS_GETLYRICSRESULT)
With *ArgDonnees
SetGadgetText(#GAD_FR_CP_ARTISTE,\LyricArtist)
SetGadgetText(#GAD_FR_CP_TITRE,\LyricSong)
SetGadgetText(#GAD_FR_CP_IDPISTE,Str(\TrackId))
SetGadgetText(#GAD_FR_CP_SOMMECONTPISTE,\TrackCheckSum)
SetGadgetText(#GAD_FR_CP_IDPAROLES,Str(\LyricId))
SetGadgetText(#GAD_FR_CP_SOMMECONTPAROLES,\LyricChecksum)
SetGadgetText(#GAD_FR_CP_CLASSEMENTTITRE,\LyricRank)
SetGadgetText(#GAD_FR_CP_URLPOCHETTE,\LyricCovertArtUrl)
SetGadgetText(#GAD_FR_CP_URLPAROLES,\LyricUrl)
SetGadgetText(#GAD_FR_CP_URLCORRECTION,\LyricCorrectUrl)
SetGadgetText(#GAD_FR_ED_PAROLES,\Lyric)
\LyricCovertArtUrl=ReplaceString(\LyricCovertArtUrl,"http:","https:",#PB_String_NoCase)
\LyricCovertArtUrl=ReplaceString(\LyricCovertArtUrl,"//images.amazon.com/","//ec1.images-amazon.com/",#PB_String_NoCase)
Pc_Affichage_Image(\LyricCovertArtUrl)
EndWith
EndProcedure
Procedure Pc_CHARTLYRICS_LancementRecherche()
Protected *RetourCHARTLYRICS,*NoeudXML
Protected.XMLCHARTLYRICS_GETLYRICSRESULT DonneesRecuperation
Protected.l IDXML,NbDonnees,Compteur
Protected.a NoItem=GetGadgetState(#GAD_FP_LS_TYPESRECHERCHE),OuvertureFenetre=#True,FenetreOuverte
Protected.s RequeteHTTP,ParametresRequete,Chaine
NewList DonneesRecherche.XMLCHARTLYRICS_SEARCHLYRICSRESULT()
Select NoItem
Case 0
Chaine=Left(Trim(GetGadgetText(#GAD_FP_CP_PARAMTYPE01_ARTISTE)),75)
If Chaine="":MessageRequester(#TITREBOITEDIALOGUE,"La saisie du champ 'Artiste' est obligatoire !",#PB_MessageRequester_Error):ProcedureReturn:EndIf
If Fc_Controle_ValiditeChaine(Chaine,"Artiste"):ProcedureReturn:EndIf
ParametresRequete="Artist="+URLEncoder(Chaine,#PB_UTF8)
Chaine=Left(Trim(GetGadgetText(#GAD_FP_CP_PARAMTYPE01_TITRE)),125)
If Chaine="":MessageRequester(#TITREBOITEDIALOGUE,"La saisie du champ 'Titre' est obligatoire !",#PB_MessageRequester_Error):ProcedureReturn:EndIf
If Fc_Controle_ValiditeChaine(Chaine,"Titre"):ProcedureReturn:EndIf
ParametresRequete+"&Song="+URLEncoder(Chaine,#PB_UTF8)
ParametresRequete="SearchLyric?"+ParametresRequete
Case 1
Chaine=Left(Trim(GetGadgetText(#GAD_FP_CP_PARAMTYPE02_PAROLES)),250)
If Chaine="":MessageRequester(#TITREBOITEDIALOGUE,"La saisie du champ 'Paroles' est obligatoire !",#PB_MessageRequester_Error):ProcedureReturn:EndIf
If Fc_Controle_ValiditeChaine(Chaine,"Paroles"):ProcedureReturn:EndIf
ParametresRequete="lyricText="+URLEncoder(Chaine,#PB_UTF8)
ParametresRequete="SearchLyricText?"+ParametresRequete
Case 2
Chaine=Trim(GetGadgetText(#GAD_FP_CP_PARAMTYPE03_IDPAROLES))
If Chaine="":MessageRequester(#TITREBOITEDIALOGUE,"La saisie du champ 'ID Paroles' est obligatoire !",#PB_MessageRequester_Error):ProcedureReturn:EndIf
ParametresRequete="lyricId="+Chaine
Chaine=Trim(GetGadgetText(#GAD_FP_CP_PARAMTYPE03_SOMMECONTROLE))
If Chaine="":MessageRequester(#TITREBOITEDIALOGUE,"La saisie du champ 'Somme de contrôle' est obligatoire !",#PB_MessageRequester_Error):ProcedureReturn:EndIf
ParametresRequete+"&lyricCheckSum="+Chaine
ParametresRequete="GetLyric?"+ParametresRequete
Case 3
Chaine=Left(Trim(GetGadgetText(#GAD_FP_CP_PARAMTYPE04_ARTISTE)),75)
If Chaine="":MessageRequester(#TITREBOITEDIALOGUE,"La saisie du champ 'Artiste' est obligatoire !",#PB_MessageRequester_Error):ProcedureReturn:EndIf
If Fc_Controle_ValiditeChaine(Chaine,"Artiste"):ProcedureReturn:EndIf
ParametresRequete="Artist="+URLEncoder(Chaine,#PB_UTF8)
Chaine=Left(Trim(GetGadgetText(#GAD_FP_CP_PARAMTYPE04_TITRE)),125)
If Chaine="":MessageRequester(#TITREBOITEDIALOGUE,"La saisie du champ 'Titre' est obligatoire !",#PB_MessageRequester_Error):ProcedureReturn:EndIf
If Fc_Controle_ValiditeChaine(Chaine,"Titre"):ProcedureReturn:EndIf
ParametresRequete+"&Song="+URLEncoder(Chaine,#PB_UTF8)
ParametresRequete="SearchLyricDirect?"+ParametresRequete
EndSelect
RequeteHTTP=#CHARTLYRICSCHEMINAPI+ParametresRequete
*RetourCHARTLYRICS=Fc_Requete_SiteInternet(RequeteHTTP)
If *RetourCHARTLYRICS
IDXML=CatchXML(#ARBRE_XML,*RetourCHARTLYRICS,MemorySize(*RetourCHARTLYRICS),#PB_XML_StreamStart,#PB_UTF8)
;Debug ComposeXML(#ARBRE_XML,#PB_XML_NoDeclaration)
If IDXML
Select NoItem
Case 0,1
NbDonnees=XMLChildCount(MainXMLNode(#ARBRE_XML))-1
For Compteur=1 To NbDonnees
*NoeudXML=ChildXMLNode(MainXMLNode(#ARBRE_XML),Compteur)
AddElement(DonneesRecherche())
ExtractXMLStructure(*NoeudXML,@DonneesRecherche(),XMLCHARTLYRICS_SEARCHLYRICSRESULT,#PB_XML_NoCase)
Next
Case 2,3
*NoeudXML=MainXMLNode(#ARBRE_XML)
ExtractXMLStructure(*NoeudXML,@DonneesRecuperation,XMLCHARTLYRICS_GETLYRICSRESULT,#PB_XML_NoCase)
NbDonnees=Bool(DonneesRecuperation\LyricId>0)
EndSelect
SetGadgetText(#GAD_FP_LIB_NBELEMENTS,Str(NbDonnees))
FreeXML(#ARBRE_XML)
EndIf
FreeMemory(*RetourCHARTLYRICS)
EndIf
If NbDonnees
If IsWindow(#FEN_RESULTATS)
If GetWindowData(#FEN_RESULTATS)<>NoItem
CloseWindow(#FEN_RESULTATS)
Else
OuvertureFenetre=#False:FenetreOuverte=#True
EndIf
EndIf
If OuvertureFenetre
FenetreOuverte=Fc_FenResultats_Affichage(NoItem)
EndIf
If FenetreOuverte
Select NoItem
Case 0,1:Pc_AffichageResultats_Recherche(DonneesRecherche())
Case 2,3:Pc_AffichageResultats_Recuperation(@DonneesRecuperation)
EndSelect
HideWindow(#FEN_RESULTATS,#False)
EndIf
ElseIf IsWindow(#FEN_RESULTATS)
Pc_Reinitialisation_GadgetsFenetreResultats()
EndIf
EndProcedure
;-══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
; ╔═════════════════════════╗
; ║ PROCEDURES FENETRES XML ║
; ╚═════════════════════════╝
Procedure.a Fc_Fenetres_OuvertureDialogueXML(ArgArbreXML.u,ArgDialogueXML.u,ArgChaineXML.s,ArgNomFenetre.s,ArgIdFenetreParente.i=0)
Protected.i NoDialogue
Protected.a TypeErreur
Protected.s MsgErreur
If ArgChaineXML
If ParseXML(ArgArbreXML,ArgChaineXML)
If XMLStatus(ArgArbreXML)=#PB_XML_Success
If CreateDialog(ArgDialogueXML)
If ArgIdFenetreParente<>0
NoDialogue=OpenXMLDialog(ArgDialogueXML,ArgArbreXML,ArgNomFenetre,0,0,0,0,ArgIdFenetreParente)
Else
NoDialogue=OpenXMLDialog(ArgDialogueXML,ArgArbreXML,ArgNomFenetre,0,0,0,0)
EndIf
If NoDialogue
FreeXML(ArgArbreXML)
ProcedureReturn #True
Else
TypeErreur=3
EndIf
FreeDialog(ArgDialogueXML)
Else
TypeErreur=2
EndIf
FreeXML(ArgArbreXML)
Else
TypeErreur=1
MsgErreur="Erreur durant l'interprétation du dialogue XML !"
EndIf
Else
TypeErreur=1
MsgErreur="Erreur durant la lecture des données du dialogue XML !"
EndIf
EndIf
Select TypeErreur
Case 1:MsgErreur+"\n\n No erreur : "+XMLStatus(ArgArbreXML)+" - "+XMLError(ArgArbreXML)+"\n Ligne : "+Str(XMLErrorLine(ArgArbreXML))+" - Colonne : "+Str(XMLErrorPosition(ArgArbreXML))
Case 2:MsgErreur="Erreur durant la création de la fenêtre de dialogue !"
Case 3:MsgErreur="Erreur durant l'ouverture de la fenêtre de dialogue !\n\nErreur : "+DialogError(ArgDialogueXML)
EndSelect
MessageRequester(#TITREBOITEDIALOGUE,UnescapeString(MsgErreur),#PB_MessageRequester_Error)
EndProcedure
; ╔══════════════════════════════╗
; ║ PROCEDURES FENETRE RESULTATS ║
; ╚══════════════════════════════╝
Procedure.a Fc_FenResultats_Affichage(ArgTypeRecherche.a)
Protected.a ValeurRetour
Protected.s ChaineXML
Select ArgTypeRecherche
Case 0,1 ; Recherche Paroles
ChaineXML="<?xml version='1.0' encoding='UTF-16'?>"+Chr(10)+ ;{
"<dialogs>"+Chr(10)+
" <window id='"+Str(#FEN_RESULTATS)+"' name='FEN_RESULTATS' text='"+Mc_FormatageXML("Résultats de la recherche DISCOGS")+"' xpos='266' ypos='0' minwidth='600' minheight='auto' margin='top:16,bottom:8,horizontal:16' flags='#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered'>"+Chr(10)+
" <vbox expand='item:1' spacing='8'>"+Chr(10)+
" <listicon id='"+Str(#GAD_FR_LS_DONNEES)+"' name='GAD_FR_LS_DONNEES' height='100' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
" <gridbox id='"+Str(#GAD_FR_BG_RESULTATS)+"' name='GAD_FR_BG_RESULTATS' disabled='yes' columns='2' colspacing='4' colexpand='item:2'>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_ARTISTE)+"' name='GAD_FR_LIB_ARTISTE' text='"+Mc_FormatageXML("Artiste :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_ARTISTE)+"' name='GAD_FR_CP_ARTISTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLARTISTE)+"' name='GAD_FR_LIB_URLARTISTE' text='"+Mc_FormatageXML("URL Artiste :")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLARTISTE)+"' name='GAD_FR_CP_URLARTISTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLARTISTE)+"' name='GAD_FR_BT_URLARTISTE'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_TITRE)+"' name='GAD_FR_LIB_TITRE' text='"+Mc_FormatageXML("Titre :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_TITRE)+"' name='GAD_FR_CP_TITRE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLTITRE)+"' name='GAD_FR_LIB_URLTITRE' text='"+Mc_FormatageXML("URL Titre : ")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLTITRE)+"' name='GAD_FR_CP_URLTITRE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLTITRE)+"' name='GAD_FR_BT_URLTITRE'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_CLASSEMENTTITRE)+"' name='GAD_FR_LIB_CLASSEMENTTITRE' text='"+Mc_FormatageXML("Classement Titre :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_CLASSEMENTTITRE)+"' name='GAD_FR_CP_CLASSEMENTTITRE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_IDPISTE)+"' name='GAD_FR_LIB_IDPISTE' text='"+Mc_FormatageXML("ID Piste :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_IDPISTE)+"' name='GAD_FR_CP_IDPISTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_SOMMECONTPISTE)+"' name='GAD_FR_LIB_SOMMECONTPISTE' text='"+Mc_FormatageXML("Somme contrôle Piste :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_SOMMECONTPISTE)+"' name='GAD_FR_CP_SOMMECONTPISTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLPOCHETTE)+"' name='GAD_FR_LIB_URLPOCHETTE' text='"+Mc_FormatageXML("URL Pochette :")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLPOCHETTE)+"' name='GAD_FR_CP_URLPOCHETTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLPOCHETTE)+"' name='GAD_FR_BT_URLPOCHETTE'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <empty/>"+Chr(10)+
" <hbox expand='no' align='center'>"+Chr(10)+
" <image id='"+Str(#GAD_FR_IMG_POCHETTE)+"' name='GAD_FR_IMG_POCHETTE' width='160' height='160'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_IDPAROLES)+"' name='GAD_FR_LIB_IDPAROLES' text='"+Mc_FormatageXML("ID Paroles :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_IDPAROLES)+"' name='GAD_FR_CP_IDPAROLES' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_SOMMECONTPAROLES)+"' name='GAD_FR_LIB_SOMMECONTPAROLES' text='"+Mc_FormatageXML("Somme contrôle Paroles :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_SOMMECONTPAROLES)+"' name='GAD_FR_CP_SOMMECONTPAROLES' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLPAROLES)+"' name='GAD_FR_LIB_URLPAROLES' text='"+Mc_FormatageXML("URL Paroles : ")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLPAROLES)+"' name='GAD_FR_CP_URLPAROLES' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLPAROLES)+"' name='GAD_FR_BT_URLPAROLES'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLCORRECTION)+"' name='GAD_FR_LIB_URLCORRECTION' text='"+Mc_FormatageXML("URL correction : ")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLCORRECTION)+"' name='GAD_FR_CP_URLCORRECTION' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLCORRECTION)+"' name='GAD_FR_BT_URLCORRECTION'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_PAROLES)+"' name='GAD_FR_LIB_PAROLES' text='"+Mc_FormatageXML("Paroles :")+"'/>"+Chr(10)+
" <editor id='"+Str(#GAD_FR_ED_PAROLES)+"' name='GAD_FR_ED_PAROLES' height='152'/> "+Chr(10)+
" </gridbox> "+Chr(10)+
" </vbox> "+Chr(10)+
" </window>"+Chr(10)+
"</dialogs>" ;}
Case 2,3 ; Récupération Paroles
ChaineXML="<?xml version='1.0' encoding='UTF-16'?>"+Chr(10)+ ;{
"<dialogs>"+Chr(10)+
" <window id='"+Str(#FEN_RESULTATS)+"' name='FEN_RESULTATS' text='"+Mc_FormatageXML("Résultats de la recherche DISCOGS")+"' xpos='266' ypos='0' minwidth='600' minheight='auto' margin='top:16,bottom:8,horizontal:16' flags='#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered'>"+Chr(10)+
" <vbox expand='item:1' spacing='8'>"+Chr(10)+
" <gridbox id='"+Str(#GAD_FR_BG_RESULTATS)+"' name='GAD_FR_BG_RESULTATS' disabled='yes' columns='2' colspacing='4' colexpand='item:2'>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_ARTISTE)+"' name='GAD_FR_LIB_ARTISTE' text='"+Mc_FormatageXML("Artiste :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_ARTISTE)+"' name='GAD_FR_CP_ARTISTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_TITRE)+"' name='GAD_FR_LIB_TITRE' text='"+Mc_FormatageXML("Titre :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_TITRE)+"' name='GAD_FR_CP_TITRE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_CLASSEMENTTITRE)+"' name='GAD_FR_LIB_CLASSEMENTTITRE' text='"+Mc_FormatageXML("Classement Titre :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_CLASSEMENTTITRE)+"' name='GAD_FR_CP_CLASSEMENTTITRE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_IDPISTE)+"' name='GAD_FR_LIB_IDPISTE' text='"+Mc_FormatageXML("ID Piste :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_IDPISTE)+"' name='GAD_FR_CP_IDPISTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_SOMMECONTPISTE)+"' name='GAD_FR_LIB_SOMMECONTPISTE' text='"+Mc_FormatageXML("Somme contrôle Piste :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_SOMMECONTPISTE)+"' name='GAD_FR_CP_SOMMECONTPISTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLPOCHETTE)+"' name='GAD_FR_LIB_URLPOCHETTE' text='"+Mc_FormatageXML("URL Pochette :")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLPOCHETTE)+"' name='GAD_FR_CP_URLPOCHETTE' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLPOCHETTE)+"' name='GAD_FR_BT_URLPOCHETTE'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <empty/>"+Chr(10)+
" <hbox expand='no' align='center'>"+Chr(10)+
" <image id='"+Str(#GAD_FR_IMG_POCHETTE)+"' name='GAD_FR_IMG_POCHETTE' width='160' height='160'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_IDPAROLES)+"' name='GAD_FR_LIB_IDPAROLES' text='"+Mc_FormatageXML("ID Paroles :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_IDPAROLES)+"' name='GAD_FR_CP_IDPAROLES' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_SOMMECONTPAROLES)+"' name='GAD_FR_LIB_SOMMECONTPAROLES' text='"+Mc_FormatageXML("Somme contrôle Paroles :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_SOMMECONTPAROLES)+"' name='GAD_FR_CP_SOMMECONTPAROLES' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLPAROLES)+"' name='GAD_FR_LIB_URLPAROLES' text='"+Mc_FormatageXML("URL Paroles : ")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLPAROLES)+"' name='GAD_FR_CP_URLPAROLES' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLPAROLES)+"' name='GAD_FR_BT_URLPAROLES'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_URLCORRECTION)+"' name='GAD_FR_LIB_URLCORRECTION' text='"+Mc_FormatageXML("URL correction : ")+"'/>"+Chr(10)+
" <hbox expand='item:1' spacing='2'>"+Chr(10)+
" <string id='"+Str(#GAD_FR_CP_URLCORRECTION)+"' name='GAD_FR_CP_URLCORRECTION' flags='#PB_String_ReadOnly'/>"+Chr(10)+
" <buttonimage id='"+Str(#GAD_FR_BT_URLCORRECTION)+"' name='GAD_FR_BT_URLCORRECTION'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <text id='"+Str(#GAD_FR_LIB_PAROLES)+"' name='GAD_FR_LIB_PAROLES' text='"+Mc_FormatageXML("Paroles :")+"'/>"+Chr(10)+
" <editor id='"+Str(#GAD_FR_ED_PAROLES)+"' name='GAD_FR_ED_PAROLES' height='256'/> "+Chr(10)+
" </gridbox> "+Chr(10)+
" </vbox> "+Chr(10)+
" </window>"+Chr(10)+
"</dialogs>" ;}
EndSelect
If ChaineXML
ValeurRetour=Fc_Fenetres_OuvertureDialogueXML(#ARBRE_XML,#XML_FENRESULTATS,ChaineXML,"FEN_RESULTATS")
If ValeurRetour
If Not IsImage(#IMG_BTCHARTLYRICS)
CatchImage(#IMG_BTCHARTLYRICS,?ImageBtChartLyrics_Debut,?ImageBtChartLyrics_Fin-?ImageBtChartLyrics_Debut)
EndIf
SetWindowData(#FEN_RESULTATS,ArgTypeRecherche)
Select ArgTypeRecherche
Case 0,1 ;{ Recherche Paroles
SetGadgetItemAttribute(#GAD_FR_LS_DONNEES,0,#PB_ListIcon_ColumnWidth,100,0)
SetGadgetItemText(#GAD_FR_LS_DONNEES,-1,"Artiste",0)
AddGadgetColumn(#GAD_FR_LS_DONNEES,1,"Titre",100)
AddGadgetColumn(#GAD_FR_LS_DONNEES,2,"ID Piste",64)
AddGadgetColumn(#GAD_FR_LS_DONNEES,3,"Somme cont. Piste",64)
AddGadgetColumn(#GAD_FR_LS_DONNEES,4,"ID Paroles",64)
AddGadgetColumn(#GAD_FR_LS_DONNEES,5,"Somme cont. Paroles",64)
AddGadgetColumn(#GAD_FR_LS_DONNEES,6,"Classement Titre",64)
AddGadgetColumn(#GAD_FR_LS_DONNEES,7,"URL Artiste",100)
AddGadgetColumn(#GAD_FR_LS_DONNEES,8,"URL Titre",100)
;
SetGadgetData(#GAD_FR_BT_URLARTISTE,#GAD_FR_CP_URLARTISTE)
SetGadgetAttribute(#GAD_FR_BT_URLARTISTE,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
SetGadgetData(#GAD_FR_BT_URLTITRE,#GAD_FR_CP_URLTITRE)
SetGadgetAttribute(#GAD_FR_BT_URLTITRE,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
SetGadgetData(#GAD_FR_BT_URLPOCHETTE,#GAD_FR_CP_URLPOCHETTE)
SetGadgetAttribute(#GAD_FR_BT_URLPOCHETTE,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
SetGadgetData(#GAD_FR_BT_URLPAROLES,#GAD_FR_CP_URLPAROLES)
SetGadgetAttribute(#GAD_FR_BT_URLPAROLES,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
SetGadgetData(#GAD_FR_BT_URLCORRECTION,#GAD_FR_CP_URLCORRECTION)
SetGadgetAttribute(#GAD_FR_BT_URLCORRECTION,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
;}
Case 2,3 ;{ Récupération Paroles
SetGadgetData(#GAD_FR_BT_URLPOCHETTE,#GAD_FR_CP_URLPOCHETTE)
SetGadgetAttribute(#GAD_FR_BT_URLPOCHETTE,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
SetGadgetData(#GAD_FR_BT_URLPAROLES,#GAD_FR_CP_URLPAROLES)
SetGadgetAttribute(#GAD_FR_BT_URLPAROLES,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
SetGadgetData(#GAD_FR_BT_URLCORRECTION,#GAD_FR_CP_URLCORRECTION)
SetGadgetAttribute(#GAD_FR_BT_URLCORRECTION,#PB_Button_Image,ImageID(#IMG_BTCHARTLYRICS))
;}
EndSelect
EndIf
EndIf
ProcedureReturn ValeurRetour
EndProcedure
; ╔═══════════════════════════════╗
; ║ PROCEDURES FENETRE PRINCIPALE ║
; ╚═══════════════════════════════╝
Procedure Pc_FenPrincipale_GestionConteneursParametres()
Protected.b NoItem=GetGadgetState(#GAD_FP_LS_TYPESRECHERCHE)
Protected.u ConteneurActif=GetGadgetData(#GAD_FP_LS_TYPESRECHERCHE),ConteneurSelectionne=GetGadgetItemData(#GAD_FP_LS_TYPESRECHERCHE,NoItem)
If ConteneurSelectionne<>ConteneurActif
HideGadget(ConteneurActif,#True)
HideGadget(ConteneurSelectionne,#False)
SetGadgetData(#GAD_FP_LS_TYPESRECHERCHE,ConteneurSelectionne)
SetActiveGadget(GetGadgetData(ConteneurSelectionne))
EndIf
EndProcedure
Procedure Pc_FenPrincipale_GestionEvenements()
Protected.l NoFenetre,Evenmt,EvenmtMenu,TypeEvenmt,NoGadget
Repeat
NoFenetre=EventWindow()
Evenmt=WaitWindowEvent()
TypeEvenmt=EventType()
Select Evenmt
Case #PB_Event_ActivateWindow
Case #PB_Event_DeactivateWindow
Case #PB_Event_Gadget
NoGadget=EventGadget()
Select TypeEvenmt
Case #PB_EventType_Change
Select NoGadget
Case #GAD_FR_LS_DONNEES:Pc_Affichage_DonneesListe()
EndSelect
Case #PB_EventType_LeftClick
Select NoGadget
Case #GAD_FP_LS_TYPESRECHERCHE:Pc_FenPrincipale_GestionConteneursParametres()
Case #GAD_FP_BT_RECHERCHER:Pc_CHARTLYRICS_LancementRecherche()
Case #GAD_FR_BT_URLARTISTE,#GAD_FR_BT_URLTITRE,#GAD_FR_BT_URLPAROLES,#GAD_FR_BT_URLPOCHETTE,#GAD_FR_BT_URLCORRECTION:Pc_Ouverture_LienInternet(NoGadget)
EndSelect
EndSelect
Case #PB_Event_CloseWindow
Select NoFenetre
Case #FEN_RESULTATS:CloseWindow(#FEN_RESULTATS)
Case #FEN_RECHERCHEDB
If IsWindow(#FEN_RESULTATS):CloseWindow(#FEN_RESULTATS):EndIf
End
EndSelect
Case #PB_Event_Menu
EvenmtMenu=EventMenu()
Select EvenmtMenu
Case #PB_Shortcut_Escape
EndSelect
Case #WM_KEYDOWN
Case #WM_KEYUP
Case #WM_SYSKEYDOWN
Case #WM_SYSKEYUP
Case #WM_SYSCOMMAND
EndSelect
ForEver
EndProcedure
Procedure Pc_FenPrincipale_Affichage()
Protected.a ValeurRetour
Protected.s ChaineXML
ChaineXML="<?xml version='1.0' encoding='UTF-16'?>"+Chr(10)+ ;{
"<dialogs>"+Chr(10)+
" <window id='"+Str(#FEN_RECHERCHEDB)+"' name='FEN_RECHERCHEDB' text='"+Mc_FormatageXML("Recherche Base de données Internet")+"' xpos='0' ypos='0' width='800' minwidth='auto' minheight='auto' maxheight='auto' margin='top:20,bottom:0' flags='#PB_Window_SystemMenu|#PB_Window_SizeGadget |#PB_Window_Invisible|#PB_Window_ScreenCentered'>"+Chr(10)+
" <vbox spacing='2'>"+Chr(10)+
" <hbox expand='item:3' spacing='8'>"+Chr(10)+
" <hbox expand='no' align='' spacing='24'>"+Chr(10)+
" <empty width='8'/> "+Chr(10)+
" </hbox>"+Chr(10)+
" <frame id='"+Str(#GAD_FP_CD_TYPERECHERCHE)+"' name='GAD_FP_CD_TYPERECHERCHE' text='"+Mc_FormatageXML("Type de recherche : ")+"'>"+Chr(10)+
" <listview id='"+Str(#GAD_FP_LS_TYPESRECHERCHE)+"' name='GAD_FP_LS_TYPESRECHERCHE' width='300' height='80'/> "+Chr(10)+
" </frame>"+Chr(10)+
" <frame id='"+Str(#GAD_FP_CD_PARAMETRESRECHERCHE)+"' name='GAD_FP_CD_PARAMETRESRECHERCHE' text='"+Mc_FormatageXML("Paramètres : ")+"'>"+Chr(10)+
" <multibox id='"+Str(#GAD_FP_BM_PARAMETRES)+"'>"+Chr(10)+
" <container id='"+Str(#GAD_FP_CT_PARAMETRESTYPE01)+"' name='GAD_FP_CT_PARAMETRESTYPE01'>"+Chr(10)+
" <gridbox id='"+Str(#GAD_FP_BG_PARAMETRESTYPE01)+"' name='GAD_FP_BG_PARAMETRESTYPE01' columns='2' rowspacing='12' colexpand='item:2'>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PARAMTYPE01_ARTISTE)+"' name='GAD_FP_LIB_PARAMTYPE01_ARTISTE' text='"+Mc_FormatageXML("Artiste (max 75 car.) :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FP_CP_PARAMTYPE01_ARTISTE)+"' name='GAD_FP_CP_PARAMTYPE01_ARTISTE'/>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PARAMTYPE01_TITRE)+"' name='GAD_FP_LIB_PARAMTYPE01_TITRE' text='"+Mc_FormatageXML("Titre (max 125 car.) :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FP_CP_PARAMTYPE01_TITRE)+"' name='GAD_FP_CP_PARAMTYPE01_TITRE'/>"+Chr(10)+
" </gridbox> "+Chr(10)+
" </container>"+Chr(10)+
" <container id='"+Str(#GAD_FP_CT_PARAMETRESTYPE02)+"' name='GAD_FP_CT_PARAMETRESTYPE02' invisible='yes'>"+Chr(10)+
" <gridbox id='"+Str(#GAD_FP_BG_PARAMETRESTYPE02)+"' name='GAD_FP_BG_PARAMETRESTYPE02' columns='2' rowspacing='12' colexpand='item:2'>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PARAMTYPE02_PAROLES)+"' name='GAD_FP_LIB_PARAMTYPE02_PAROLES' text='"+Mc_FormatageXML("Paroles (max 250 car.) :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FP_CP_PARAMTYPE02_PAROLES)+"' name='GAD_FP_CP_PARAMTYPE02_PAROLES'/>"+Chr(10)+
" </gridbox> "+Chr(10)+
" </container>"+Chr(10)+
" <container id='"+Str(#GAD_FP_CT_PARAMETRESTYPE03)+"' name='GAD_FP_CT_PARAMETRESTYPE03' invisible='yes'>"+Chr(10)+
" <gridbox id='"+Str(#GAD_FP_BG_PARAMETRESTYPE03)+"' name='GAD_FP_BG_PARAMETRESTYPE03' columns='2' rowspacing='12' colexpand='item:2'>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PARAMTYPE03_IDPAROLES)+"' name='GAD_FP_LIB_PARAMTYPE03_IDPAROLES' text='"+Mc_FormatageXML("ID Paroles :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FP_CP_PARAMTYPE03_IDPAROLES)+"' name='GAD_FP_CP_PARAMTYPE03_IDPAROLES' flags='#PB_String_Numeric'/>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PARAMTYPE03_SOMMECONTROLE)+"' name='GAD_FP_LIB_PARAMTYPE03_SOMMECONTROLE' text='"+Mc_FormatageXML("Somme de contrôle :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FP_CP_PARAMTYPE03_SOMMECONTROLE)+"' name='GAD_FP_CP_PARAMTYPE03_SOMMECONTROLE'/>"+Chr(10)+
" </gridbox> "+Chr(10)+
" </container>"+Chr(10)+
" <container id='"+Str(#GAD_FP_CT_PARAMETRESTYPE04)+"' name='GAD_FP_CT_PARAMETRESTYPE04' invisible='yes'>"+Chr(10)+
" <gridbox id='"+Str(#GAD_FP_BG_PARAMETRESTYPE04)+"' name='GAD_FP_BG_PARAMETRESTYPE04' columns='2' rowspacing='12' colexpand='item:2'>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PARAMTYPE04_ARTISTE)+"' name='GAD_FP_LIB_PARAMTYPE04_ARTISTE' text='"+Mc_FormatageXML("Artiste (max 75 car.) :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FP_CP_PARAMTYPE04_ARTISTE)+"' name='GAD_FP_CP_PARAMTYPE04_ARTISTE'/>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PARAMTYPE04_TITRE)+"' name='GAD_FP_LIB_PARAMTYPE04_TITRE' text='"+Mc_FormatageXML("Titre (max 125 car.) :")+"'/>"+Chr(10)+
" <string id='"+Str(#GAD_FP_CP_PARAMTYPE04_TITRE)+"' name='GAD_FP_CP_PARAMTYPE04_TITRE'/>"+Chr(10)+
" </gridbox> "+Chr(10)+
" </container> "+Chr(10)+
" </multibox> "+Chr(10)+
" </frame>"+Chr(10)+
" <hbox expand='no' align='' spacing='24'>"+Chr(10)+
" <empty width='8'/> "+Chr(10)+
" </hbox> "+Chr(10)+
" </hbox>"+Chr(10)+
" <empty height='8'/>"+Chr(10)+
" <hbox expand='item:7' spacing='4'>"+Chr(10)+
" <empty width='12'/>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_ELEMENTS)+"' name='GAD_FP_LIB_ELEMENTS' text='"+Mc_FormatageXML("Nb éléments trouvés : ")+"'/>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_NBELEMENTS)+"' name='GAD_FP_LIB_NBELEMENTS' text='"+Mc_FormatageXML(" ")+"' width='72'/>"+Chr(10)+
" <empty width='12'/>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_PAGE)+"' name='GAD_FP_LIB_PAGE' text='"+Mc_FormatageXML("Page : ")+"' invisible='yes'/>"+Chr(10)+
" <text id='"+Str(#GAD_FP_LIB_NBPAGES)+"' name='GAD_FP_LIB_NBPAGES' text='"+Mc_FormatageXML(" ")+"' invisible='yes' width='72'/>"+Chr(10)+
" <empty/>"+Chr(10)+
" <hbox expand='no' align='right'>"+Chr(10)+
" <button id='"+Str(#GAD_FP_BT_RECHERCHER)+"' name='GAD_FP_BT_RECHERCHER' text='"+Mc_FormatageXML("Rechercher")+"'/>"+Chr(10)+
" <empty width='8'/>"+Chr(10)+
" </hbox> "+Chr(10)+
" </hbox>"+Chr(10)+
" <empty height='4'/>"+Chr(10)+
" <progressbar id='"+Str(#GAD_FP_BP_JAUGE)+"' name='GAD_FP_BP_JAUGE' invisible='yes' height='4' min='0' max='100'/>"+Chr(10)+
" <empty height='2'/> "+Chr(10)+
" </vbox> "+Chr(10)+
" </window>"+Chr(10)+
"</dialogs>" ;}
ValeurRetour=Fc_Fenetres_OuvertureDialogueXML(#ARBRE_XML,#XML_FENPRINCIPALE,ChaineXML,"FEN_RECHERCHEDB")
If ValeurRetour
CreateRegularExpression(#REGEXP,#EXPRESSIONREG,#PB_RegularExpression_NoCase)
; Ajout items liste types de recherche
AddGadgetItem(#GAD_FP_LS_TYPESRECHERCHE,0,"Recherche paroles par artiste et titre")
AddGadgetItem(#GAD_FP_LS_TYPESRECHERCHE,1,"Recherche paroles par texte paroles")
AddGadgetItem(#GAD_FP_LS_TYPESRECHERCHE,2,"Récupération paroles par ID")
AddGadgetItem(#GAD_FP_LS_TYPESRECHERCHE,3,"Récupération paroles par artiste et titre")
SetGadgetState(#GAD_FP_LS_TYPESRECHERCHE,0)
;
SetGadgetData(#GAD_FP_LS_TYPESRECHERCHE,#GAD_FP_CT_PARAMETRESTYPE01)
SetGadgetItemData(#GAD_FP_LS_TYPESRECHERCHE,0,#GAD_FP_CT_PARAMETRESTYPE01)
SetGadgetItemData(#GAD_FP_LS_TYPESRECHERCHE,1,#GAD_FP_CT_PARAMETRESTYPE02)
SetGadgetItemData(#GAD_FP_LS_TYPESRECHERCHE,2,#GAD_FP_CT_PARAMETRESTYPE03)
SetGadgetItemData(#GAD_FP_LS_TYPESRECHERCHE,3,#GAD_FP_CT_PARAMETRESTYPE04)
;{
SetGadgetData(#GAD_FP_CT_PARAMETRESTYPE01,#GAD_FP_CP_PARAMTYPE01_ARTISTE)
SetGadgetData(#GAD_FP_CT_PARAMETRESTYPE02,#GAD_FP_CP_PARAMTYPE02_PAROLES)
SetGadgetData(#GAD_FP_CT_PARAMETRESTYPE03,#GAD_FP_CP_PARAMTYPE03_IDPAROLES)
SetGadgetData(#GAD_FP_CT_PARAMETRESTYPE04,#GAD_FP_CP_PARAMTYPE04_ARTISTE)
;}
HideWindow(#FEN_RECHERCHEDB,#False)
SetActiveGadget(#GAD_FP_CP_PARAMTYPE01_ARTISTE)
Pc_FenPrincipale_GestionEvenements()
EndIf
EndProcedure
;-══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
; ╔══════════════════╗
; ║ MODULE PRINCIPAL ║
; ╚══════════════════╝
Pc_FenPrincipale_Affichage()
End
;-══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
; ╔═════════════════╗
; ║ SECTION DONNEES ║
; ╚═════════════════╝
;{
DataSection
ImageBtChartLyrics_Debut: ;{ Fichier : D:\FICHIERS\Fichiers PureBasic\GestionAlbumsAudio\Ressources\Images\ImgBtChartLyrics.png
Data.q $0A1A0A0D474E5089,$524448490D000000,$1000000010000000,$6891900000000208,$5948700900000036,$0E0000C40E000073,$00001B0E2B9501C4,$CF28544144497D02
Data.q $C614511B4BCB9075,$744C68994CEE64EF,$26DC4217588FA912,$E0ABE31588DD6208,$BB4561FFEAAED04A,$5D4D9B042CC1FFB0,$268D42B104623768,$151B11042CEC66BB
Data.q $C7993A270631D40C,$F685B603174F73BD,$AE1C7C79DFBE1D5B,$2122899E84212A54,$3E79E002F90C63C4,$281C1EBE42120C18,$1F1A952A6AAAA28A,$6DB64BFD0000E71F
Data.q $10512DADADD9B367,$2DCDD2C6C6464647,$686B9730EE21082D,$0A10838EB884246C,$36767766EBAE2247,$74F4F4D4A9523637,$0942108924949932,$DD17959587DC4001
Data.q $84163AF55BAEBADD,$8E9D3A508455D5D5,$CB4D34CBABBC72CA,$8463184A102C04B2,$932652A54A91DF90,$29AE6E66F6DE7B69,$2DB0DEED53FF4612,$D341616164E4E4FB
Data.q $D56D96DA84A00034,$E7777AAC78294A2D,$8A28A7284A509417,$D264C967676779E7,$44C58B19BACC37B8,$9BCFB4D359659451,$9898912272E5D79B,$0180863189249098
Data.q $39730ED34D000030,$F0F8F00063C171D7,$2850A414F8383838,$C75C00083B6B8000,$25A5E583EF3B7F9D,$DDD4FF3E7C800000,$C99C7DF52947D7D7,$F9AE3ED68F0E8E64
Data.q $02C31A347AFAD3EC,$EFECDF24924D34D6,$E7830C36DEDEDFEF,$D7777772727AFC79,$181E5E5FBD249207,$5145318C70081978,$3D80C5BAACA6A6A6,$1CB007C710843518
Data.q $5378F1E34747A58B,$F5EDE89333333428,$CB29A6EA7A7A7B87,$B2FFDE2AFAFF9232,$3BDB67676617CF9F,$F3C03D75D75D75DA,$AD5AB8F8F8F870E1,$12108DB6DA767476
Data.q $01630E2118C05145,$90A6A119A8C3351B,$2040803228A2DB65,$5E79E528F06C10D0,$34D1F4A3D8C798C0,$7B7B434343C4D34D,$7FCDCD238786AF7B,$EBA2D5145D2CBE9E
Data.q $542F2E2E3FE7E738,$182A54AABABABD55,$639A6BBED5AB5421,$9BD3D3D3C58ADFDB,$5CB975FAB7B7379F,$88AD3E2E2DDE54A9,$3200BFADADADA346,$00547111FC196A6E
Data.q $AE444E4549000000
Data.b $42,$60,$82
ImageBtChartLyrics_Fin: ;}
EndDataSection
;}