#!/usr/bin/osascript

on run argv
	set filepath to item 1 of argv

	tell application "iTunes"
		-- some constants
		set playlist_name to "Clipstart"
		set found_playlist to null
		
		-- find our playlist if it exists already
		repeat with one_playlist in playlists
			if name of one_playlist is equal to playlist_name then
				set found_playlist to one_playlist
			end if
		end repeat
		
		-- create new playlist if necessary
		if found_playlist is null then
			set found_playlist to make new playlist with properties {name:playlist_name}
		end if
		
		-- add video file to playlist
		add (filepath as POSIX file) to found_playlist
	end tell
end