-
-
Save rornor/e8adee2d94cac17840b3 to your computer and use it in GitHub Desktop.
Full last.fm bio with txt caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
folder = "C:\Temp" | |
On Error resume Next | |
With CreateObject("ADODB.Stream") | |
.Open | |
.Type = 2 | |
.Charset = "utf-8" | |
.LoadFromFile folder & "\" & WScript.Arguments.Item(0) & ".txt" | |
If Len(.Size) > 1 Then | |
WScript.Echo .ReadText | |
.Close | |
Else | |
.WriteText WScript.Arguments.Item(0) | |
.Flush | |
.Position = 0 | |
.Type = 1 | |
.Read = 3 | |
For i = 1 To .Size-3 | |
param = param & "%" & Hex(AscB(.Read(1))) | |
Next | |
.Close | |
Set xml = CreateObject("MSXML2.DOMDocument.6.0") : xml.async = False | |
xml.load("http://developer.echonest.com/api/v4/artist/biographies?api_key=PKDMY7Z0SGFBW" & UCase(Right("denial", 4)) & "&license=cc-by-sa&format=xml&name=" & param) | |
bio = xml.selectSingleNode("/response/biographies/biography/text[../site='last.fm']").text | |
If Len(bio) Then | |
bio = Replace(Replace(bio, ". ", "." & vbCrLf & vbCrLf), ". ", "." & vbCrLf & vbCrLf) | |
.Open | |
.Type = 2 | |
.Position = 0 | |
.Charset = "utf-8" | |
.WriteText bio | |
.SaveToFile folder & "\" & WScript.Arguments.Item(0) & ".txt" | |
.Close | |
WScript.Echo bio | |
End If | |
End If | |
End With |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version without text caching can be found here: https://gist.github.com/aa2ada8bdc93144abd03