Categories: Misc / DotNet / Java / Coder / Linux / PHP Ask - La ask - La Answer

Artwork Assistance

Well, my skills in Applescript are now a little better. Thanks everyone for the help with the strings, Cocoa and Applescript do work nicely together, but in that instance Cocoa managed to forget what an array was...even though its a programmed function. Whoops?

Anyways, I have been doing stuff like retrieving artwork from iTunes and saving it to disk so my Cocoa apps can handle it. I was wondering, how would you go about using Applescript to add artwork to tracks?

For instance, I have my Cocoa app reading data from Amazon and saving the resulting artwork cover to the hard drive. I know that I have to set this image to a data variable and then tell iTunes to add that artwork for the selected song...just wondering how to go about the first part...

Also, the file is in TIFF format, would this be an issue with iTunes at all? I know I retrieve files as pict from iTunes when saving to disk.

Thanks again for your help,

Mat
[974 byte] By [mj_1903] at [2007-11-9 14:30:09]
# 1 Re: Artwork Assistance
Have a look at the section on artwork on this page ( http://www.malcolmadams.com/itunes/itinfo/itunes4info.shtml).
Doug Adams at 2007-11-15 17:25:06 >
# 2 Re: Artwork Assistance
Looking for some canned open source code of this nature -- get artwork from amazon, save to mp3 file. surely someone's gotta have this canned by now.
WoodenBrain at 2007-11-15 17:26:06 >
# 3 Re: Artwork Assistance
Does it need to be Amazon ? there are a few search scripts on Dougs site and one for adding pdfs to tracks.. a quick bit of cut and paste and you're sorted :D

http://www.dougscripts.com/itunes/scripts/scripts11.php?page=1#musicoutfittersearch

http://www.dougscripts.com/itunes/scripts/scripts11.php?page=1#findalbumartwork

http://www.dougscripts.com/itunes/scripts/scripts11.php?page=1#searchslothradio

and

http://www.dougscripts.com/itunes/scripts/scripts07.php?page=2#pdfadder
deeg at 2007-11-15 17:27:05 >
# 4 Re: Artwork Assistance
i know i can piece something together from here and there, i just want something canned that get's one and only one matching image from somewhere on the internet, preferably amazon, but i guess if it were reliable then anywhere. i don't want it to open in safari or anything of the sort. i just want a url to an image, and a routine to make the image into picture data.

don't wanna spend forever on it!
WoodenBrain at 2007-11-15 17:28:12 >
# 5 Re: Artwork Assistance
well what do you know... spent last night coding something up.. got as far as retrieving the image urls via Amazon Web services and started hunting for an xml parser.. anyway, while surfing i came across a link for XMLTools.. which inturn linked to "Get Amazon Pix" available here...

http://www.dougscripts.com/itunes/scripts/scripts11.php?page=1#getamazonpix

does the entire net end up back at Doug's site ? :confused:

have not tried Greg's script but it appears to do what you want and more so..
deeg at 2007-11-15 17:29:11 >
# 6 Re: Artwork Assistance
"The Web Site at The End of the Universe" :D
Doug Adams at 2007-11-15 17:30:10 >
# 7 Re: Artwork Assistance
I just get all of my artwork by right clicking and saving picture as from play.com and if i cant find it there i use google image. Simple enough for me.
awmajic at 2007-11-15 17:31:14 >
# 8 Re: Artwork Assistance
Deeg, thanks a lot. Somehow I missed that, I was searching for "art" and "artwork" not "pix" or "amazon" on doug's site. I knew there was something out there. unfortunately, it's a lot more complicated than I thought it would be-- I need it to be fast. I'm trying to put it into the new <a href="http://www.versiontracker.com/dyn/moreinfo/macosx/27109">salling clicker controller I just released version 1.0 of.</a>. It can only take a 3 or 4 seconds to grab a picture or it would be useless. perhaps i can find a way to cache pictures for upcoming tracks. Anyway that's a good start. Thanks.

(It does appear to be outdated though--the developer tolken thing is no longer called that--they appear to be called associates or something. anyone know anything about that? i hate having to read legaleese. if i'm developing an application can i use my developer tolken for what i distribute? it looks like most scripts and such require you to sign up for your own developer tolken).
WoodenBrain at 2007-11-15 17:32:17 >
# 9 Re: Artwork Assistance
I am continuing with my coding, I'm using a curl'd REST query rather than a SOAP call that Greg uses.. don't know enough about either method to say which one is faster but REST looked easier :) Also trying to avoid the osax requirement if possible. I'll post back with an example for you to play with.. If this is ending up being used in Salling would you prefer the small image being retrieved rather than the larger ones if they exist ? the small ones are 75x75, medium are 160x160, large 300x300 ?

i think you can use your dev id in your app.. i did not read the legalise either but i have not had to get a dev id for other apps i have tried such as "iTunes catalog".
deeg at 2007-11-15 17:33:14 >
# 10 Re: Artwork Assistance
Originally posted by deeg
[B]If this is ending up being used in Salling would you prefer the small image being retrieved rather than the larger ones if they exist ? the small ones are 75x75, medium are 160x160, large 300x300 ?

hmm i'm not sure about that. definitely the small one for the purposes of sending it to the device and network speed, but i was also thinking about the option of copying to the track and / or the album tags (by command), in which case the 300 size ones better. actually over bluetooth the size wouldn't matter much. the network connection is probably the limiting factor. wouldn't it be a matter of changing a line in the code? for now i'd include all 3 options and comment out the others.

have you checked out my salling controller yet? it already uses the cache files for Clutter and iTunes Catalog, so right now i'm thinking if people want more artwork on their bluetooth device, run clutter or ITC. but if you/me can do it super fast, maybe do it via scripting.

thaks for the effort, deeg.
WoodenBrain at 2007-11-15 17:34:12 >
# 11 Re: Artwork Assistance
heres something to play with... not finished yet, itunes is throwing a -116 error when i try to add the artwork to it...note it currently creates an image file on the desktop for each retrieved image.. am looking into keeping it all internal to the script or if not you can change the default path to the Application Helper file in ~/library or some such.. you'll need to add your aws subscription id where specified...yet to add the store location selector for various regional amazon stores..

global theCurrentTrack

tell application "iTunes"
set theCurrentTrack to current track
tell theCurrentTrack to copy {artist, album} to {theArtist, theTitle}
end tell
my amazon_Search(theArtist, theTitle)

-- do a rest requet via curl to Amazon Web services for artist and Album of playing track
on amazon_Search(theiTunesArtist, theiTunesTitle)
-- construct theArtist
set theArtist to my encode_text(theiTunesArtist, true, true)

--construct the title
set theTitle to my encode_text(theiTunesTitle, true, true)

-- Define parts of the REST request.
set theSubscriptionID to "INSERT YOUR SUBSCRIPTION ID HERE" -- (note: add an '&' to end of id)

-- Assemble the REST request URL.

set theRequest to "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=" & theSubscriptionID &
"Operation=ItemSearch" & "&Artist=" & theArtist & "&Title=" & theTitle & "&SearchIndex=Music&ResponseGroup=Images" as string

-- do the REST request via curl

set theResults to (do shell script "curl \"" & theRequest & "\" ") as Unicode text

-- Check the results

my process_the_Results(theResults, theiTunesArtist, theiTunesTitle)

end amazon_Search

-- subroutine for the results of the REST request it returns the FIRST small image, Medium Image, Large image URLS

on process_the_Results(theResults, theiTunesArtist, theiTunesTitle)
if theResults contains "We did not find any matches for your request" then
beep
else
set ourURLs to my xml_strip(theResults)
if item 1 of ourURLs is not "" then
set theSMallImage to my Download_the_image(item 1 of ourURLs, "SmallImage")
end if
if item 2 of ourURLs is not "" then
set theMediumImage to my Download_the_image(item 2 of ourURLs, "MediumImage")
end if
if item 3 of ourURLs is not "" then
set theLargeImage to my Download_the_image(item 3 of ourURLs, "largeImage")
set theImage to read theLargeImage as picture
tell application "iTunes"
if (count of artwork of theCurrentTrack) is 0 then
delay 5
tell theCurrentTrack
set data of artwork 1 to theImage
end tell
end if
end tell
end if
end if
end process_the_Results

-- subroutine to download the image to a holder...

on Download_the_image(theURL, theImageType)
set theFile to ((path to desktop) & theImageType & ".jpg") as string
tell application "Finder"
if file theFile exists then
set oldFile to true
else
set oldFile to false
end if
end tell
tell application "URL Access Scripting"
activate
set dlURL to theURL
try
if oldFile = true then
set x to download dlURL to file theFile replacing yes with progress
else
set x to download dlURL to file theFile with progress
end if
on error
set theFile to ""
end try
try
quit
end try
end tell

return theFile as alias
end Download_the_image

-- subroutine to process returns xml.. looking for SMALL,MEDIUM,LARGE image would be
--nice to use System Events but that appear to work on files only not variables...
--or i could not get it to work on a variable.. dont want to use an oasx either...

on xml_strip(the_xml)
set the_xml to the_xml as string
set theSmallURL to ""
set theMediumURL to ""
set theLargeURL to ""
set AppleScript's text item delimiters to return
repeat with b from 1 to count of text items of the_xml
set thisLine to text item b of the_xml
if thisLine contains "<SmallImage>" then
set theResult to my get_URL(thisLine, "<SmallImage><URL>", "</URL><Height>75")
if theResult is not "" then
set theSmallURL to theResult
set theResult to ""
end if
end if
if thisLine contains "<MediumImage>" then
set theResult to my get_URL(thisLine, "<MediumImage><URL>", "</URL><Height>160")
if theResult is not "" then
set theMediumURL to theResult
set theResult to ""
end if
end if
if thisLine contains "<LargeImage>" then
set theResult to my get_URL(thisLine, "<LargeImage><URL>", "</URL><Height>300")
if theResult is not "" then
set theLargeURL to theResult
set theResult to ""
end if
end if
end repeat
set AppleScript's text item delimiters to {""}
return {theSmallURL, theMediumURL, theLargeURL}
end xml_strip

-- Subroutine to strip data from a string

on get_URL(the_string, start_delim, end_delim)
set offset_start to (offset of start_delim in the_string) + (count of characters of start_delim)
set offset_end to (offset of end_delim in the_string) - 1
return text offset_start thru offset_end of the_string
end get_URL

-- this sub-routine is used to encode a character and is available at http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.10.htm
on encode_char(this_char)
set the ASCII_num to (the ASCII number this_char)
set the hex_list to
{"0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "A", "B", "C", "D", "E", "F"}
set x to item ((ASCII_num div 16) + 1) of the hex_list
set y to item ((ASCII_num mod 16) + 1) of the hex_list
return ("%" & x & y) as string
end encode_char

-- this sub-routine is used to encode a text string and is available at http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.10.htm

on encode_text(this_text, encode_URL_A, encode_URL_B)
set the standard_characters to
"abcdefghijklmnopqrstuvwxyz0123456789"
set the URL_A_chars to "$+!'/?;&@=#%><{}[]\"~`^\\|*"
set the URL_B_chars to ".-_:"
set the acceptable_characters to the standard_characters
if encode_URL_A is false then
set the acceptable_characters to
the acceptable_characters & the URL_A_chars
if encode_URL_B is false then
set the acceptable_characters to
the acceptable_characters & the URL_B_chars
set the encoded_text to ""
repeat with this_char in this_text
if this_char is in the acceptable_characters then
set the encoded_text to
(the encoded_text & this_char)
else
set the encoded_text to
(the encoded_text & encode_char(this_char)) as string
end if
end repeat
return the encoded_text
end encode_text
deeg at 2007-11-15 17:35:10 >
# 12 Re: Artwork Assistance
deeg, thanks a lot. i will check this out soon.
WoodenBrain at 2007-11-15 17:36:18 >
# 13 Re: Artwork Assistance
check this thread... looks like you have to save it as a pict first and then read from 513... but there should be a way to avoid having to resave the .jpg file as pict first, I think.

http://forums.ipodlounge.com/showthread.php?s=&threadid=96368&highlight=artwork
WoodenBrain at 2007-11-15 17:37:14 >
# 14 Re: Artwork Assistance
hey what happened to the normal post rely button, and to the edit buttons? sorry for 3 posts in a row.

indeed, the following works. i wish saving as a pict first could be avoided though. It takes about 10 seconds. I also have to think of a way around that AWS problem. What a pain to make people have to sign up. Either I have to use my own in distribution, or have to make a pref file or something.

if item 3 of ourURLs is not "" then
set theLargeImage to my Download_the_image(item 3 of ourURLs, "largeImage")
tell application "Image Events"
launch
set the_image to open theLargeImage
save the_image as PICT in ((path to desktop) & "largeImage" & ".pict" as string)
close the_image
end tell
tell application "iTunes"
set the_artwork to read alias ((path to desktop) & "largeImage" & ".pict" as string) from 513 as picture
set data of artwork 1 of current track to the_artwork
end tell
set theImage to read theLargeImage from 513 as picture
tell application "iTunes"
if (count of artwork of theCurrentTrack) is 0 then
delay 5
tell theCurrentTrack
--set data of artwork 1 to (theImage as picture)
--read (alias this_image) as picture
set data of artwork 1 to theImage
end tell
end if
end tell
end if
WoodenBrain at 2007-11-15 17:38:22 >
# 15 Re: Artwork Assistance
here's #4.

I noticed in the source code for a sloth radio search there are direct URLs to amazon. I wonder if there is a good way to parse any of this? that way the whole AWS problem could be avoided.

<!-- RESULT LIST START -->

<!-- RESULT ITEM START -->
<table class="albumbox2"><tr><td width="305" valign="top">No image found. <a href="http://images.google.com/images?q=Fermin+Muguruza+Brigdistak+Sound+System">Google for "Brigdistak Sound System".</a><img src="" width="1" height="1" /></td><td valign="top"><table><tr><td align="right"><b>Artist:</b></td><td>Fermin Muguruza</td></tr><tr><td align="right"><b>Album:</b></td><td>Brigdistak Sound System</td></tr><tr><td align="right"><b>Year: </b></td><td>2002</td></tr><tr><td align="right"><b>Used: </b></td><td>$9.99</td></tr></table><br /><center><a href="http://www.amazon.com/exec/obidos/ASIN/B00005O84Y/ivorytower-20?dev-t=D2AAJ98P9F66IB%26camp=2025%26link_code=xm2"><img src="buy5.gif" width="120" height="28" border="0" /></a></center></td></tr></table>
<!-- RESULT ITEM END -->

<!-- RESULT ITEM START -->
<table class="albumbox2"><tr><td width="305" valign="top"><img src="http://images.amazon.com/images/P/B000063695.01.LZZZZZZZ.jpg" width="300" height="294" /></td><td valign="top"><table><tr><td align="right"><b>Artist:</b></td><td>Ferm
WoodenBrain at 2007-11-15 17:39:14 >
# 16 Re: Artwork Assistance
and one more thing...

take a look at the "AlbumArt" tiger widget. inside the package there is a java script file called AlbumArtAmazon. In that there's a nice juicey AWS ID.

Still the better "legal" way would be to parse those Sloth Radio results. The problem I see right off is all the " (quotes). How do you even get that as a string in AppleScript with all the quotes in there?
WoodenBrain at 2007-11-15 17:40:25 >
# 17 Re: Artwork Assistance
no worries about the number of posts..

the edit/post buttons got pushed to the right due to my comments in the code, have altered the long one to three lines to bring the forum buttons back on screen..

thanks for the link to the fix for -116 error.. noticed in your code that you appear to add the image twice.. is that intended or an error..

interesting about the sloth radio thing... what's the benefit of going to them and searching compared to AWS itself ? is it to avoid the AWS subscription ? i think you can just include your own subscription id in the App.. it would be pointless of Amazon to require every end user of any web service to get their own personal subscription.
if you do go the slot radio way could you not just read the whole source in, the same way Doug does in his http://www.dougscripts.com/itunes/scripts/scripts11.php?page=1#cddbsafarikit ?

also since we have the pict image on the Mac already, the delay 5 can be removed from the section that add's the artwork to the track..from running it a few times, most of the delay appears to be iTunes adding the artwork rather than Image events converting the file so i think you would have the delay regardless of the format you obtain/download the file in..Do you also get stuttering playback in itunes when adding the image ?
deeg at 2007-11-15 17:41:22 >
# 18 Re: Artwork Assistance
what do you mean add the image twice? unless you include the lines I was trying that I commented out there.

what's irritating is you have download and save to disk as a jpg, read it back, write it back to a pict, read the pict, and finally write (a portion of the pict) out to the id3 tags.

it should be possible to do all, or almost all, of that in memory, don't you think?

regarding the sloth radio, the benefit is indeed to avoid the subscription. I'm not so sure that it would be within the terms of the AWS license to use their images in this way. Clearly they are aiming to get people to put their content on their web pages for click-through sales. Now whether it is technically illegal or not, or violates their license, or whatever, I don't know without a lawyer. But I did scan the agreement enough to get that "sense". I'm sure a lot of people use it for "other purposes" but I don't know what it would take to get them to notice. My guess is it would depend on how "popular" your application (that you included your AWS tolkein in) became.

Thus, I think if possible to bypass that it would be better. Nothing says you can't access their publicly accessable URLs, no matter how you get them.

ANyway, I don't intend to tear my hair out over it, but I took a couple of brief stabs--so far unsuccessful at parsing the sloth stuff.

reading the source does not seem to work unless you download the URL and then open it in safari first (getting the source from the document window and not the file).

if you use url access scripting to download the file, then I thought you could use read ... using delimiters to get the records, then it would be a simple matter of getting the first record that had "amazon" in it and extracting the URL (don't know how to do that either... just wanted to get the record first...)

but for some reason, this doesn't do anything like what I expect:
(to test, download the results of a slothradio seach and save on desktop with name "sloth.html" (as .html source of course)

set tempdir to (path to desktop) as string
set theFile to open for access (tempdir & "sloth.html") as alias
set therecs to read theFile using delimiter {("<!-- RESULT ITEM START -->" & return), ("<!-- RESULT ITEM END -->" & return)}
--{"RESULT ITEM START", "RESULT ITEM END"}
--{"start", "end"}
close access theFile

return therecs

as for the stuttering playback, yes, if you add art to a file playing, or for that matter even change the ID3 tags, it will tend to do that.

For that reason it might be prudent to get the index of the track, and do the operation of the next track to play.

my idea at this point is to do something like that and save the image in either a) a cache file location compatible with "Clutter" (whose cache files my salling clicker app is already using), or b) the album folder. I'm inclined to do the latter, but I don't know how many people would object to having a script populate their music folders with .jpgs. for me it would be desirable and would save more space in the end than adding artwork.

at some point i need to post my geek tool script that puts track info and a picture on the desktop, but it is sort of a pro-user sorta thing, but works really well for me.

PS: anyone know off hand how to test whether we have an internet connection and how fast it is?

PPS: my console log is showing URL Access Scripting repeatedly crashing when running this script (or my version of it which is almost the same -- I think I commented out the Try..quit..end try part in that routine; why would you want to quit URL Access Scripting each call?)

PPPS:

there's are a couple of threads about artwork going on on macscripter:

http://bbs.applescript.net/viewtopic.php?id=13020
WoodenBrain at 2007-11-15 17:42:18 >
# 19 Re: Artwork Assistance
sorry, it was not setting the image but reading it in..

this will get the image url from sloths results, the search URL is constructed as per doug's
http://www.dougscripts.com/itunes/scripts/scripts11.php?page=1#searchslothradio

to open_location(theURL)
set theResults to (do shell script "curl \"" & theURL & "\" ") as Unicode text
my parse_the_results(theResults)
end open_location

on parse_the_results(theResults)
set theResults to theResults as string
set AppleScript's text item delimiters to return
repeat with b from 1 to count of text items of theResults
set thisLine to text item b of theResults
if thisLine contains "//images.amazon.com" then
set theResult to my get_URL(thisLine, "width=\"305\" valign=\"top\"><img src=\"", " width=\"300\" height=\"300\" />")
end if
end repeat
set AppleScript's text item delimiters to {""}
log (theResult)

end parse_the_results

-- Subroutine to strip data from a string

on get_URL(the_string, start_delim, end_delim)
set offset_start to (offset of start_delim in the_string) + (count of characters of start_delim)
set offset_end to (offset of end_delim in the_string) - 2
return text offset_start thru offset_end of the_string
end get_URL
deeg at 2007-11-15 17:43:26 >
# 20 Re: Artwork Assistance
Not for nothin', but wouldn't it be faster to do a sed or perl matching search on all that text (as we had discussed prev, deeg)? Going through each line could slow stuff up. Just a thought.
Doug Adams at 2007-11-15 17:44:24 >
# 21 Re: Artwork Assistance
probably but not if you factor in the time it would take me to learn Perl :) i look and i look and i look again at Perl code and it still looks like

qwert!!{}} {@*} yuizxcvb4356789vbnmi9@@@@

to me..

(thats probably the required code for all i know :) )

