Skip to content

Instantly share code, notes, and snippets.

@rornor
Last active December 14, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rornor/e8adee2d94cac17840b3 to your computer and use it in GitHub Desktop.
Save rornor/e8adee2d94cac17840b3 to your computer and use it in GitHub Desktop.
Full last.fm bio with txt caching
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
@rornor
Copy link
Author

rornor commented Feb 25, 2013

Version without text caching can be found here: https://gist.github.com/aa2ada8bdc93144abd03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment