NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Legacy (v4.x and earlier) v
« Previous 1 … 161 162 163 164 165 … 433 Next »
updateepg.bat script to check if a recording is in progress before update

updateepg.bat script to check if a recording is in progress before update
snagglewest
Offline

Senior Member

VA USA
Posts: 361
Threads: 60
Joined: Jul 2011
#1
2015-10-03, 05:28 PM
I'm trying to get a script running that checks if a recording is in progress before updating the EPG. My updates are scheduled to run at 5am, not a time I normally have recordings going, but ever once in a while it presents a problem. I messed around with this a while back but couldn't get it working. Having lost another recording has motivated me to fix it. I good while ago I found a snippet that is supposed to check if a recording is in progress and wait until it's done before starting the EPG update. Unfortunately running the bat file seems to put the script into a loop and never actually does anything. I added some simple logging to the script so I could see were the problem occurs. There's nothing recording but the script just keeps restarting itself. Could someone script savvy take a look and see if there's any glaring errors that might be causing

Code:
@ECHO off
REM Update EPG only if not recording

ECHO -------------------------- >> epg.log
ECHO Starting new updateEPG BAT file run - %time%>> epg.log

CD /d "%~dp0"
:loop
set chknpvr=1
"c:\Program Files (x86)\NPVR\NScriptHelper.exe" -isInUse | find "NOT RECORDING"
set chknpvr=%ERRORLEVEL%
if %chknpvr% NEQ 0 timeout 300
if %chknpvr% NEQ 0 goto loop
if %chknpvr% EQU 0 "C:\Program Files (x86)\NPVR\NextPVR.exe" -updateepgonly
ECHO updateEPG BAT complete - %time%>> epg.log
exit

And here's a portion of the log that gets generated.

Code:
Starting new updateEPG BAT file run - 13:07:56.88
--------------------------
Starting new updateEPG BAT file run - 13:07:58.18
--------------------------
Starting new updateEPG BAT file run - 13:07:59.50
--------------------------
Starting new updateEPG BAT file run - 13:08:00.80
--------------------------
Starting new updateEPG BAT file run - 13:08:02.09
--------------------------
Starting new updateEPG BAT file run - 13:08:03.43
--------------------------
Starting new updateEPG BAT file run - 13:08:04.73
--------------------------
Starting new updateEPG BAT file run - 13:08:06.01
--------------------------
Starting new updateEPG BAT file run - 13:08:07.30
--------------------------
Starting new updateEPG BAT file run - 13:08:08.58
--------------------------
Starting new updateEPG BAT file run - 13:08:09.89
--------------------------
Starting new updateEPG BAT file run - 13:08:11.23
--------------------------
Starting new updateEPG BAT file run - 13:08:12.52

Snag
NextPVR V6.1.5.231022 - Ubuntu 22.04 VM / 4 core / 8Gb memory
HDHR Prime X2 / HDFX-2 /Schedule Direct / 2X Pi4 + & 3X Pi3 LibreELEC Kodi clients
Server - TrueNAS/ SuperMicro MBD-X10SL7-F MB / Xeon E3-1246 / 32Gb Unbuffered ECC / 8 X 4TB RAIDZ2
dixxfixx
Offline

Member

Posts: 149
Threads: 5
Joined: Nov 2007
#2
2015-10-03, 05:47 PM
I am not a rocket surgeon or NextPVR script expert, but I'll bet that when the script calls -updateepgonly, NextPVR first calls the updateepg.bat script, which then calls -updateepgonly, which calls the updateepg.bat script again, etc. Rinse and repeat. Probably just leave that call out, 'cause it's already headed that way when the script terminates.
WinXP SP3 A8V-X Athlon 64 FX-60 2.60GHz 2GB
NextPVR 3.4.8
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#3
2015-10-03, 06:55 PM (This post was last modified: 2015-10-03, 07:05 PM by JavaWiz.)
Try the below script... A few notes:
  • Update the BASEPDIR to reflect your system
  • Update the DEBUG variable to FALSE once debugging is complete, so the script won't pause at the end.
The script will create a log and output to the screen. Also, I've commented out the -UpdateEpgOnly call, much for the same reason dixxfixx identified in prior post.

Code:
@ECHO off
REM Update EPG only if not recording

