All pastes #729874 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-10-08 15:15 UTC
rendered paste body
--- /Users/chuck/manicure.rb
+++ pineapplecli.manicure.rb
@@ -1,5 +1,12 @@
 #! /usr/bin/ruby
-# manincure.rb version 0.1
+# manincure.rb version 0.1 
+
+# pineapplecli.manicure.rb version 0.1.2
+# *note by cvk_b, explanation of changes
+# 1. Remove extraneous info and formatting
+# 2. Put Name and commands on a single line, delimited by "QQQ"
+# 3. Made sure the x264 options were last on the line    
+# 4. Added Autoselect subtitles
 
 $presetMasterList = []
 $hashMasterList = []
@@ -38,7 +45,6 @@
     homeLocation = `echo $HOME`.chomp
     inputFile = homeLocation+'/Library/Application\ Support/HandBrake/UserPresets.plist'
     parseCommand = 'cat '+inputFile+' | sed -e \'s/<[a-z]*>//\' -e \'s/<\/[a-z]*>//\'  -e \'/<[?!]/d\' '
-    puts "\n\n"
     rawPresets = `#{parseCommand}`
   end
 
@@ -79,49 +85,13 @@
   def displayCommandStrings    
     $hashMasterList.each do |hash|
       if hash.key?("PresetName")
-        displayHeader(hash)
         generateCLIString(hash)
       end
     end    
   end
   
-  def displayHeader(hash)
-    puts "*" * @@columnWidth
-    puts '* '+hash["PresetName"].to_s.center(@@columnWidth-4)+' *'
-    puts '~' * @@columnWidth
-    puts hash["PresetDescription"].to_s.center(@@columnWidth).gsub(/\n/," ").scan(/\S.{0,#{@@columnWidth-2}}\S(?=\s|$)|\S+/)
-    
-    puts '~' * @@columnWidth
-    puts "#{hash["FileCodecs"]}".center(@@columnWidth)
-    
-    if hash["Type"].to_i == 1
-      puts "Custom Preset".center(@@columnWidth)
-    end
-
-    if hash["Default"].to_i == 1
-      puts "This is your default preset.".center(@@columnWidth)
-    end
-      
-    puts "~" * @@columnWidth
-   # puts "\n"
-    
-  end
-  
   def generateCLIString(hash)
-    commandString = ""
-    commandString << './HandBrakeCLI -i DVD -o ~/Movies/movie.'
-    
-    #Filename suffix
-    case hash["FileFormat"]
-    when /MP4/
-      commandString << "mp4 "
-    when /AVI/
-      commandString << "avi "
-    when /OGM/
-      commandString << "ogm "
-    when /MKV/
-      commandString << "mkv "
-    end
+    commandString = hash["PresetName"]+"QQQ"
     
     #Video encoder
     if hash["VideoEncoder"] != "FFmpeg"
@@ -203,16 +173,13 @@
     end
     
     #Subtitles
-    if hash["Subtitles"] != "None"
-      commandString << " -s "
-      commandString << hash["Subtitles"]
-    end
-    
-    #x264 Options
-    if hash["x264Option"] != ""
-      commandString << " -x "
-      commandString << hash["x264Option"]
+    if hash["Subtitles"] != "None"      
+      if hash["Subtitles"] != "Autoselect" then
+        commandString << " -s "
+        commandString << hash["Subtitles"]
+      end
     end
+    if hash["Subtitles"] == "Autoselect" then commandString << " -U -F" end       
     
     #Booleans
     if hash["ChapterMarkers"].to_i == 1 then commandString << " -m" end
@@ -220,11 +187,15 @@
     if hash["PicturePAR"].to_i == 1 then commandString << " -p" end
     if hash["VideoGrayScale"].to_i == 1 then commandString << " -g" end
     if hash["VideoTwopass"].to_i == 1 then commandString << " -2" end
+
+    #x264 Options
+    if hash["x264Option"] != ""
+      commandString << " -x "
+      commandString << hash["x264Option"]
+    end
     
     # That's it, print to screen now
-    puts commandString
-    puts "*" * @@columnWidth
-    puts  "\n\n"
+    puts commandString     
   end
 
 end