DePhoegon

VLC IP CableCard TV Show Recording, Windows (Streamlined)

Aug 21st, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 10.14 KB | None | 0 0
  1. @echo off
  2. :: Windows Version, PowerShell Commands (Internal Scripts, Works with Default Script settings in windows [Restricted]), Task Scheduler, Date Format
  3. :: Uses PowerShell to adjust Short Date Format, for Date verification & easy entering of Current day, Saves Current Date Format & Replaces it. It should happen 6 Times when entering the date, and 3 When Restarting using the same date.
  4. :: COMODO Users, Set bat file as 'Updater or Installer', will allow Scripts to be ran w/o stopping them.  Check code, it's safe but always look, Set bat file as READ ONLY when not adding/deleting shows.
  5. :: Verifies Entered Date & uses one date format, modifies & restores system date format [Stores in txt file, restores & deletes txt file] Makes compatible with any date time format w/o to much headache
  6. :: Improved schtasks usage, & launching VLC directly with the correct augments & no Command line windows [Very Huge benefit], & hidden VLC window
  7. goto Start
  8. :ARE
  9. echo Already Recorded
  10. :RE2
  11. set AREP=0
  12. if %YT% EQU 0 set AREP=1
  13. set SDC=0
  14. set RSC=0
  15. set RSS=0
  16. set S=0
  17. echo Restart Options
  18. echo 1. Blank Restart
  19. echo 2. Same Channel
  20. echo 3. Same Show
  21. echo 4. Same Channel and show
  22. if %AREP% EQU 1 ( echo Selected Channel- %CHAN% // Selected Show- %SW% & goto RE3 )
  23. :: Skips echos for Options that'd give errors, & Echos Other data
  24. echo 5. Same Day
  25. echo 6. Same Day and Show
  26. echo 7. Same Day and Channel
  27. echo 8. Same Day, Show, and Channel
  28. echo Selected Channel- %CHAN% // Selected Show- %SW% // Selected Date- %DAT%
  29. :RE3
  30. set /p RSS= "Enter to quit: "
  31. if %RSS% EQU 0 goto End
  32. if %RSS% EQU 1 goto Top
  33. if %RSS% EQU 2 goto SH0
  34. if %RSS% EQU 3 ( set SDC=1& goto RTOP )
  35. if %RSS% EQU 4 ( set SDC=1& goto RES )
  36. if %AREP% EQU 1 goto End
  37. :: Prevents the Selection of Options that'd generate Errors, and Exits instead
  38. if %RSS% EQU 5 ( set RSC=1& goto RTOP )
  39. if %RSS% EQU 6 (
  40. set RSC=1
  41. set SDC=1
  42. goto RTOP
  43. )
  44. if %RSS% EQU 7 ( set RSC=1& goto SH0 )
  45. if %RSS% EQU 8 (
  46. set RSC=1
  47. set SDC=1
  48. goto RES
  49. )
  50. :End
  51. exit
  52. :Start
  53. :: Program & Folder variables,  Changeable as needed.
  54. set VLC=C:\Program Files (x86)\VideoLAN\VLC\vlc.exe
  55. set FF=Z:\TVVideo\
  56. set TF=Z:\Videos\TVSHOW\
  57. set WT=Z:\TSAudio\WaitT\
  58. set TSTV=Z:\Videos\TVShowwAdsTS\
  59. set IP=http://192.168.51.249:5004/auto/v
  60. set F=.ts
  61. set M=.mp4
  62. :Top
  63. set S=0
  64. set RSC=0
  65. set YT=0
  66. set SDC=0
  67. set SMC=0
  68. :RTOP
  69. set CHAN=0
  70. set /p CHAN= "Enter Channel Number?: "
  71. set NT=0
  72. set /a NT=%NT%+%CHAN%
  73. if %NT% EQU 0 ( echo Input Channel Number& goto RTOP )
  74. :RES
  75. if %SDC% EQU 1 ( call :SD3 ) else ( goto SH0 )
  76. set /a SDC=%TYV%*%TDV%*%TMV%
  77. set RSS=%SDC%
  78. set /p SDC= "Special Episdoe? [No input=No, any input= Yes]"
  79. if %SDC% EQU %RSS% ( goto RSH )
  80. set RSS=0
  81. set SDC=0
  82. goto SPC
  83. :SH0
  84. if %S% EQU 2 goto SH1
  85. echo Select Show.
  86. echo 0. Special Episode. [To Use, Select First]
  87. :SH1
  88. if %S% EQU 0 goto SH2
  89. echo Special Episode - Select Show
  90. :SH2
  91. :: Lists Shows, Alter List as want
  92. echo 1. Attack on Titan
  93. echo 2. Doctor Who
  94. echo 3. Dragon Ball Super
  95. echo 4. Dragon Ball Z Kai: The Final Chapters
  96. echo 5. M*A*S*H*
  97. echo 6. Mike Tyson Mysteries
  98. echo 7. Mighty MagiSwords
  99. echo 8. Rick and Morty
  100. echo 9. Samurai Jack
  101. echo 10. Star Trek: The Next Generation
  102. echo 11. Star Trek: Voyager
  103. echo 12. Your Pretty Face is Going to Hell
  104. ::Setup to check for input on Show Name prompt
  105. if %S% EQU 2 goto SHS
  106. call :SD3
  107. :: Overcomplicated way to detect no input & avoid accidental matching
  108. set /a SW=(%TDV%*%TMV%)+(%TMV%*(%TDV%+%TDV%))+%TYV%
  109. set NT=no%SW%show
  110. set SW=%NT%
  111. set /p SW= "[If other type out] {No Spaces}: "
  112. if %SW%==%NT% ( echo No Default selection, Input Required. & goto SH0 )
  113. :: Cycle for selection of Show, with special episode
  114. if %SW% EQU 0 (
  115. echo Choose show or Enter name.
  116. set S=2
  117. goto SH0
  118. ) else ( goto SH3 )
  119. :SHS
  120. set /a SW=(%TDV%*%TMV%)+(%TMV%*(%TDV%+%TDV%))+%TYV%
  121. set NT=no%SW%show
  122. set SW=%NT%
  123. set /p SW= "[If other type out] {No Spaces}: "
  124. if %SW%==%NT% ( echo No Default selection, Input Required. & goto SH0 )
  125. :SH3
  126. if %SW% EQU 1 Set SW=Attack-on-Titan
  127. if %SW% EQU 2 set SW=Doctor-Who
  128. if %SW% EQU 3 set SW=Dragon-Ball-Super
  129. if %SW% EQU 4 set SW=Dragon-Ball-Z-Kai-The-Final-Chapters
  130. if %SW% EQU 5 set SW=MASH
  131. if %SW% EQU 6 set SW=Mike-Tyson-Mysteries
  132. if %SW% EQU 7 set SW=Mighty-MagiSwords
  133. if %SW% EQU 8 set SW=Rick-and-Morty
  134. if %SW% EQU 9 set SW=Samurai-Jack
  135. if %SW% EQU 10 set SW=Star-Trek-The-Next-Generation
  136. if %SW% EQU 11 set SW=Star-Trek-Voyager
  137. if %SW% EQU 12 set SW=Your-Pretty-Face-is-going-to-Hell
  138. if %S% EQU 2 goto SPC
  139. :RSH
  140. set RSS=0
  141. set SDC=0
  142. set /p S= "Which Season? [ # ]: "
  143. set /p E= "Which Episode? [ # ]: "
  144. set SE=-S%S%E%E%
  145. goto TST
  146. :SPC
  147. set /p S= "Season# and Special Episode. [ S#-Name-of-Episode ] {No Spaces}: "
  148. set SE=-%S%
  149. :TST
  150. ::Check for Existing Recording or Scheduled in task scheduler
  151. if EXIST %TF%%SW%%SE%%F% (echo %TF%%SW%%SE%%F% & goto ARE)
  152. if EXIST %TSTV%%SW%%SE%%F% (echo %TSTV%%SW%%SE%%F% & goto ARE)
  153. if EXIST %TSTV%%SW%%SE%%M% (echo %TSTV%%SW%%SE%%M% & goto ARE)
  154. if EXIST %TF%%SW%%SE%%M% (echo %TF%%SW%%SE%%M% & goto ARE)
  155. if EXIST %WT%%SW%%SE%%F% (echo %WT%%SW%%SE%%F% & goto ARE)
  156. if EXIST %FF%%SW%%SE%%F% (echo %FF%%SW%%SE%%F% & goto ARE)
  157. if EXIST %FF%%SW%%SE%%M% (echo %FF%%SW%%SE%%M% & goto ARE)
  158. Schtasks /query /tn %SW%%SE% >NUL 2>&1
  159. if %errorlevel% EQU 0 (echo %SW%%SE% Schedule already created & goto RE2 )
  160. :MMM
  161. :: Check for entered Date from Restart, & auto enters current date for Year, Month, Day
  162. if %RSC% EQU 1 goto DVC
  163. set YT=0
  164. set /p YT= "What Year? [ #### ] {No Entry=Current Year}: "
  165. if %YT% EQU 0 ( call :SDY ) else ( goto MMY )
  166. set YT=%TYV%
  167. goto YR
  168. :MMY
  169. set NT=0
  170. :: Check for Number input
  171. set /a NT=%NT%+%YT%
  172. if %NT% EQU 0 (echo Numbers Only & goto MMM)
  173. call :SDY
  174. if %YT% LSS %TYV% (echo Past Year & goto MMM)
  175. :: Sets A year limit
  176. set /a NT=%TYV%+2
  177. if %YT% GTR %NT% (echo More then 2 years out & Goto MMM)
  178. :YR
  179. set MT=0
  180. set /p MT= "Which Month? [ ## ] {No Entry=Current Month}: "
  181. set NT=0
  182. if %MT% EQU 0 ( call :SDM & set NT=1 )
  183. if %NT% EQU 1 ( set MT=%TMV%& goto MR )
  184. set /a NT=%MT%+%NT%
  185. if %NT% EQU 0 ( echo Numbers only & goto YR)
  186. if %MT% LSS 0 ( echo Invalid selection & goto YR)
  187. if %MT% GTR 12 ( echo Invalid selection & goto YR)
  188. :MR
  189. set DT=0
  190. set /p DT= "Which Day? [ ## ] {No Entry=Current Day}: "
  191. set NT=0
  192. if %DT% EQU 0 ( call :SDD & set NT=1)
  193. if %NT% EQU 1 ( set DT=%TDV%& goto DR)
  194. set /a NT=%DT%+%NT%
  195. if %NT% EQU 0 (echo Invalid Selection, Numbers only & goto MR)
  196. goto DC
  197. :DR
  198. goto DVC
  199. :DVP
  200. :: Corrects Single Digits, format issue
  201. if %DT% LSS 10 set DT=0%DT%
  202. if %MT% LSS 10 set MT=0%MT%
  203. set DAT=%MT%/%DT%/%YT%
  204. :TTH
  205. set HR=0
  206. set HMR=0
  207. set /p HR= "What Starting Hour? [ ##, No Leading Zero / Enter for 00]: "
  208. if %HR% LSS 0 (echo Wrong Hour & goto TTH)
  209. if %HR% GTR 23 (echo Wrong Hour & goto TTH)
  210. if %HR% LSS 10 set HR=0%HR%
  211. :TTM
  212. set /p HMR= "What Starting Minutes in Hour? [ ##, No Leading Zero / Enter for 00]: "
  213. if %HMR% LSS 0 (echo Wrong Minute & goto TTM)
  214. if %HMR% GTR 59 (echo Wrong Minute & goto TTM)
  215. if %HMR% LSS 10 set HMR=0%HMR%
  216. set TIME=%HR%:%HMR%
  217. set /p LONG= "How Long in Minutes?: "
  218. set /a L=(%LONG%*60)-5
  219. set AUG=:sout=#duplicate{dst=file{dst=%TSTV%%SW%%SE%%F%}} --qt-start-minimized  --run-time=%L%
  220. :: Avoids Date format errors, Sets short date format, then restores the one in use by the system.
  221. set PSN=TS
  222. call :PSFC
  223. schtasks /create /tn "%SW%%SE%" /tr "\"%VLC%\" %IP%%CHAN% %AUG% vlc://quit" /sc once /st %TIME% /sd %DAT%
  224. call :PSFCr
  225. goto RE2
  226. :DC
  227. :: Verifies Days Exist in calendar
  228. if %DT% LSS 0 goto DFC
  229. if %DT% LSS 1 (echo Program altered & pause & goto End)
  230. if %MT% LSS 1 (echo Program altered & pause & goto End)
  231. if %MT% GTR 12 (echo Program altered & pause & goto End)
  232. if %MT% EQU 1 goto D31
  233. if %MT% EQU 2 goto D28
  234. if %MT% EQU 3 goto D31
  235. if %MT% EQU 4 goto D30
  236. if %MT% EQU 5 goto D31
  237. if %MT% EQU 6 goto D30
  238. if %MT% EQU 7 goto D31
  239. if %MT% EQU 8 goto D31
  240. if %MT% EQU 9 goto D30
  241. if %MT% EQU 10 goto D31
  242. if %MT% EQU 11 goto D30
  243. if %MT% EQU 12 goto D31
  244. :D31
  245. if %DT% GTR 31 goto DFC
  246. Goto DR
  247. :D30
  248. if %DT% GTR 30 goto DFC
  249. goto DR
  250. :D28
  251. :: Leap Year, Verifying February Days & accounting for leap years w/o hard coding years
  252. set MDC=0
  253. set /a MDC=(%YT%/4)*4
  254. if %YT% EQU %MDC% ( set /a MDC=(%YT%/100)*100) else (goto LYF)
  255. if %YT% EQU %MDC% ( set MDC=0 & set /a MDC=(%YT%/400)*400 & if %YT% EQU %MDC% ( set MDC=0) else (goto LYF) )
  256. goto LYP
  257. :LYF
  258. if %DT% GTR 28 goto DFC
  259. goto DR
  260. :LYP
  261. if %DT% GTR 29 goto DFC
  262. goto DR
  263. :DFC
  264. echo Invalid Day & goto MR
  265. :DVC
  266. set DAC=0
  267. if %RSC% EQU 1 (
  268. if %MT% GEQ 10 ( set MT=%MT%) else ( set MT=%MT:~1%)
  269. if %DT% GEQ 10 ( set DT=%DT%) else ( set DT=%DT:~1%)
  270. )
  271. :: Verifies Selected Date is set in the current or future
  272. call :SD3
  273. if %YT% LEQ %TYV% set /a DAC=%DAC%+1
  274. if %MT% LEQ %TMV% set /a DAC=%DAC%+1
  275. if %DT% LSS %TDV% set /a DAC=%DAC%+1
  276. if %DAC% LSS 3 Goto DVP
  277. echo Invalid Date selection.  %MT%/%DT%/%YT% [Month/Day/Year] is in the past, or check your calander.
  278. goto MMM
  279. :SDD
  280. ::To avoid base 8 conflicts.
  281. :: PowerShell to adjust date format, allowing usage of this batch file despite the preferred or default date format
  282. set PSN=D
  283. call :PSFC
  284. set TDV=0
  285. if %date:~3,2% GEQ 10 ( set TDV=%date:~3,2%) else ( set TDV=%date:~4,1%)
  286. call :PSFCr
  287. exit /b
  288. :SDM
  289. ::To avoid base 8 conflicts.
  290. set PSN=M
  291. call :PSFC
  292. set TMV=0
  293. if %date:~0,2% GEQ 10 ( set TMV=%date:~0,2%) else ( set TMV=%date:~1,1%)
  294. call :PSFCr
  295. exit /b
  296. :SDY
  297. ::To avoid Conflicts
  298. set PSN=Y
  299. call :PSFC
  300. set TYV=%date:~6,4%
  301. call :PSFCr
  302. exit /b
  303. :SD3
  304. :: Used to get all 3, at once & generate a 5th file, incase system steps on itself with writing/deleting the same file.
  305. set PSN=3
  306. call :PSFC
  307. if %date:~3,2% GEQ 10 ( set TDV=%date:~3,2%) else ( set TDV=%date:~4,1%)
  308. if %date:~0,2% GEQ 10 ( set TMV=%date:~0,2%) else ( set TMV=%date:~1,1%)
  309. set TYV=%date:~6,4%
  310. call :PSFCr
  311. exit /b
  312. :PSFC
  313. ::Creates Powershell script to change short date format & calls the first one
  314. powershell -command "$cul = Get-Culture;$Store = $cul.datetimeformat.shortdatepattern;Write-output $Store > VLCDFS%PSN%.txt;$Cul.DateTimeFormat.ShortDatePattern = 'MM/dd/yyyy';Set-Culture $Cul"
  315. exit /b
  316. :PSFCr
  317. powershell -command "$DF = Get-Content VLCDFS%PSN%.txt;$cul = Get-Culture;$cul.datetimeformat.shortdatepattern = $DF;Set-Culture $cul;remove-item VLCDFS%PSN%.txt"
  318. exit /b
Add Comment
Please, Sign In to add comment