Skip to content

Instantly share code, notes, and snippets.

Created June 25, 2014 23:40
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kylemcdonald/f7c8f8c9267fe1b310a9 to your computer and use it in GitHub Desktop.
Records video from your webcam whenever you are visiting a specific site.
global targetDomain
global folderName
-- options
set targetDomain to ""
set folderName to (path to desktop as text) & "Dropcam"
-- main code
global recordingFile
global newMovieRecording
on startRecording(filePath)
set recordingFile to a reference to file filePath
tell application "QuickTime Player"
set newMovieRecording to new movie recording
tell newMovieRecording
end tell
end tell
end startRecording
on stopRecording()
tell application "QuickTime Player"
tell newMovieRecording
save newMovieRecording in recordingFile
close newMovieRecording
end tell
end tell
end stopRecording
on checkSite()
tell application "Google Chrome"
repeat with win in windows
set curUrl to URL of active tab of win
if curUrl contains targetDomain then
return true
end if
end repeat
return false
end tell
end checkSite
on getTimestamp(now)
set stamp to {¬
year of now, "-", ¬
month of now, "-", ¬
day of now, " ", ¬
hours of now, " ", ¬
minutes of now, " ", ¬
seconds of now}
return stamp as string
end getTimestamp
global moviePath
global recordingStatus
global startTime
set recordingStatus to false
on update()
set siteStatus to checkSite()
log siteStatus
if siteStatus then
if not recordingStatus then
set recordingStatus to true
set startTime to current date
set moviePath to folderName & ":" & getTimestamp(startTime)
log moviePath
startRecording(moviePath & ".mov")
end if
else if recordingStatus then
set recordingStatus to false
set duration to (current date) - startTime
set beforeName to moviePath & ".mov"
set afterName to getTimestamp(startTime) & " +" & duration & ".mov"
tell application "Finder"
set the name of file beforeName to afterName
end tell
end if
end update
-- infinite loop
delay 1
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment