Quick hack to scrape the Last.FM charts for a selected artist and enqueue the top songs in order, provided they are in your Media Library. -Shane.

dim xmlhttp, art, dict1, mlq
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.
	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)
		artname = Matches2(0).Value
		artname = Right(artname, Len(artname) - 1)
		artname = Left(artname, Len(artname) - 1)
		artname = Replace(artname, "_MERGESCRIPT", "")
		artname = Trim(artname)
		idx = dict1(artname)
		If (idx > 0) Then
			mlq(idx).enqueue
		End If
 
	Next
 
End Function
 
x = playlist.getselection
 
if ubound(x) > 0 then
	Set Dict1 = CreateObject("Scripting.dictionary")
	Dict1.CompareMode = 1
	art = x(1).artist
	mlq = medialibrary.runqueryarray("artist = """ & art & """")
 
	i = 1
	for each song in mlq
	 dict1(song.title) = i
	 i = i + 1
	next
 
	set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP.4.0")
	
	xmlhttp.Open "GET", "http://www.last.fm/music/" + art + "/+charts", false
	xmlhttp.Send
	
	res = xmlhttp.responsetext
	
	RegExpAdd ".*/music/.*/_/.*", res
 
end if
quit
 
examples/webservice/last.fm_query_top_tracks_for_an_artist.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