Set DEBUG=TRUE
Set BASEUDIR=c:\Users\Public\NPVR
REM Set BASEPDIR=c:\Program Files (x86)\NPVR
Set BASEPDIR=c:\Program Files\NPVR

Set LOGFILE="%BASEUDIR%\Logs\EpgCheck.log"
Set NSHELPER="%BASEPDIR%\NScriptHelper.exe"
Set NPVR="%BASEPDIR%\NextPVR.exe"

CALL :LOGMSG
CALL :LOGMSG -----------------------------------------------
CALL :LOGMSG Begin EPG Update process

:VALIDATEENV
    CALL :LOGMSG Validating Environment
    FOR %%i IN ("%BASEUDIR%") DO IF NOT EXIST %%~si\NUL (
        CALL :LOGMSG ABORT: Base user directory does not exist. Check script variable BASEUDIR
        GOTO :ENDJOB
    )
    FOR %%i IN ("%BASEPDIR%") DO IF NOT EXIST %%~si\NUL (
        CALL :LOGMSG ABORT: Base Program directory does not exist. Check script variable BASEPDIR
        GOTO :ENDJOB
    )
    FOR %%i IN (%NSHELPER%) DO IF NOT EXIST %%~si (
        CALL :LOGMSG ABORT: NScriptHelper.exe does not exist. Check script variable NSHELPER
        GOTO :ENDJOB
    )
    FOR %%i IN (%NPVR%) DO IF NOT EXIST %%~si (
        CALL :LOGMSG ABORT: NextPVR.exe does not exist. Check script variable NPVR
        GOTO :ENDJOB
    )
    
    set chknpvr=1
:LOOP
    CALL :LOGMSG Check to see if any recording in progress...
    %NSHELPER% -isInUse >> %LOGFILE%
    %NSHELPER% -isInUse -isInUse | find "NOT RECORDING"
    set chknpvr=%ERRORLEVEL%
    REM CALL :LOGMSG isInUse returns %chknpvr%
    if %chknpvr% NEQ 0 (
        timeout 300
        GOTO :LOOP
    )
    CALL :LOGMSG No recordings in progress, update the EPG.
    REM %NPVR% -updateepgonly
    CALL :LOGMSG EPG Update complete
    GoTo :ENDJOB

--------------------------------------------------------------------------------------------
:LOGMSG
    if "%*". EQU "". (
        echo.
    ) else (
        echo %*
    )
    echo %date% %time% %* >> %LOGFILE%
    Goto :EOF

--------------------------------------------------------------------------------------------
:ENDJOB
    If %DEBUG% EQU TRUE Pause
My log looks like this:
Quote:Sat 10/03/2015 11:49:22.39 -----------------------------------------------
Sat 10/03/2015 11:49:22.40 Begin EPG Update process
Sat 10/03/2015 11:49:22.41 Validating Environment
Sat 10/03/2015 11:49:22.42 Check to see if any recordings in progress...
RECORDING
Sat 10/03/2015 11:49:41.06 Check to see if any recordings in progress...
RECORDING
Sat 10/03/2015 11:49:52.88 Check to see if any recordings in progress...
NOT RECORDING
Sat 10/03/2015 11:49:55.11 No recordings in progress, update the EPG.
Sat 10/03/2015 11:49:55.13 EPG Update complete
snagglewest
Offline

Senior Member

VA USA
Posts: 361
Threads: 60
Joined: Jul 2011
#4
2015-10-03, 09:46 PM
Thinking about it I suspect you're correct that the EPGupdate script calls the updateepg.bat again which starts the loop.

Wiz, does leaving off the -updateepgonly mean Npvr opens the user interface? If so does it stay open and update the EPG? I've no idea exactly how it works behind the scene. I haven't tested it yet, I have a recording going right now. I'll wait till it finishes in case I jack things up Smile

Snag
NextPVR V6.1.5.231022 - Ubuntu 22.04 VM / 4 core / 8Gb memory
HDHR Prime X2 / HDFX-2 /Schedule Direct / 2X Pi4 + & 3X Pi3 LibreELEC Kodi clients
Server - TrueNAS/ SuperMicro MBD-X10SL7-F MB / Xeon E3-1246 / 32Gb Unbuffered ECC / 8 X 4TB RAIDZ2
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#5
2015-10-04, 12:32 AM
snagglewest Wrote:Wiz, does leaving off the -updateepgonly mean Npvr opens the user interface? If so does it stay open and update the EPG? I've no idea exactly how it works behind the scene. I haven't tested it yet, I have a recording going right now. I'll wait till it finishes in case I jack things up Smile

Snag
The line
Code:
REM %NPVR% -updateepgonly
Is fully commented out. NextPVR is not called. When the EPG updates, the UI is not visible.

To my understanding, the process works as follows
  • Based on the settings in the config, the EPG update is called (via the recording service) at the target config time.
  • The batch file EPGUpdate.bat is called, this will run commands prior to NextPVR actually updating the EPG (such as running XMLTV or other pre-processor)
  • Once batch file completes, the recording service updates the EPG (i.e. you don't have to call nextpvr with -updateepg) No visible UI.
snagglewest
Offline

Senior Member

VA USA
Posts: 361
Threads: 60
Joined: Jul 2011
#6
2015-10-04, 01:47 AM
Thanks for the script Wiz, I think I have it working now. I tried it by forcing an update and it seems to have worked correctly. I'll let it run at 5am and hopefully everything goes as planned!

Snag
NextPVR V6.1.5.231022 - Ubuntu 22.04 VM / 4 core / 8Gb memory
HDHR Prime X2 / HDFX-2 /Schedule Direct / 2X Pi4 + & 3X Pi3 LibreELEC Kodi clients
Server - TrueNAS/ SuperMicro MBD-X10SL7-F MB / Xeon E3-1246 / 32Gb Unbuffered ECC / 8 X 4TB RAIDZ2
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#7
2015-10-04, 03:22 AM
Make sure you set DEBUG=FALSE or it will get stuck on the PAUSE statement.
dixxfixx
Offline

Member

Posts: 149
Threads: 5
Joined: Nov 2007
#8
2015-10-04, 05:17 AM
As long as we're having scripting class, why are there two "-isInUse" options in "%NSHELPER% -isInUse -isInUse | find "NOT RECORDING""? What does that do?
WinXP SP3 A8V-X Athlon 64 FX-60 2.60GHz 2GB
NextPVR 3.4.8
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#9
2015-10-04, 05:48 AM
dixxfixx Wrote:As long as we're having scripting class, why are there two "-isInUse" options in "%NSHELPER% -isInUse -isInUse | find "NOT RECORDING""? What does that do?
The first one directs the results to the log file
the second one is used to search for the "NOT RECORDING" string.

I did that mostly to debug the script, so I could see what NScriptHelper was returning.
dixxfixx
Offline

Member

Posts: 149
Threads: 5
Joined: Nov 2007
#10
2015-10-04, 06:02 AM
No, I mean where there's two in the second line, together, like I quoted.
WinXP SP3 A8V-X Athlon 64 FX-60 2.60GHz 2GB
NextPVR 3.4.8
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  EPG Update Errors jcole998 23 1,941 2025-05-11, 06:03 PM
Last Post: mvallevand
  Recording movies / TV to XBMC directory stucture spinnaker 10 3,718 2024-06-03, 03:56 AM
Last Post: Rod Hutchinson
  Not recording errors vidwiz 4 1,089 2024-04-17, 05:39 PM
Last Post: mvallevand
  Add Series/Episode Info to Recording Metadata andrewj 2 1,152 2023-11-20, 03:42 PM
Last Post: sub
  Device Update - Channel Mapping chezmorris 10 4,837 2022-07-01, 01:59 PM
Last Post: mvallevand
  Recording to a network drive woes. 2leftfeet 12 7,384 2022-04-05, 08:03 PM
Last Post: mvallevand
  ITV/BBC HD and EPG missing from scan and update angelisle 16 4,324 2021-08-26, 11:45 AM
Last Post: NumberFive
  device needed for recording David209 2 1,773 2021-04-04, 08:47 AM
Last Post: David209
  PC not going to sleep after recording LeoL 7 3,412 2021-04-01, 07:17 PM
Last Post: Handy.Man
  HDHomerun recording bizzarely not working Jean0987654321 3 2,120 2021-03-27, 03:23 PM
Last Post: Jean0987654321

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode