Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :: Using VLC to Set Recording for Movies
- :: Simplified Restart
- :: Windows Version, Works with Default Script Settings [Restricted], Stores & Restores Short Date Format
- :: COMODO users, Set bat file as 'installer or Updater'
- :: Uses Internal PowerShell Scripts
- :: Uses Task Scheduler to launch VLC directly with correct augments
- goto Start
- :ARE
- echo Already Recorded
- :RE2
- echo Restart or exit?
- set /p T= "Restart (R)"
- if %T%==R (goto Top)
- if %T%==r (goto Top)
- :End
- exit
- :Start
- set VLC=C:\Program Files (x86)\VideoLAN\VLC\vlc.exe
- set FF=Z:\TVVideo\
- set FD=Z:\Videos\TVMovieswAds\
- set IP=http://192.168.51.249:5004/auto/v
- set F=.ts
- set M=.mp4
- set WV=Z:\TSAudio\WaitV\
- :top
- set T=0
- set MT=0
- set DT=0
- set YT=0
- set HR=00
- set HMR=00
- set /p CHN= "Enter Channel Number?: "
- set /p SW= "Which Movie? (No Spaces): "
- set /p SE= "Release Year: "
- set SP=-[%SE%]
- :: Looks for Movie scheduled & Recorded (and also Transcoded into another format. Variable %M% can be set to any extension you'd transcode them into.
- if Exist %FF%%SW%%SP%%F% (echo %FF%%SW%%SP%%F% & goto ARE)
- if Exist %FD%%SW%%SP%%F% (echo %FD%%SW%%SP%%F% & goto ARE)
- if Exist %WV%%SW%%SP%%F% (echo %WV%%SW%%SP%%F% & goto ARE)
- if Exist %FF%%SW%%SP%%M% (echo %FF%%SW%%SP%%M% & goto ARE)
- if Exist %FD%%SW%%SP%%M% (echo %FD%%SW%%SP%%M% & goto ARE)
- Schtasks /query /tn %SW%%SP% >NUL 2>&1
- if %errorlevel% EQU 0 (echo %SW%%SP% Schedule already created & goto RE2 )
- :MMM
- set YT=0
- set /p YT= "What Year? [ #### ] {No Entry=Current Year}: "
- if %YT% EQU 0 ( call :SDY ) else ( goto MMY )
- set YT=%TYV%
- goto YR
- :MMY
- set NT=0
- :: Check for Number input
- set /a NT=%NT%+%YT%
- if %NT% EQU 0 (echo Numbers Only & goto MMM)
- call :SDY
- if %YT% LSS %TYV% (echo Past Year & goto MMM)
- :: Sets A year limit
- set /a NT=%TYV%+2
- if %YT% GTR %NT% (echo More then 2 years out & Goto MMM)
- :YR
- set MT=0
- set /p MT= "Which Month? [ ## ] {No Entry=Current Month}: "
- set NT=0
- if %MT% EQU 0 ( call :SDM & set NT=1 )
- if %NT% EQU 1 ( set MT=%TMV%& goto MR )
- set /a NT=%MT%+%NT%
- if %NT% EQU 0 ( echo Numbers only & goto YR)
- if %MT% LSS 0 ( echo Invalid selection & goto YR)
- if %MT% GTR 12 ( echo Invalid selection & goto YR)
- :MR
- set DT=0
- set /p DT= "Which Day? [ ## ] {No Entry=Current Day}: "
- set NT=0
- if %DT% EQU 0 ( call :SDD & set NT=1)
- if %NT% EQU 1 ( set DT=%TDV%& goto DR)
- set /a NT=%DT%+%NT%
- if %NT% EQU 0 (echo Invalid Selection, Numbers only & goto MR)
- goto DC
- :DR
- goto DVC
- :DVP
- :: Corrects Single Digits, format issue
- if %DT% LSS 10 set DT=0%DT%
- if %MT% LSS 10 set MT=0%MT%
- set DAT=%MT%/%DT%/%YT%
- :TTH
- set HR=0
- set HMR=0
- set /p HR= "What Starting Hour? [ ##, No Leading Zero / Enter for 00]: "
- if %HR% LSS 0 (echo Wrong Hour & goto TTH)
- if %HR% GTR 23 (echo Wrong Hour & goto TTH)
- if %HR% LSS 10 set HR=0%HR%
- :TTM
- set /p HMR= "What Starting Minutes in Hour? [ ##, No Leading Zero / Enter for 00]: "
- if %HMR% LSS 0 (echo Wrong Minute & goto TTM)
- if %HMR% GTR 59 (echo Wrong Minute & goto TTM)
- if %HMR% LSS 10 set HMR=0%HMR%
- set TIME=%HR%:%HMR%
- set /p LONG= "How Long in Minutes?: "
- set /a L=(%LONG%*60)-5
- set AUG=:sout=#duplicate{dst=file{dst=%FD%%SW%%SP%%F%},dst=display} --run-time=%L%
- set PSN=TS
- call :PSFC
- schtasks /create /tn "%SW%%SP%" /tr "\"%VLC%\" %IP%%CHAN% %AUG% vlc://quit" /sc once /st %TIME% /sd %DAT%
- call :PSFCr
- goto RE2
- :DC
- :: Verifies Days Exist in calendar
- if %DT% LSS 0 goto DFC
- if %DT% LSS 1 (echo Program altered & pause & goto End)
- if %MT% LSS 1 (echo Program altered & pause & goto End)
- if %MT% GTR 12 (echo Program altered & pause & goto End)
- if %MT% EQU 1 goto D31
- if %MT% EQU 2 goto D28
- if %MT% EQU 3 goto D31
- if %MT% EQU 4 goto D30
- if %MT% EQU 5 goto D31
- if %MT% EQU 6 goto D30
- if %MT% EQU 7 goto D31
- if %MT% EQU 8 goto D31
- if %MT% EQU 9 goto D30
- if %MT% EQU 10 goto D31
- if %MT% EQU 11 goto D30
- if %MT% EQU 12 goto D31
- :D31
- if %DT% GTR 31 goto DFC
- Goto DR
- :D30
- if %DT% GTR 30 goto DFC
- goto DR
- :D28
- :: Leap Year, Verifying February Days & accounting for leap years w/o hard coding years
- set MDC=0
- set /a MDC=(%YT%/4)*4
- if %YT% EQU %MDC% ( set /a MDC=(%YT%/100)*100) else (goto LYF)
- if %YT% EQU %MDC% ( set MDC=0 & set /a MDC=(%YT%/400)*400 & if %YT% EQU %MDC% ( set MDC=0) else (goto LYF) )
- goto LYP
- :LYF
- if %DT% GTR 28 goto DFC
- goto DR
- :LYP
- if %DT% GTR 29 goto DFC
- goto DR
- :DFC
- echo Invalid Day & goto MR
- :DVC
- set DAC=0
- :: Verifies Selected Date is set in the current or future
- call :SD3
- if %YT% LEQ %TYV% set /a DAC=%DAC%+1
- if %MT%==08 set MT=8
- if %MT%==09 set MT=9
- if %MT% LEQ %TMV% set /a DAC=%DAC%+1
- if %DT% LSS %TDV% set /a DAC=%DAC%+1
- if %DAC% LSS 3 Goto DVP
- echo Invalid Date selection. %MT%/%DT%/%YT% [Month/Day/Year] is in the past, or check your calander.
- goto MMM
- :SDD
- ::To avoid base 8 conflicts.
- :: PowerShell to adjust date format, allowing usage of this batch file despite the preferred or default date format
- set PSN=D
- call :PSFC
- set TDV=0
- if %date:~3,2% GEQ 10 ( set TDV=%date:~3,2%) else ( set TDV=%date:~4,1%)
- call :PSFCr
- exit /b
- :SDM
- ::To avoid base 8 conflicts.
- set PSN=M
- call :PSFC
- set TMV=0
- if %date:~0,2% GEQ 10 ( set TMV=%date:~0,2%) else ( set TMV=%date:~1,1%)
- call :PSFCr
- exit /b
- :SDY
- ::To avoid Conflicts
- set PSN=Y
- call :PSFC
- set TYV=%date:~6,4%
- call :PSFCr
- exit /b
- :SD3
- :: Used to get all 3, at once & generate a 5th file, incase system steps on itself with writing/deleting the same file.
- set PSN=3
- call :PSFC
- if %date:~3,2% GEQ 10 ( set TDV=%date:~3,2%) else ( set TDV=%date:~4,1%)
- if %date:~0,2% GEQ 10 ( set TMV=%date:~0,2%) else ( set TMV=%date:~1,1%)
- set TYV=%date:~6,4%
- call :PSFCr
- exit /b
- :PSFC
- ::Creates Powershell script to change short date format & calls the first one
- powershell -command "$cul = Get-Culture;$Store = $cul.datetimeformat.shortdatepattern;Write-output $Store > VLCDFS%PSN%.txt;$Cul.DateTimeFormat.ShortDatePattern = 'MM/dd/yyyy';Set-Culture $Cul"
- exit /b
- :PSFCr
- powershell -command "$DF = Get-Content VLCDFS%PSN%.txt;$cul = Get-Culture;$cul.datetimeformat.shortdatepattern = $DF;Set-Culture $cul;remove-item VLCDFS%PSN%.txt"
- exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement