Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 property HANDBRAKE_CLI : "~/bin/HandBrakeCLI"
- 2 property HANDBRAKE_PARAMETERS : " -O -I -f mp4 -e x264 -x level=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subq=6:no-fast-pskip=1 -b 1200 -2 -T -E faac -B 160 -R 48 -A English -w 704"
- 3 property TARGET_PATH : "Users/gtwibell/Movies/"
- 4 property TARGET_TYPE : ".mp4"
- 5 property SOURCE_TYPE : ".mpg"
- 6 property SHELL_SCRIPT_SUFFIX : " > /dev/null 2>&1 & "
- 7
- 8 on RecordingDone(recordingID)
- 9 tell application "EyeTV"
- 10 set new_recording_id to (recordingID as integer)
- 11 set new_recording to recording id new_recording_id
- 12 my export_recording(new_recording)
- 13 end tell
- 14 end RecordingDone
- 15
- 16 on run
- 17 tell application "EyeTV"
- 18 set selected_recordings to selection of programs window
- 19 repeat with selected_recording in selected_recordings
- 20 my export_recording(selected_recording)
- 21 end repeat
- 22 end tell
- 23 end run
- 24
- 25 on export_recording(the_recording)
- 26 tell application "EyeTV"
- 27 set recording_location to location of the_recording as text
- 28 set AppleScript's text item delimiters to "."
- 29 set recording_path to text items 1 through -2 of recording_location as string
- 30 set AppleScript's text item delimiters to ""
- 31 set recording_path to POSIX path of recording_path
- 32 set input_file to my escape_path(recording_path & SOURCE_TYPE) as string
- 33 set output_file to my escape_path(TARGET_PATH & my get_recording_name(recording_location) & TARGET_TYPE) as string
- 34 set cmd to HANDBRAKE_CLI & " -i " & input_file & " -o " & output_file & HANDBRAKE_PARAMETERS & SHELL_SCRIPT_SUFFIX
- 35 do shell script "echo \"" & cmd & "\" > /Users/gtwibell/shellscript.log"
- 36 do shell script cmd
- 37 end tell
- 38 end export_recording
- 39
- 40 on get_recording_name(recording_location)
- 41 set oldDelimiters to AppleScript's text item delimiters
- 42 set AppleScript's text item delimiters to "/"
- 43 set path_components to every text item of POSIX path of (recording_location as string)
- 44 set recording_folder to item -2 of path_components as string
- 45 set AppleScript's text item delimiters to ".eyetv"
- 46 set recording_name to first item of every text item of recording_folder
- 47 set AppleScript's text item delimiters to oldDelimiters
- 48 return recording_name
- 49 end get_recording_name
- 50
- 51 on escape_path(the_path)
- 52 set oldDelimiters to AppleScript's text item delimiters
- 53 set AppleScript's text item delimiters to "/"
- 54 set path_components to every text item of the_path
- 55 set AppleScript's text item delimiters to oldDelimiters
- 56 repeat with counter from 1 to count path_components
- 57 set path_component to item counter of path_components
- 58 set item counter of path_components to my escape_string(path_component)
- 59 end repeat
- 60 set AppleScript's text item delimiters to "/"
- 61 set the_path to path_components as string
- 62 set AppleScript's text item delimiters to oldDelimiters
- 63 return the_path
- 64 end escape_path
- 65
- 66 on escape_string(the_string)
- 67 set chars to every character of the_string
- 68 repeat with i from 1 to length of chars
- 69 if "!$&\"'*()/{[|;<>?` \\" contains (item i of chars as text) then
- 70 set item i of chars to "\\" & (item i of chars as text)
- 71 end if
- 72 end repeat
- 73 return every item of chars as string
- 74 end escape_string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement