- def readPresetPlist # Grab the .plist and store it in presets
-
- # Grab the user's home path
- homeLocation = `echo $HOME`.chomp
-
- # Use that to build a path to the presets .plist
- inputFile = homeLocation+'/Library/Application\ Support/HandBrake/UserPresets.plist'
-
- # Builds a command that inputs the .plist, but not before stripping all the XML gobbledygook.
- parseCommand = 'cat '+inputFile+' | sed -e \'s/<[a-z]*>//\' -e \'s/<\/[a-z]*>//\' -e \'/<[?!]/d\' '
-
- puts "\n\n"
-
- # Run the command, return the raw presets
- rawPresets = `#{parseCommand}`
- end
-
- def cleanStew(presetStew) #remove tabbed white space
- presetStew.each do |oneline|
- oneline.strip!
- end
- end
-
- def findPresetBreaks(presetStew) #figure out where each preset starts and ends
- i = 0
- j = 0
- presetBreaks =[]
- presetStew.each do |presetLine|
- if presetLine =~ /AudioBitRate/ # This is the first line of a new preset.
- presetBreaks[j] = i-1 # So mark down how long the last one was.
- j += 1
- end
- i += 1
- end
- return presetBreaks
- end
-
- def buildPresetHash #fill up @hashMasterList with hashes of all key/value pairs
- j = 0
-
- # Iterate through all presets, treating each in turn as singleServing
- @presetMasterList.each do |singleServing|
-
- # Initialize the hash for preset j (aka singleServing)
- @hashMasterList[j] = Hash.new
-
- # Each key and value are on sequential lines.
- # Iterating through by twos, use that to build a hash.
- # Each key, on line i, paired with its value, on line i+1
- i = 1
- while i < singleServing.length
- @hashMasterList[j].store( singleServing[i], singleServing[i+1] )
- i += 2
- end
-
- j += 1
- end
- end
-