Trying to create a YouTube uploader

Heres what I have so far. Where it has the keystrokes for user and pass you’ll have to enter your own cause I’m not giving away mine. :stuck_out_tongue:

One problem I’m getting to start is when it goes to the upload page, It leaves another window with the home page opened.

set youtubelogin to "http://www.youtube.com/login"
set youtubeupload to "http://www.youtube.com/upload"

tell application "Safari"
	activate
	open youtubelogin
	set URL of document 1 to youtubelogin
	--This subroutine makes sure the page has finished loading -- it expects the page to finish with the "</html"> tag
	my waitforload()
end tell

on waitforload()
	--check if page has loaded
	set loadflag to 0
	repeat until loadflag is 1
		delay 0.5
		tell application "Safari"
			set test_html to source of document 1
		end tell
		try
			set zarg to text ((count of characters in test_html) - 10) thru (count of characters in test_html) of test_html
			if "</html>" is in text ((count of characters in test_html) - 10) thru (count of characters in test_html) of test_html then
				set loadflag to 1
			end if
		end try
	end repeat
end waitforload

tell application "System Events"
	keystroke "MY USERNAME"
	keystroke tab
	keystroke "MY PASSWORD"
	key code 36
end tell

tell application "Safari"
	
	activate
	open youtubelogin
	set URL of document 1 to youtubeupload
	
	my waitforload()
end tell



So yeah when it gets to the upload page I want it to select the upload button. Then, the tricky part. I want applescript to display a browse in a dialog box where I can select a video file to upload. Then, I want dialog boxes where I can type the title, description, and tags and it will put them in the right place. And maybe if it’s possible, it would be great if it could display the progress in a dialog box, but I doubt that’s possible.