Grabs chart listing from Last.FM and attempts to enqueue the songs if they are in your Media Library. Requires your tags be nicely formatted. Use MusicBrainz to get your music correctly tagged.

dim xmlhttp, mlq, dict1
dim regEx, regEx2, Match, Matches, Matches2   ' Create variable.
 
Function RegExpAdd(patrn, strng)
   
	Set regEx = New RegExp   ' Create a regular expression.
	Set regEx2 = New RegExp   ' Create a regular expression.
	
	regEx.Pattern = patrn   ' Set pattern.
	regEx.IgnoreCase = True   ' Set case insensitivity.
	regEx.Global = True   ' Set global applicability.
	
	Set Matches = regEx.Execute(strng)   ' Execute search.
	songnum = 1
	For Each Match in Matches   ' Iterate Matches collection.
		'Find song title within URL
		regEx2.Pattern = ">.*<"
		regEx2.IgnoreCase = True   ' Set case insensitivity.
		 	
		Set Matches2 = regEx2.Execute(Match.Value)
		songtitle = Matches2(0).Value
		songtitle = Right(songtitle, Len(songtitle) - 1)
		songtitle = Left(songtitle, Len(songtitle) - 1)
 
		idx = dict1(songtitle)
		If (idx > 0) Then
			mlq(idx).enqueue
		Else
			LoadItem("x:\(missing) " + songtitle).enqueue
		End If
		If songnum = 50 Then
			Quit
		Else
			songnum = songnum + 1
		End If
	Next
 
End Function
 
Set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP.4.0")
 
'Substitute for http://www.last.fm/tag/rock or other genre to 
'get a specific genre chart listing
xmlhttp.Open "GET", "http://www.last.fm/charts/track", false
xmlhttp.Send
res = xmlhttp.responsetext
Set Dict1 = CreateObject("Scripting.dictionary")
Dict1.CompareMode = 1
mlq = MediaLibrary.RunQueryArray("")
	
i = 1
For each song in mlq
	dict1(song.artist + " - " + song.title) = i
	i = i + 1
Next
 
RegExpAdd "/music/.*/_/.*>.*</a", res
 
Quit
 
examples/webservice/last.fm_query_top_tracks.txt · Last modified: 2006/11/06 15:45
 
Recent changes RSS feed Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Music Plugins