VRT NU & VRT MAX
- Roep het TV-journaal van 13u van gisteren op als het voor 14u is, anders dat van vandaag.
- Roep De Nacht van Radio 1 op van afgelopen nacht.
1) Batch file(s)
1.a VrtNuHetJournaal.bat
REM YESTERDAY
@echo off
set day=-1
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YYYY=%result:~0,4%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "TYesterday=%yyyy%%mm%%dd%"
REM TODAY
Set TToday=%date:~6,4%%date:~3,2%%date:~0,2%
set THour=%time:~0,2%
REM YESTERDAY OR TODAY
IF %time:~0,2% lss 14 (
set URL=https://www.vrt.be/vrtnu/a-z/het-journaal/2020/het-journaal-het-journaal-13u-%TYesterday%/
) ELSE (
set URL=https://www.vrt.be/vrtnu/a-z/het-journaal/2020/het-journaal-het-journaal-13u-%TToday%/
)
REM EXECUTE
start %URL%
1.b VrtMaxDeNachtVanRadio1.bat
@ECHO OFF
ECHO.
:: Check the Windows version
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
:: Check the number of command line arguments
REM IF "%~1"=="" GOTO Syntax
REM IF NOT "%~7"=="" GOTO Syntax
REM YESTERDAY
set day=-1
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "yesterday=%%a"
REM echo %yesterday%
set "YYYY=%yesterday:~0,4%"
set "MM=%yesterday:~4,2%"
set "DD=%yesterday:~6,2%"
set "TYesterday=%dd%/%mm%/%yyyy%"
:: Initialize variables
SET Date1=%TYesterday%
REM echo %Date1%
SET Date2=01/01/1970
REM echo %Date2%
SET iDate=
SET sDate=
FOR /F "skip=1 tokens=2*" %%A IN ('REG.EXE Query "HKCU\Control Panel\International" /v iDate') DO SET iDateLocal=%%~B
FOR /F "skip=1 tokens=2*" %%A IN ('REG.EXE Query "HKCU\Control Panel\International" /v sDate') DO SET sDateLocal=%%~B
FOR %%A IN (%Date%) DO SET Today=%%A
SET Verbose=0
SET Debug=0
TYPE "%~f0" | FINDSTR.EXE /R /B /I /C:":: *@ECHO OFF" >NUL && SET Debug=1
:: parse command line
FOR %%A IN (%*) DO (
SET Arg=%%~A
IF "%Debug%"=="1" ECHO Arg=%%~A
IF "!Arg:~0,1!"=="/" (
IF /I "!Arg:~0,2!"=="/I" (
IF "!iDate!"=="" (
SET iDate=!Arg:~3!
IF "%Debug%"=="1" ECHO iDate=!iDate!
IF "%Debug%"=="1" ECHO iDateLocal=%iDateLocal%
) ELSE (
ECHO Duplicate switch /i
ECHO.
GOTO Syntax
)
) ELSE (
IF /I "!Arg:~0,2!"=="/S" (
IF "!sDate!"=="" (
SET sDate=!Arg:~3!
IF "%Debug%"=="1" ECHO sDate=!sDate!
) ELSE (
ECHO Duplicate switch /s
ECHO.
GOTO Syntax
)
) ELSE (
IF /I "!Arg!"=="/V" (
IF "!Verbose!"=="0" (
SET Verbose=1
IF "%Debug%"=="1" SET Verbose
) ELSE (
ECHO Duplicate switch /v
ECHO.
GOTO Syntax
)
) ELSE (
IF /I "!Arg:~0,2!"=="/D" (
SET Debug=1
SET Debug
) ELSE (
ECHO Invalid command line switch !Arg!
ECHO.
GOTO Syntax
)
)
)
)
) ELSE (
IF "!Date1!"=="" (
SET Date1=%%A
IF "%Debug%"=="1" SET Date1
) ELSE (
IF "!Date2!"=="" (
SET Date2=%%A
IF "%Debug%"=="1" SET Date2
) ELSE (
ECHO Too many dates on command line
ECHO.
GOTO Syntax
)
)
)
)
SET iDateEnum.0=Month%sDate%Day%sDate%Year
SET iDateEnum.1=Day%sDate%Month%sDate%Year
SET iDateEnum.2=Year%sDate%Month%sDate%Day
REM :: Use today for second date if not spedified
REM IF "%Date2%"=="" (
REM IF %Debug%%Verbose% GEQ 1 SET Today
REM IF %Debug%%Verbose% GEQ 1 SET Date2
REM IF NOT "%iDate%%sDate%"=="" (
REM CALL :ParseDate %Today% %iDateLocal% %sDateLocal%
REM IF %iDate%==0 SET Today=!GMonth!%sDate%!GDay!%sDate%!GYear!
REM IF %iDate%==1 SET Today=!GDay!%sDate%!GMonth!%sDate%!GYear!
REM IF %iDate%==2 SET Today=!GYear!%sDate%!GMonth!%sDate%!GDay!
REM )
REM SET Date2=!Today!
REM IF %Debug%%Verbose% GEQ 1 SET Today
REM IF %Debug%%Verbose% GEQ 1 SET Date2
REM )
:: Use local date format if no alternative was specified
IF "%iDate%"=="" SET iDate=%iDateLocal%
IF "%sDate%"=="" SET sDate=%sDateLocal%
IF "%verbose%"=="1" (
ECHO Date format used:
ECHO iDate=%iDate% ^(!iDateEnum.%iDate%!^)
SET Local_iDate=!iDateEnum.%iDateLocal%!
SET Local_iDate=!Local_iDate:%sDate%=%sDateLocal%!
ECHO iDateLocal=%iDateLocal% ^(!Local_iDate!^)
SET sDate
ECHO.
)
:: Check if the first date is valid
(ECHO.%Date1%) | FINDSTR /R /B /C:"[0-9]*%sDate%[0-9]*%sDate%[0-9]*" >NUL
IF ERRORLEVEL 1 (
ECHO Error: %Date1% is not a valid date
ECHO.
GOTO Syntax
)
:: Check if the second date is valid
(ECHO.%Date2%) | FINDSTR /R /B /C:"[0-9]*%sDate%[0-9]*%sDate%[0-9]*" >NUL
IF ERRORLEVEL 1 (
ECHO Error: %Date2% is not a valid date
ECHO.
GOTO Syntax
)
:: Parse the first date
CALL :ParseDate %Date1%
IF "%Verbose%"=="1" (
ECHO Date1=%Date1%
SET GYear
SET GMonth
SET GDay
ECHO.
)
IF %GDay% GTR 31 (
ECHO Invalid date, day cannot be greater than 31
ECHO.
GOTO Syntax
)
IF %GMonth% GTR 12 (
ECHO Invalid date, month cannot be greater than 12
ECHO.
GOTO Syntax
)
:: Convert the parsed Gregorian date to Julian
CALL :JDate %GYear% %GMonth% %GDay%
IF "%Verbose%"=="1" (
ECHO Julian Date1
SET JDate
ECHO.
)
:: Save the resulting Julian date
SET JDate1=%JDate%
:: Parse the second date
CALL :ParseDate %Date2%
IF "%Verbose%"=="1" (
ECHO Date2=%Date2%
SET GYear
SET GMonth
SET GDay
ECHO.
)
IF %GDay% GTR 31 (
ECHO Invalid date, day cannot be greater than 31
ECHO.
GOTO Syntax
)
IF %GMonth% GTR 12 (
ECHO Invalid date, month cannot be greater than 12
ECHO.
GOTO Syntax
)
:: Convert the parsed Gregorian date to Julian
CALL :JDate %GYear% %GMonth% %GDay%
IF "%Verbose%"=="1" (
ECHO Julian Date2
SET JDate
ECHO.
)
:: Calculate the absolute value of the difference in days
IF %JDate% GTR %JDate1% (
SET /A DateDiff = %JDate% - %JDate1%
) ELSE (
SET /A DateDiff = %JDate1% - %JDate%
)
:: Format output for singular or plural
SET Days=days
IF %DateDiff% EQU 1 SET Days=day
:: Prefix value with a minus sign if negative
IF %JDate% GTR %JDate1% SET DateDiff=-%DateDiff%
:: Display the result
REM ECHO First date : %Date1%
REM ECHO Second date : %Date2%
REM ECHO Difference : %DateDiff% %Days%
REM ECHO %DateDiff%
REM nummerwaarde van weekday: https://stackoverflow.com/questions/15111557/using-powershell-how-do-you-get-the-weekday-number
for /f %%i in ('powershell "(get-date).AddDAys(-1)".DayOfWeek.value__') do set dow=%%i
set /a dow = %dow%+1
REM ECHO dow: %dow%
FOR %%G IN ("2"
"3"
"4"
"5") DO (
IF /I "%dow%"=="%%~G" GOTO MonToThurs
)
FOR %%G IN ("6"
"7") DO (
IF /I "%dow%"=="%%~G" GOTO FriAndSat
)
FOR %%G IN ("1") DO (
IF /I "%dow%"=="%%~G" GOTO Sun
)
:MonToThurs
REM =ROUNDDOWN("22"&(NUMBERVALUE((DATEVALUE(TEXT(F3;"jjjj-mm-dd"))-DATEVALUE("1970-01-01")))*86400/604800*4)-10437,5+(1/10*J3);0)
rem https://www.vrt.be/vrtnu/luister/radio/d/de-nacht-van-radio-1~11-22/de-nacht-van-radio-1~11-22672-0/
set /a result = %DateDiff%*86400/6048*4
REM echo %result%
set /a result = (%result%-1043710+(2*%dow%))/100
REM echo %result%
set /a result = 22000+%result%
IF /I "%dow%"=="2" set /a result = %result%-1
REM echo %result%
GOTO LUISTER
:FriAndSat
REM ="22"&ROUNDDOWN((NUMBERVALUE((DATEVALUE(TEXT(F7;"jjjj-mm-dd"))-DATEVALUE("1970-01-01")))*86400/604800*2)-4832+(1/10*J7);0)
rem https://www.vrt.be/vrtnu/luister/radio/d/de-nacht-van-radio-1~11-22/de-nacht-van-radio-1~11-22724-0/
set /a result = %DateDiff%*86400/60480*2
set /a result = (%result%-48314+(1/10*%dow%))/10
REM echo %result%
set /a result = 22000+%result%
REM echo result: %result%
GOTO LUISTER
:Sun
REM =ROUNDDOWN("22"&(NUMBERVALUE((DATEVALUE(TEXT(F2;"jjjj-mm-dd"))-DATEVALUE("1970-01-01")))*86400/604800*1)-2170+(1/10*J2);0)
rem https://www.vrt.be/vrtnu/luister/radio/d/de-nacht-van-radio-1~11-22/de-nacht-van-radio-1~11-22608-0/
set /a result = %DateDiff%*86400/604800*1
set /a result = %result%-2170+(1/10*%dow%)
set /a result = 22000+%result%
GOTO LUISTER
:LUISTER
set URL=https://www.vrt.be/vrtnu/luister/radio/d/de-nacht-van-radio-1~11-22/de-nacht-van-radio-1~11-%result%-0/
REM EXECUTE
start %URL%
GOTO :EOF
REM :: Return the result in a variable named after this batch file
REM ENDLOCAL & SET %~n0=%DateDiff%
GOTO:EOF
::===================================::
:: ::
:: - S u b r o u t i n e s - ::
:: ::
::===================================::
:JDate
:: Convert date to Julian
:: Arguments : YYYY MM DD
:: Returns : Julian date
::
:: First strip 1 or 2 leading zeroes; a logical error in this
:: routine was corrected with help from Alexander Shapiro
SET MM=%2
SET DD=%3
IF "%MM:~0,1%"=="0" IF NOT "%MM%"=="0" SET MM=%MM:~1%
IF "%MM:~0,1%"=="0" IF NOT "%MM%"=="0" SET MM=%MM:~1%
IF "%DD:~0,1%"=="0" IF NOT "%DD%"=="0" SET DD=%DD:~1%
IF "%DD:~0,1%"=="0" IF NOT "%DD%"=="0" SET DD=%DD:~1%
::
:: Algorithm based on Fliegel-Van Flandern
:: algorithm from the Astronomical Almanac,
:: provided by Doctor Fenton on the Math Forum
:: (http://mathforum.org/library/drmath/view/51907.html),
:: and converted to batch code by Ron Bakowski.
SET /A Month1 = ( %MM% - 14 ) / 12
SET /A Year1 = %1 + 4800
SET /A JDate = 1461 * ( %Year1% + %Month1% ) / 4 + 367 * ( %MM% - 2 -12 * %Month1% ) / 12 - ( 3 * ( ( %Year1% + %Month1% + 100 ) / 100 ) ) / 4 + %DD% - 32075
FOR %%A IN (Month1 Year1) DO SET %%A=
GOTO:EOF
:ParseDate
:: Parse (Gregorian) date depending on registry's date format settings
:: Argument : Gregorian date in local date format, optional iDate and sDate alternatives (in that order)
:: Requires : sDate (local date separator), iDate (local date format number)
:: Returns : GYear (4-digit year), GMonth (2-digit month), GDay (2-digit day)
::
SET iDateUsed=%iDate%
SET sDateUsed=%sDate%
IF NOT "%~2"=="" SET iDateUsed=%~2
IF NOT "%~3"=="" SET sDateUsed=%~3
IF %iDateUsed%==0 FOR /F "TOKENS=1-3 DELIMS=%sDateUsed%" %%A IN ("%~1") DO (
SET GYear=%%~C
SET GMonth=%%~A
SET GDay=%%~B
)
IF %iDateUsed%==1 FOR /F "TOKENS=1-3 DELIMS=%sDateUsed%" %%A IN ("%~1") DO (
SET GYear=%%~C
SET GMonth=%%~B
SET GDay=%%~A
)
IF %iDateUsed%==2 FOR /F "TOKENS=1-3 DELIMS=%sDateUsed%" %%A IN ("%~1") DO (
SET GYear=%%~A
SET GMonth=%%~B
SET GDay=%%~C
)
SET iDateUsed=
SET sDateUsed=
GOTO:EOF
:Syntax
ECHO DateDiff.bat, Version 1.11 for Windows XP .. 10
ECHO Calculate the difference (in days) between two dates
ECHO.
ECHO Usage: DATEDIFF date [ date [ /i:iDate ] [ /s:sDate ] ] [ /v ]
ECHO.
ECHO Where: "date" is a "normal" Gregorian date in the computer's
ECHO local format; if no second date is specified,
ECHO today is assumed
ECHO /i:iDate specify alternative date format:
ECHO iDate = 0 for month/day/year format
ECHO iDate = 1 for day/month/year format
ECHO iDate = 2 for year/month/day format
ECHO /s:sDate specify alternative date separator
ECHO (/ or - or . or whatever you want)
ECHO /v Verbose output
ECHO.
ECHO Julian date conversion based on Fliegel-Van Flandern algorithms from
ECHO the Astronomical Almanac, provided by Doctor Fenton on the Math Forum
ECHO (http://mathforum.org/library/drmath/view/51907.html), and converted
ECHO to batch code by Ron Bakowski.
ECHO Bug found by and corrected with help from Alexander Shapiro.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
IF "%OS%"=="Windows_NT" ENDLOCAL
EXIT /B 1
2) SameName.vbs
Hide the DOS box by using a .vbs script alongside the .bat file with the same name:
Dim scriptName : scriptName = WScript.ScriptFullName
scriptName = Left(scriptName, Len(scriptName) - 4) & ".bat"
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & scriptName & Chr(34), 0
Set WshShell = Nothing
3) Pin to start
Source:
https://social.technet.microsoft.com/Forums/en-US/dd2b13ef-2968-4f23-b531-57d1e9d634e3/if-you-guys-have-been-trying-hard-to-pin-vbs-files-to-your-start-menu-in-windows-10-look-no?forum=ITCG&prof=required
If you rightclick the .vbs file, you'll notice there's no 'Pin to Start' option.
There's a simple trick to solve this:
- modify the .vbs extension into .exe
- rightclick the .exe and choose Pin to Start
- rename the .exe back to .vbs
- now go to %AppData%\Microsoft\Windows\Start Menu\Programs
- rightclick the shortcut you've just created and change .exe into .vbs in the Target field
4) Add the right icon
- open the VRT NU site in the Edge browser
- choose … (Settings and more) > Apps > Install this site as an app
- in the dialog that appears, choose the Install button
- click Start, then rightclick the recently added app
- choose More > Open file location
- rightclick > Properties
- click the Change Icon… button and copy what's in the field
- now open the Properties > Change Icon… of the .vbs shortcut (from 3)), in the same location
- paste the copied value here and confirm
Now your .vbs shortcut has the right icon. You can safely delete the site app.