Dynamically exclude multiple genres when getting albums from iTunes

hello!

So, i’m writing a somewhat-complex playlist generator for myself (sorta as an excuse to learn Applescript) and I’ve come across an issue I’m having trouble getting over:

set albumList to album of file tracks of library playlist 1 whose podcast is false and bookmarkable is false and genre is not in excludedGenres

Now, excludedGenres is a list of genres that the user selected from a dialog before the step described above. The code snippet above does not work because you can only do

genre is not "SomeGenre"

(a single value), and I’m wanting to do it for a whole list of values that are user-supplied.

Can anybody help me out with this? Is there a simple solution I’m just missing?

Thanks in advance!

[Edit]
Just to show that I’m actually trying to get this working and not just giving up too easily, I tried doing this:

on buildMasterAlbumListExpression(excludedGenres)
	set ret to "set albumList to album of file tracks of library playlist 1 whose podcast is false and bookmarkable is false "
	repeat with g in excludedGenres
		set ret to ret & "and genre is not '" & g & "' "
	end repeat
	return ret
end buildMasterAlbumListExpression

I was hoping to do use that function and do something like this:

set albumList to (run script my buildMasterAlbumListExpression(excludedGenres))

But that also gives an error :\

Hi,

try this


buildMasterAlbumListExpression(excludedGenres)

on buildMasterAlbumListExpression(excludedGenres)
	set ret to "tell application \"iTunes\" to set albumList to album of file tracks of library playlist 1 whose podcast is false and bookmarkable is false "
	repeat with g in excludedGenres
		set ret to ret & "and genre is not \"" & g & "\" "
	end repeat
	run script ret
end buildMasterAlbumListExpression