if you have a bit of code i could "learn from".. feel free to amend the code ;)
deeg at 2007-11-15 17:45:30 >
# 22 Re: Artwork Assistance
deeg,

there's a problem with your parsing code. i'm not sure images are always the height you think they are. this returns an invalid URL for the large image, because the the height is 475 rather than the expected 300.

edit: wah! this is why i was originally looking for something canned... i didn't want to spend an hour let alone more than a day on this! :(

I tried just changing the end value in the xml strip subroutine to </url><height> without the value, but I realized that it needs to be unique. the "offset in" command on a string only returns the first value of the match. I thought there would be a way to get a LIST of matches, but I don't think so, not without osax, at least.

here's something from my library of subroutines that works on lists, but not strings.

set tlist to {"hi", "there", "you", "cow"}
set kj to choose from list tlist
set offs to list_positions(tlist, (item 1 of kj), false)

return offs

on list_positions(this_list, this_item, list_all)
set the offset_list to {}
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then
set the end of the offset_list to i
if list_all is false then return item 1 of offset_list
end if
end repeat
if list_all is false and offset_list is {} then return 0
return the offset_list
end list_positions

---- xml code that doesn't get the large image --

<?xml version="1.0" encoding="UTF-8"?><ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-03-23"><OperationRequest>
<HTTPHeaders><Header Name="UserAgent" Value="Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412"></Header>
</HTTPHeaders>
<RequestId>0BBARXXXXXTSXZZXXXX</RequestId><Arguments><Argument Name="Service" Value="AWSECommerceService"></Argument>
<Argument Name="Title" Value="Fight Back!">
</Argument><Argument Name="SearchIndex" Value="Music"></Argument>
<Argument Name="Artist" Value="Icy Demons"></Argument><Argument Name="SubscriptionId" Value="0RP8XXXXXX3EEEEE82"></Argument>
<Argument Name="ResponseGroup" Value="Images"></Argument><Argument Name="Operation" Value="ItemSearch"></Argument></Arguments><RequestProcessingTime>0.01633620262146</RequestProcessingTime>
</OperationRequest><Items><Request><IsValid>True</IsValid><ItemSearchRequest><Artist>Icy Demons</Artist>
<ResponseGroup>Images</ResponseGroup>
<SearchIndex>Music</SearchIndex>
<Title>Fight Back!</Title></ItemSearchRequest></Request><TotalResults>1</TotalResults><TotalPages>1</TotalPages><Item><ASIN>B0001TSWEQ</ASIN>
<SmallImage><URL>http://images.amazon.com/images/P/B0001TSWEQ.01._SCTHUMBZZZ_.jpg</URL><Height>75</Height><Width>75</Width></SmallImage>
<MediumImage><URL>http://images.amazon.com/images/P/B0001TSWEQ.01._SCMZZZZZZZ_.jpg</URL><Height>160</Height><Width>160</Width></MediumImage>
<LargeImage><URL>http://images.amazon.com/images/P/B0001TSWEQ.01._SCLZZZZZZZ_.jpg</URL><Height>475</Height><Width>475</Width>
</LargeImage></Item></Items></ItemSearchResponse>

