Advertisement
Guest User

Untitled

a guest
Nov 12th, 2012
1,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.88 KB | None | 0 0
  1. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. :: AutoRipDVD is brought to you by Spinalcracker
  3. :: Modified by Akevit :
  4. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5. @Echo on
  6. Setlocal enableextensions
  7. :: Enable Delayed Expansion allows for loops to iterate through each variable by using ! instead of % when calling variable
  8. Setlocal enabledelayedexpansion
  9. :: ScriptPath is now dynamically hardcoded to wherever the AutoRipDVD.bat file is, script will break If you move location of this file
  10. Set ScriptPath=%~dp0
  11. Set ScriptPath=%ScriptPath:~0,-1%
  12. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  13. :: Change the following variables to match your setup
  14. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  15. :: DriveLetter=The drive letter of your DVD or Blu-Ray drive ie. D: or G: etc
  16. Set DriveLetter=E:
  17.  
  18. :: RipDir=Where you want your DVD ripped to ie. your xbmc movie folder
  19. Set RipDir=I:\HD Movies
  20.  
  21. :: IntDir=Where you installed MakeMKV to
  22. Set IntDir=C:\Program Files (x86)\MakeMKV
  23.  
  24. :: RipMinSeconds=Minimum time In seconds that should be ripped off disk to avoid getting previews etc. Default is 3600 seconds or 1 hour
  25. Set RipMinSeconds=3600
  26.  
  27. :: Eject Disc after ripping?
  28. Set EjectDisc=No
  29.  
  30. :: Show splash screens
  31. Set ShowSplash=No
  32. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  33. :: HANDBRAKE SETTINGS
  34. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  35. :: Using Handbrake to compress - Yes or No?
  36. Set Handbrake=Yes
  37.  
  38. :: Sets the install path to handbrake
  39. Set Handbrakepath=C:\Program Files\Handbrake
  40.  
  41. :: Log Handbrake?
  42. Set Handbrakelog=Yes
  43. Set HandbrakelogDirectory=%scriptpath%
  44.  
  45. :: Keep backup of original file after compression? (Otherwise original full quality video will be deleted from Hard Drive -- They're quite large)
  46. Set KeepHDVersion=Yes
  47. Set OriginalBackupDir=I:\Oringal HD Rips
  48.  
  49. :: Enter profile For handbrake settings to use (see end of this file)
  50. Set HBsettings=720pHigh
  51.  
  52. :: Experimental procedure to only encode the largest extracted MKV and append .delete to the others
  53. Set encodeLargestOnly=Yes
  54. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  55. :: XBMC Settings For Library Update
  56. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  57. :: Update XBMC Library Upon completion?
  58. :: NOTE: CURL For Windows MUST BE INSTALLED: http://curl.haxx.se/download.html
  59. Set UpdateXBMC=Yes
  60.  
  61. :: Add arbitrary NFO.txt file For file If wanted
  62. :: Will need to manually add URL to NFO file For scraper to work
  63. Set AddNFO=Yes
  64.  
  65. ::*** Which version of XBMC are you using? Enter FroDo or Eden
  66. Set XBMCversion=Frodo
  67.  
  68. :: Set logIn details For XBMC HTTP access (settings found In XBMC Network settings)
  69. Set XBMCuser=xbmc
  70. Set XBMCpass=xbmc
  71. Set XBMCurl=127.0.0.1
  72. Set XBMCport=8082
  73. Set cURLpath=C:\cURL\curl.exe
  74. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  75. :: Debug Test Mode
  76. Set TestMode=No
  77. ::*********************************************************************************************
  78. ::*********************************************************************************************
  79. ::******* Do NOT EDIT ANYTHING BELOW THIS!!!!!!************************************************
  80. ::*********************************************************************************************
  81. ::*********************************************************************************************
  82. :StartScript
  83. :: Set volid = label name
  84. For /f "tokens=1-5*" %%1 In ('vol %DriveLetter%') Do (
  85. Set volid=%%6
  86. Goto :processcontd
  87. )
  88.  
  89. :processcontd
  90. :: Remove trailing space from label name if exists
  91. If "%volid:~-1,1%"==" " Set volid=%volid:~0,-1%
  92. Echo Volid:[%volid%]
  93.  
  94. :GetDiscNum
  95. :: Get disc number based on name of %volid%
  96. "%IntDir%\makemkvcon64.exe" -r --cache=1 info disc:9999 | Find /i "%volid%" > "%userprofile%\ARtemp"
  97. Set /p discNum=<"%userprofile%\ARtemp"
  98. Del "%userprofile%\ARtemp"
  99. Set discNum=%discNum:~4,1%
  100.  
  101. :: Checking For drive
  102. Set str=%volid%
  103. Set str=%str:_= %
  104. Set volid=%str%
  105. If "%volid%"=="_= " Call :NoDrive
  106.  
  107. Echo:Ripping %volid% now...
  108. Echo %date% %time%: Begin Script [%volid%] >> "%scriptpath%\AutoRipLog.txt"
  109. :: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  110. :: Go to test mode
  111. If %testmode%==Yes Goto :Testing
  112. :: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  113.  
  114. :: Creating directory to rip DVD as an MKV to
  115. Mkdir "%RipDir%\%volid%"
  116.  
  117. :: Launch AutoRip splash screen
  118. If %ShowSplash%==Yes Call "%ScriptPath%\OSDAutoRip.hta"
  119.  
  120. :: Ripping DVD to MKV file
  121. Cd /d "%IntDir%"
  122. Echo %date% %time%: Ripping [%volid%] >> "%scriptpath%\AutoRipLog.txt"
  123.  
  124. :: Rip with MakeMKV?
  125. Echo 1. Rip with MakeMKV
  126. Echo 2. Skip Rip with MakeMKV
  127. Set /P UseMakeMKV=Please select a number:
  128. If %UseMakeMKV%==1 Call :Rip_With_MakeMKV
  129.  
  130.  
  131.  
  132. :EndingScripts
  133. If %Handbrake%==Yes Call :HBEncode
  134. If %UpdateXBMC%==Yes Call :UpdateLibrary
  135. If %AddNFO%==Yes Call :AddNFOscript
  136.  
  137. :ScriptComplete
  138. Cd /d "%ScriptPath%"
  139. If %EjectDisc%==Yes Call AutoRipComplete.vbs
  140. Echo %date% %time%: End Script [%volid%] >> "%scriptpath%\AutoRipLog.txt"
  141. cscript Beep.vbs
  142. PAUSE
  143. EXIT
  144.  
  145. :: Start of various ending scripts
  146. :NoDrive
  147. Cd /d "%ScriptPath%"
  148. Echo %date% %time%: End Script [%volid%] >> "%scriptpath%\AutoRipLog.txt"
  149. cscript Beep.vbs
  150. NoDiskDrive.hta
  151. AutoRipComplete.vbs
  152. EXIT
  153.  
  154. :Rip_With_MakeMKV
  155. makemkvcon64.exe --minlength=%RipMinSeconds% mkv disc:%discNum% all "%RipDir%\%volid%"
  156. Echo %date% %time%: Rip complete [%volid%] >> "%scriptpath%\AutoRipLog.txt"
  157. :Goto :EOF
  158.  
  159. :HBEncode
  160. Call :%HBsettings%
  161. Echo %date% %time%: BegIn HB Encode [%volid%] >> "%scriptpath%\AutoRipLog.txt"
  162. Cd /d "%Handbrakepath%"
  163.  
  164. :: Setting Handbrakelog, double quotes necessary otherwise output won't be written
  165. If %Handbrakelog%==Yes Set LOG="--verbose=1 2> "%HandbrakelogDirectory%\HandbrakeLog.txt""
  166.  
  167. :: !Experimental! - Only encode largest mkv file and rename others
  168. If %encodeLargestOnly%==Yes Call :renameSmallerMKVs
  169.  
  170. :: Encoding each video file separately and appending %RESOLUTION% variable to filename
  171. For %%m In ("%RipDir%\%volid%\*.mkv") Do (
  172. Set num=%%m
  173. Set num=!num:~-6,2!
  174. HandBrakeCLI -i "%%m" -o "%RipDir%\%volid%\%volid% [!num!] %RESOLUTION%.mkv" %PICTURE% %VIDEO% %AUDIO% %ADVANCED% %LOG:~1,-1%
  175. :: This has potential not to work either since it doesn't iterate properly
  176. Call :HBEncodeLogSection
  177. )
  178.  
  179. Cd /d %_tmpPath%
  180. If %KeepHDVersion%==Yes Goto :KeepHDLabel
  181. Del "%volid%_*.mkv"
  182. Goto :EOF
  183.  
  184. :renameSmallerMKVs
  185. Dir "%RipDir%\%volid%\*.mkv" /b /o-s>{temp}
  186. Set /P biggestMKV=<{temp}
  187. Del {temp}
  188. For %%f In ("%RipDir%\%volid%\*.mkv") Do (
  189. If Not "%%f"=="%RipDir%\%volid%\%biggestMKV%" (
  190. Ren "%%f" *.delete
  191. )
  192. )
  193. Goto :EOF
  194.  
  195. :HBEncodeLogSection
  196. ECHO %date% %time%: End HB Encode [%%m] >> "%scriptpath%\AutoRipLog.txt"
  197. Goto :EOF
  198.  
  199. :: This only works for encoding one movie as keepFile could potentially contain multiple 720p files
  200. :: Should find a way to iterate through
  201. :: Potential problem with how it iterates through and renaming a file that has already been renamed or something
  202. :KeepHDLabel
  203. Mkdir "%OriginalBackupDir%\%volid%"
  204. Dir /b "%RipDir%\%volid%\*%RESOLUTION%.mkv">{temp}
  205. Set /P keepFile=<{temp}
  206. Del {temp}
  207. For %%f in ("%RipDir%\%volid%\*_*") do (
  208. If Not "%%f"=="%RipDir%\%volid%\%keepFile%" (
  209. Move "%%f" "%OriginalBackupDir%\%volid%"
  210. )
  211. )
  212. Goto :EOF
  213.  
  214. :AddNFOscript
  215. Echo http://www.themoviedb.org/movie/ > "%RipDir%\%volid%\%titlename%.NFO.ADD URL FROM TMDB or TVDB WHEN NEEDED.txt"
  216. Goto :EOF
  217.  
  218. :UpdateLibrary
  219. If %XBMCversion%==FroDo Goto :UpdateLibraryFrodo
  220. If %XBMCversion%==Eden Goto :UpdateLibraryEden
  221. Goto :EOF
  222.  
  223. :UpdateLibraryFrodo
  224. "%cURLpath%" -i -H "Content-Type: application/json" -X POST -d "{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Scan\"}" http://%XBMCuser%:%XBMCpass%@%XBMCurl%:%XBMCport%/jsonrpc
  225. Goto :EOF
  226.  
  227. :UpdateLibraryEden
  228. "%cURLpath%" --get "http://%XBMCuser%:%XBMCpass%@%XBMCurl%:%XBMCport%/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)"
  229. Goto :EOF
  230. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  231. :: Change or add Handbrake Settings here :
  232. :: Format follows the tabs In handbrake, PICTURE settings include video filter as this is how it's referenced In the CLIGuide :
  233. :: For full explanations of settings, see here: https://trac.handbrake.fr/wiki/CLIGuide :
  234. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  235. :OriginalSettings
  236. Set RESOLUTION=720p
  237. Set PICTURE=--format mkv --width 1280
  238. Set VIDEO=-m -e x264 --quality 23
  239. Set AUDIO=--ab 64 --mixdown mono
  240. Set ADVANCED=-x b-adapt=2:rc-lookahead=50:me=umh:bframes=5:ref=6:direct=auto:trellis=2:subq=10:psy-rd=1.0,0.10:analyse=all
  241. Goto :EOF
  242.  
  243. :720pHigh
  244. Set RESOLUTION=720p
  245. Set PICTURE=-f mkv --decomb -w 1280 --crop 0:0:0:0 --loose-anamorphic --modulus 2
  246. Set VIDEO=-m -e x264 -q 20 --vfr
  247. Set AUDIO=-a 1,1 -E faac,copy:ac3 -B 160,0 -6 dpl2,auto -R Auto,Auto -D 0,0 --gain=0,0 --audio-copy-mask none --audio-fallback ffac3
  248. Set ADVANCED=-x b-adapt=2:rc-lookahead=50:ref=6:bframes=6:me=umh:subq=9:merange=64:analyse=all
  249. Goto :EOF
  250.  
  251. :720pLow
  252. Set RESOLUTION=720p
  253. Set PICTURE=-f mkv -w 1280 --loose-anamorphic
  254. Set VIDEO=-m -e x264 -q 20 -r 29.97 --pfr
  255. Set AUDIO=-a 1,1 -E faac,ffac3 -B 160,0 -6 dpl2,auto -R Auto,Auto -D 0,0 --gain=0,0 --audio-copy-mask none --audio-fallback ffac3
  256. Set ADVANCED=--x264-profile high
  257. Goto :EOF
  258.  
  259. :720pMedium
  260. Set RESOLUTION=720p
  261. Set PICTURE=-f mkv --decomb -w 1280 --loose-anamorphic --modulus 2
  262. Set VIDEO=-m -e x264 -q 20 --vfr
  263. Set AUDIO=-a 1,1 -E faac,ffac3 -B 160,0 -6 dpl2,auto -R Auto,Auto -D 0,0 --gain=0,0 --audio-copy-mask none --audio-fallback ffac3
  264. Set ADVANCED=-x b-adapt=2:rc-lookahead=50
  265. Goto :EOF
  266. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  267. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  268. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  269. :: TESTING CODE AREA IGNORE
  270. :Testing
  271. @Echo ON
  272. Set RipDir=%RipDir%\Testing
  273. Echo http://www.themoviedb.org/movie/ > "%RipDir%\movie.NFO.ADD URL FROM TMDB WHEN NEEDED.txt"
  274. :: Creating directory to rip DVD as an MKV to
  275. :: Mkdir "%RipDir%\%volid%"
  276. :: "%IntDir%\makemkvcon64.exe" --minlength=%RipMinSeconds% mkv disc:%discNum% all "%RipDir%\%volid%"
  277.  
  278. :: Cd /D "%RipDir%\%volid%"
  279. :: Rename * %volid%.MKV
  280. ::If %Handbrakelog%==Yes Call HandBrakeCLI -i "%RipDir%\%volid%" -o "%RipDir%\%volid%\%volid% %RESOLUTION%.mkv" %PICTURE% %VIDEO% %AUDIO% %ADVANCED% --verbose=1 2> "%HandbrakelogDirectory%\HandbrakeLog.txt"
  281. ::If %Handbrakelog%==No Call HandBrakeCLI -i "%RipDir%\%volid%" -o "%RipDir%\%volid%\%volid% %RESOLUTION%.mkv" %PICTURE% %VIDEO% %AUDIO% %ADVANCED%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement