Du wolltest schon immer schnell nach Songtexten suchen? Ja? Dann genau das richtige für dich!
Im Beispiel könnt ihr eine Datei öffnen, die ID3 UDF von "Wayfarer" liegt dabei.
Und danke an prograndy für dessen urlencode Funktion
Die Grund Funktion:
Spoiler anzeigen
#include <String.au3>
#include <Array.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: _Lyrics_Search_Engine
; Description ...: Fast Songtext Search!
; Syntax ........: _Lyrics_Search_Engine($iSong, $iArtist, $oHTTP)
; Parameters ....:
; $iSong - The Title of the Song
; $iArtist - The Artist
; $oHTTP - Object Reference of an opened HTTP Connection
; Return values .:
; Success: The Songtext
; Failure: @ERROR
; -1: Not found
; -2: Couldn't get Array (Lyrics)
; -3: Couldn't get Array (Characters)
; -4: Couldn't convert Characters to String
; Author ........: StevenX (Stefan Blagojevic)
; ===============================================================================================================================
Func _Lyrics_Search_Engine($iSong,$iArtist,$oHTTP)
$iSong = _URIEncode($iSong)
$iArtist = _URIEncode($iArtist)
;~ GET URL READY PARAMETERS
;~ SEARCH AFTER LYRICS
$request = 'http://lyrics.wikia.com/api.php?artist='&$iArtist&'&song='&$iSong
$oHTTP.Open("GET", $request, False)
$oHTTP.Send()
$oReceived = $oHTTP.ResponseText
$sURL = _StringBetween($oReceived,'<li><strong>url: </strong>','</li><li><strong>page_namespace: </strong>0</li>')
;~ GET WHOLE LYRICS URL
If IsArray($sURL) = false Then
SetError(-1)
Return 0
EndIf
$oHTTP.Open("GET", $sURL[0], False)
$oHTTP.Send()
$oReceived = $oHTTP.ResponseText
$aData = _StringBetween($oReceived,'c()}:r.onload=c;s.parentNode.insertBefore(r,s)};}})();</script>','<!--')
If IsArray($aData) = false Then
SetError(-2)
Return 0
EndIf
$sData = StringReplace($aData[0],'<br />',' ')
$aCHR = _StringBetween($sData,'&#',';')
If IsArray($aCHR) = false Then
SetError(-3)
Return 0
EndIf
$sLyric = ""
[/autoit] [autoit][/autoit] [autoit]For $i = 0 to (UBound($aCHR) - 1)
[/autoit] [autoit][/autoit] [autoit]$sLyric = $sLyric & ChrW($aCHR[$i])
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit]If $sLyric = "" Then
SetError(-4)
Return 0
Else
Return($sLyric)
EndIf
EndFunc ;==> _Lyrics_Search_Engine
[/autoit] [autoit][/autoit] [autoit];~ Copyright: Prog@ndy
Func _URIEncode($sData)
; Prog@ndy
Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
Local $nChar
$sData=""
For $i = 1 To $aData[0]
; ConsoleWrite($aData[$i] & @CRLF)
$nChar = Asc($aData[$i])
Switch $nChar
Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
$sData &= $aData[$i]
Case 32
$sData &= "+"
Case Else
$sData &= "%" & Hex($nChar,2)
EndSwitch
Next
Return $sData
EndFunc
Im Dateianhang findet ihr alle Dateien
In der ZIP:
ID3_v3.4.au3
_Lyrics_Search_Engine-example.au3
_Lyrics_Search_Engine.au3
Steve