---
edit2: for now I've solved the problem like this... since i really only want one picture, i just get the largest picture that works.

repeat with p from 3 to 1 by -1
if item p of ourURLs is not "" then
set theFile to my Download_the_image(item p of ourURLs, theFilePath)
if theFile is not "" then
tell application "Finder"
set name of (theFile as alias) to pixn
end tell
end if
exit repeat
end if
end repeat

...

and in the xml routine, check to make sure the url ends in ".jpg":

if thisLine contains "<LargeImage>" then
set theResult to my get_URL(thisLine, "<LargeImage><URL>", "</URL><Height>300")
if theResult is not "" and theResult ends with ".jpg" then
set theLargeURL to theResult
set theResult to ""
end if
end if

--

deeg, can you pm your e-mail, i'll send you what i'm working on here, for use with geek tool. (have two purposes, first geek tool second for salling clicker..)
WoodenBrain at 2007-11-15 17:46:29 >
# 23 Re: Artwork Assistance
will pm my address...

re the variable image size.. thats easy to fix.. instead of considering the whole xml file, you can take a substring of it starting at either <smallimage>,<mediumimage> or <largeimage> and then the rest of the xml.. you can then search for </url> and get its offset in the substring of xml rather than the whole text...

on xml_strip(the_xml)
set the_xml to the_xml as string
set theSmallURL to ""
set theMediumURL to ""
set theLargeURL to ""
set AppleScript's text item delimiters to return
repeat with b from 1 to count of text items of the_xml
set thisLine to text item b of the_xml
if thisLine contains "<SmallImage>" then
set theResult to my get_URL(thisLine, "<SmallImage><URL>", "</URL>")
if theResult is not "" then
set theSmallURL to theResult
set theResult to ""
end if
end if
if thisLine contains "<MediumImage>" then
set theResult to my get_URL(thisLine, "<MediumImage><URL>", "</URL>")
if theResult is not "" then
set theMediumURL to theResult
set theResult to ""
end if
end if
if thisLine contains "<LargeImage>" then
set theResult to my get_URL(thisLine, "<LargeImage><URL>", "</URL>")
if theResult is not "" then
set theLargeURL to theResult
set theResult to ""
end if
end if
end repeat
set AppleScript's text item delimiters to {""}
return {theSmallURL, theMediumURL, theLargeURL}
end xml_strip

-- Subroutine to strip data from a string

on get_URL(the_string, start_delim, end_delim)
set offset_start to (offset of start_delim in the_string) + (count of characters of start_delim)
set intertext to text offset_start thru (count of characters of the_string) of the_string
set offset_end to (offset of end_delim in intertext) - 1
return text 1 thru offset_end of intertext
end get_URL

ps.. i have reformatted your post with a few 'returns' in the xml.. its forcing the window size off my 15" screen..
deeg at 2007-11-15 17:47:31 >
[an error occurred while processing this directive]
[an error occurred while processing this directive]