View Single Post
  #1  
Old Jun 13, 2010, 08:39 AM
the_miker's Avatar
the_miker the_miker is offline
Senior Member
 
Join Date: Nov 2007
Posts: 191
Default Album Art Downloader - VGMdb Source Script?

I just downloaded a nifty little open source app for Windows called Album Art Downloader. It's an easy-to-use program that lets you, yeah you guessed it, download album art for all your digital music files. You can either search manually or it can scan a specific music folder or your foobar2000 library/playlists for albums that are missing artwork. Not only that, but this thing lets you write custom search scripts so you can basically use any searchable web site as a source for the artwork. Guess what I'm gonna ask next? I need to know if it's possible for someone to write a script so we can use VGMdb as an artwork source within the program.

Here's a sample of one of the search scripts (for some site called MusicMight). Can anyone decipher how it's getting the search results and displaying them within the program? This would be so epic if someone got this to work.

Code:
import System
import System.Text.RegularExpressions
import AlbumArtDownloader.Scripts
import util

class MusicMight(AlbumArtDownloader.Scripts.IScript):
	Name as string:
		get: return "MusicMight"
	Version as string:
		get: return "0.3"
	Author as string:
		get: return "Alex Vallat"
	def Search(artist as string, album as string, results as IScriptResults):
		if String.IsNullOrEmpty(album):
			return //Only searching on album is supported

		album = StripCharacters("&.'\";:?!", album)
			
		//Retrieve the search results page
		searchResultsHtml as string = GetPage("http://www.musicmight.com/search?t=recording&q=" + EncodeUrl(album))
		
		matches = Regex("<a\\s[^>]*?href\\s*=\\s*'(?<url>[^']+)'[^>]*?>\\s*<img\\s[^>]+?src\\s*=\\s*'http://s3\\.amazonaws\\.com//mmimagesm/(?<img>[^']+)'[^>]*?>(?<title>.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Matches(searchResultsHtml)
		
		if matches.Count == 0: //Try single page result
			matches = Regex("\"http://s3\\.amazonaws\\.com//mmimagelg/(?<img>[^\"]+)\"[^>]*?>.*?<h4><span id=\"artistTitle\">(?:(?:<[^>4]+>)(?<title>[^<]+)?)+</h4>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Matches(searchResultsHtml)
		
		results.EstimatedCount = matches.Count
		
		for match as Match in matches:
			img = match.Groups["img"].Value
			title = ""
			for capture as Capture in match.Groups["title"].Captures:
				title += capture.Value
			title = title.Replace("<br />", "").Replace("</a>", "").Replace("&bull;", "-");

			url as string = null
			if match.Groups["url"].Success:
				url = "http://www.musicmight.com" + match.Groups["url"].Value
			
			results.Add("http://s3.amazonaws.com//mmimagesm/" + img, title, url, -1, -1, "http://s3.amazonaws.com//mmimagelg/" + img, CoverType.Front);

	def RetrieveFullSizeImage(fullSizeCallbackParameter):
		return fullSizeCallbackParameter;
Basically it looks like it goes to the search page http://vgmdb.net/search?q=blah and then parses out the results using Regex. Once that Regex line kicks in, that's where I get lost, haha. Maybe this is best for someone with Regex experience?

Here's an example of the search results within the program itself. These results here are kinda questionable and pretty unorganized since I had every search site selected. If we were to just use VGMdb for this same search, these results would be immaculate. Note that you can either have the program show you these results and then you save each one manually OR it can just save the first result (for each type.. front, back, disc, etc) automatically in the folder you choose:



So yeah, if anyone can figure something out, that would be awesome. I'd be willing to beta test and possibly donate a coffee or three to anyone willing to take a stab at this.
Reply With Quote