And to whoever was working on the Google script, the new iTunes script shows how the User-Agent can be faked.
I tried incorporating the useragent routine into the script but I am unable to get the script to even compile anymore. I am in well over my head with regards to this script and have no idea what I am doing anymore. If anyone else would like to take over or at the very least give me some direction on where to go from here, this is the current state of my code: ... ...
It was almost working, I've made a few changes, this seems to work perfectly:
namespace CoverSources
import System.Xml
import System.Drawing
import System.Text.RegularExpressions
import util
class GoogleImage:
static def GetPageSecret(url as string):
request as System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
request.UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
response = request.GetResponse()
return response.GetResponseStream()
static SourceName as string:
get: return "GoogleImage"
static SourceVersion as decimal:
get: return 0.2
static def GetThumbs(coverart,artist,album):
query = artist+" "+album
params = EncodeUrl(query)
params.Replace('%20','+')
textstream = GetPageSecret("http://images.google.com/images?q="+params)
text = System.IO.StreamReader(textstream).ReadToEnd()
r = Regex("""dyn\.Img\("([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)","([^"]*)"\)""")
iterator = r.Matches(text)
coverart.SetCountEstimate(iterator.Count)
for result as Match in iterator:
name=(result.Groups[7].Value.Replace("<b>","").Replace("</b>",""))
coverart.AddThumb("http://www.images.google.com/images?q=tbn:"+result.Groups[3].Value+result.Groups[4].Value,name,0,0,result.Groups[4].Value)
static def GetResult(param):
return param