Applescript - GoogleAlbumArt V0.1

Discuss Max, an open source CD audio extractor and audio converter.
Post Reply
neil.baldwin
Posts: 23
Joined: Sun May 13, 2007 9:58 pm

Applescript - GoogleAlbumArt V0.1

Post by neil.baldwin » Wed Apr 09, 2008 2:00 pm

I created a little Applescript for when Max can't find album art via it's Amazon searches. It's hard coded to use Safari and assumes you already have the album information/tags present. It performs a basic search and displays the results in a new Safari window - from there you need to drag-and-drop the picture into the Album Art drawer manually but at least it saves having to type the album and artist name into Google :)

Feel free to use it if it's of any use, or modify it if you need to reform the URL that gets sent to Safari etc.

Put it in the same place as Steve's iTunes Meta Data script - ~/Library/Scripts/Applications/Max/

Neil

Code: Select all

-- GoogleAlbumArt
--
-- Applescript to search google images for album art.
--

tell application "Max"
	set maxdisk to document 1
	set ar to artist of maxdisk
	set al to title of maxdisk
	set comp to compilation of maxdisk
	
	--If compilation, blank out the artist to prevent searches on single artist name
	if (comp) then set ar to ""
	
	--Make string of all search words, " " seperator to help later
	set my_search to ar & " " & al
	
	--URL based on searching google images with Safari - you might need to form your own URL
	--depending on browser. URL is made in 3 parts
	--
	set my_url to "http://images.google.com/images?client=safari&rls=en-us&q="
	
	--add search terms to URL
	set search_words to length of words of my_search
	if search_words = 0 then
		return
	else if search_words = 1 then
		set my_url to my_url & my_search
	else
		repeat with i from 1 to search_words
			set my_url to my_url & (word i of my_search)
			if (i < search_words) then set my_url to my_url & "+"
		end repeat
	end if
	
	--form end of URL
	set my_url to my_url & "&ie=UTF-8&oe=UTF-8&um=1&sa=N&tab=wi"
	
	
end tell

tell application "Safari" to activate

tell application "Safari"
	make new document at end of documents
	set URL of document 1 to my_url
end tell


Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests