Ok, so I was messing around and I made something that launches the video you enter. It opens the first result that would come up if you were to search for it on youtube. It’s very simple, but I plan to expand on it. Feel free to leave comments, constructive criticism
Thanks!
-- youLaunch - A youtube video searcher
try
getVidTitle()
replacePlusAndQuotes(theVid)
findURL(newVid)
openURL(idCode)
on error
display dialog " Thanks for using youLaunch!" buttons {"OK"} default button 1
end try
on getVidTitle()
display dialog "Enter the video's name:" default answer "video name" buttons {"Quit", "OK"} default button 2
set theResult to result
if button returned of theResult is "Quit" then
ImExitingRightNowCuzThisIsntDefined
end if
global theVid
set theVid to text returned of theResult
end getVidTitle
on replacePlusAndQuotes(theVid)
global newVid
set newVid to ""
repeat until number of characters in theVid = 1
set thisLetter to character 1 of theVid
if thisLetter is " " then
set thisLetter to "+"
end if
if thisLetter is "'" then
set thisLetter to ""
end if
set newVid to newVid & thisLetter
set theVid to text 2 thru end of theVid
end repeat
if theVid is " " then
set theVid to "+"
end if
if thisLetter is "'" then
set thisLetter to ""
end if
set newVid to newVid & theVid
end replacePlusAndQuotes
on findURL(newVid)
global idCode
set theYoutubeHTML to "http://www.youtube.com/results?search_query=" & newVid
set theCode to do shell script ("curl " & theYoutubeHTML) without altering line endings
set idCode to text ((offset of "<h3><a href=\"" in theCode) + 13) thru end of theCode
set idCode to text 1 thru ((offset of "\"" in idCode) - 1) of idCode
end findURL
on openURL(idCode)
open location ("http://www.youtube.com" & idCode)
end openURL
Model: Macbook
Browser: Safari 533.21.1
Operating System: Mac OS X (10.6)