Advertisement
gtwibell

Untitled

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