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 … 407 408 409 410 411 … 433 Next »
Help with SQL query for querying recordings in NPVR.db3

Help with SQL query for querying recordings in NPVR.db3
b00sfuk
Offline

Senior Member

Posts: 319
Threads: 26
Joined: Mar 2005
#1
2010-06-22, 07:22 AM
Any SQL gurus out there? I need a bit of help please in completing an SQL query to retrieve the next pending & in-progress recordings from the new schema in the NPVR.db3 database.
Using GBPVRWAKE, postprocessing.bat & parallelprocessing.bat I pipe these into a text file so I can use LCDSmartie to display them on my iMON VFD. This means theat I can easily see if anything is recording or about to record and for example I don't then put the PC into standby if there is. Also when the PC is in standby it displays the time the PC will wake for its next recording. With GBPVR this function was provided by the GBPVRCli program (provided as part of the SlimmGBPVR utility); the auther has confirmed this is not planned to be updated for NPVR.

I've got this far modifying SQL that I've plagiarised from the forum (thanks pBS) which runs via the SQLITE3 command line utility .
Code:
REM pending 3 recordings
"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" > "C:\Users\Public\NPVR\EXTRAS\PendName.txt"

"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT strftime('%%d-%%m %%H:%%M',start_time) from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" > "C:\Users\Public\NPVR\EXTRAS\PendTime.txt"

Rem IN-PROGRESS recordings (for upto three tuners)
"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" > "C:\Users\Public\NPVR\EXTRAS\ProgName.txt"

"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT strftime('%%H:%%M',end_time) from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" > "C:\Users\Public\NPVR\EXTRAS\ProgTime.txt"

REM next pending recording for USBPORT file for display during standby
"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '0' order by start_time limit 1;" > "C:\UTILS\LCDsmartie\USBPortExit.txt"

"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT strftime('%%d-%%m %%H:%%M',start_time) from SCHEDULED_RECORDING where status = '0' order by start_time limit 1;" >> "C:\UTILS\LCDsmartie\USBPortExit.txt"
What I need a bit of help with please is:

1. The times returned for start/end time are an hour early. I assume this is as actual time (in UK) is currently BST but it is reporting GMT (or UMT).

2. I can get 'name', 'start_time' & 'end_time' but 'subtitle' is now only kept within an XML subfields structure in the 'event_details' field shown below. I can't see an easy way to get at just this.
Code:
<Event>
  <OID>752285</OID>
  <Title>Match of the Day</Title>
  <SubTitle>World Cup 2010</SubTitle>
  <Description>Colin Murray presents highlights of the day&apos;s three group matches, with all the reaction from England&apos;s clash with Algeria in Cape Town. The day&apos;s other Group C game sees the USA take on Slovenia in Johannesburg, while Germany meet Serbia in Group D.</Description>
  <ChannelOID>6864</ChannelOID>
  <StartTime>2010-06-18T21:00:00.0000000</StartTime>
  <EndTime>2010-06-18T21:30:00.0000000</EndTime>
</Event>
Thanks
Silverstone LC10M with iMON
Gigabyte 780G+4850e, AMD 6570
Blackgold BGT3620, Harmony 555 Remote
Win7 32-bit, SAF
martint123
Offline

Posting Freak

UK, East Yorkshire
Posts: 4,658
Threads: 208
Joined: Nov 2005
#2
2010-06-22, 10:49 AM
Subscribing to this thread in the hope of stealing your code to display same on my Joggler Wink Snag is my sql is non-existent. sorry.
forzaKGB
Offline

Member

Posts: 235
Threads: 31
Joined: Mar 2006
#3
2010-06-22, 11:57 AM
If you don't mind using ssed you might do this:
ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" {XML-string or file-name}
b00sfuk
Offline

Senior Member

Posts: 319
Threads: 26
Joined: Mar 2005
#4
2010-06-22, 12:42 PM
forzaKGB Wrote:If you don't mind using ssed you might do this:
ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" {XML-string or file-name}

Ideally I'd like to keep it clean in the SQL but this is certainly an option to grab the whole record and then post-process the text file. Thanks.
Silverstone LC10M with iMON
Gigabyte 780G+4850e, AMD 6570
Blackgold BGT3620, Harmony 555 Remote
Win7 32-bit, SAF
forzaKGB
Offline

Member

Posts: 235
Threads: 31
Joined: Mar 2006
#5
2010-06-22, 02:39 PM
Would something like this help?

"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT event_details from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" | ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" > "C:\Users\Public\NPVR\EXTRAS\SubTitle.txt"
b00sfuk
Offline

Senior Member

Posts: 319
Threads: 26
Joined: Mar 2005
#6
2010-06-23, 12:28 PM
forzaKGB Wrote:Would something like this help?

"sqlite3.exe" -separator " -- " "npvr.db3" "SELECT event_details from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" | ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" > "C:\Users\Public\NPVR\EXTRAS\SubTitle.txt"


Thanks, I'll probably end up using this but being a bit of a minimalist I'd prefer to do it in one tool rather than two!

Still need to find a solution to the data problem which will need SQL I think.
Silverstone LC10M with iMON
Gigabyte 780G+4850e, AMD 6570
Blackgold BGT3620, Harmony 555 Remote
Win7 32-bit, SAF
b00sfuk
Offline

Senior Member

Posts: 319
Threads: 26
Joined: Mar 2005
#7
2010-06-23, 09:20 PM (This post was last modified: 2010-06-23, 09:46 PM by b00sfuk.)
Think I solved this now with the help (thanks again to forzaKGB & pBS). I can now extract the details to text files of the next pending recordings and any in-progress ones. Times are local time and I can get at the XML subfields now. Details below in case it is of use to anybody.

Using the SSED utility mentioned above and the SQLITE3 command line utility (http://www.sqlite.org/download.html). This could be scheduled to run every few minutes, run in each of the NPVR batch files plus at wake/startup (like I do) or maybe called directly from within VFD/LCD software apps.


Code:
REM PENDING NEXT 3 RECORDINGS
REM Name
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" > "C:\Users\Public\NPVR\EXTRAS\PendName.txt"

REM Subtitle
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT event_details from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" | C:\Users\Public\NPVR\EXTRAS\ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" > "C:\Users\Public\NPVR\EXTRAS\PendSubT.txt"

REM Start Time
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT strftime('%%d-%%m %%H:%%M',datetime(start_time,'localtime')) from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" > "C:\Users\Public\NPVR\EXTRAS\PendTime.txt"


Rem IN-PROGRESS RECORDINGS (upto 3 to cover all tuners)
REM Name
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;"  "C:\Users\Public\NPVR\EXTRAS\ProgName.txt"

REM Subtitle
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT event_details from SCHEDULED_RECORDING where status = '1' order by start_time imit 3;" | C:\Users\Public\NPVR\EXTRAS\ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" > "C:\Users\Public\NPVR\EXTRAS\ProgSubT.txt"

REM End Time
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT strftime('%%H:%%M',datetime(end_time,'localtime')) from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" > "C:\Users\Public\NPVR\EXTRAS\ProgTime.txt"


REM PENDING NEXT 1 RECORDING for USBPORT
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '0' order by start_time limit 1;" > "C:\UTILS\LCDsmartie\USBPortExit.txt"

REM Name
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT strftime('%%d-%%m %%H:%%M',start_time) from SCHEDULED_RECORDING where status = '0' order by start_time limit 1;" >> "C:\UTILS\LCDsmartie\USBPortExit.txt"

REM Start Time
"C:\Users\Public\NPVR\EXTRAS\sqlite3.exe" -separator " -- " "C:\Users\Public\NPVR\npvr.db3" "SELECT strftime('%%d-%%m %%H:%%M',datetime(start_time,'localtime')) from SCHEDULED_RECORDING where status = '0' order by start_time limit 1;" >> "C:\UTILS\LCDsmartie\USBPortExit.txt"
Silverstone LC10M with iMON
Gigabyte 780G+4850e, AMD 6570
Blackgold BGT3620, Harmony 555 Remote
Win7 32-bit, SAF
b00sfuk
Offline

Senior Member

Posts: 319
Threads: 26
Joined: Mar 2005
#8
2010-06-24, 07:56 AM (This post was last modified: 2010-06-24, 11:42 AM by b00sfuk.)
Tidied up version & duplicated line removed. Could probably reduce the number of statements but this was easiest way to get what I wanted without learning more complex SQL. Needed each field on a new line for selection in LCDSmartie so it was easiest to run multiple times to output to separate files. I.E. using the LCDSmartie command $File(C:\Users\Public\NPVR\EXTRAS\PendName.txt,1) to show the 1st line of the file.
Code:
SET NDIR=C:\Users\Public\NPVR
SET LCDDIR=C:\UTILS\LCDsmartie

REM PENDING NEXT 3 RECORDINGS
REM Name
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" > "%NDIR%\EXTRAS\PendName.txt"

REM Subtitle
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT event_details from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" | %NDIR%\EXTRAS\ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" > "%NDIR%\EXTRAS\PendSubT.txt"

REM Start Time
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT strftime('%%d-%%m %%H:%%M',datetime(start_time,'localtime')) from SCHEDULED_RECORDING where status = '0' order by start_time limit 3;" > "%NDIR%\EXTRAS\PendTime.txt"


Rem IN-PROGRESS RECORDINGS (upto 3 to cover all tuners)
REM Name
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" > "%NDIR%\EXTRAS\ProgName.txt"

REM Subtitle
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT event_details from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" | %NDIR%\EXTRAS\ssed -n -e "s/.*<SubTitle>\(.*\)<\/SubTitle>.*/\1/p" > "%NDIR%\EXTRAS\ProgSubT.txt"

REM End Time
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT strftime('%%H:%%M',datetime(start_time,'localtime')) from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" > "%NDIR%\EXTRAS\ProgTime.txt"


REM PENDING NEXT 1 RECORDING for USBPORT FILE TO DISPLAY IN STANDBY USING LCDSMARTIE 5.3.2
REM Name
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT name from SCHEDULED_RECORDING where status = '0' order by start_time limit 1;" > "%LCDDIR%\USBPortExit.txt"

REM Start Time
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT strftime('%%d-%%m %%H:%%M',datetime(start_time,'localtime')) from SCHEDULED_RECORDING where status = '0' order by start_time limit 1;" >> "%LCDDIR%\USBPortExit.txt"
Silverstone LC10M with iMON
Gigabyte 780G+4850e, AMD 6570
Blackgold BGT3620, Harmony 555 Remote
Win7 32-bit, SAF
mikaelgu
Offline

Member

Posts: 114
Threads: 25
Joined: Oct 2004
#9
2010-09-23, 01:44 PM
Excellent code! Thank you so much, you saved me hours upon hours of hard labour, blood, sweat and probably tears aswell (not mine, the wife´s Wink ).
b00sfuk
Offline

Senior Member

Posts: 319
Threads: 26
Joined: Mar 2005
#10
2010-09-23, 01:53 PM
Glad it helped. Forget to update this thread but there is an error in one line of the final revision where it should be end-time not start time for in-progress recordings.
Code:
REM End Time
"%NDIR%\EXTRAS\sqlite3.exe" "%NDIR%\npvr.db3" "SELECT strftime('%%H:%%M',datetime([B]end_time[/B],'localtime')) from SCHEDULED_RECORDING where status = '1' order by start_time limit 3;" > "%NDIR%\EXTRAS\ProgTime.txt"
Silverstone LC10M with iMON
Gigabyte 780G+4850e, AMD 6570
Blackgold BGT3620, Harmony 555 Remote
Win7 32-bit, SAF
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Failed recordings won't delete Spid4567 3 2,494 2023-07-14, 10:13 PM
Last Post: ZeDoZ
  npvr is not responding johndutcher 3 1,500 2022-05-05, 07:57 PM
Last Post: sub
  NPVR 4.2.4 Video Library No Longer Shows folder.jpg Lao Pan 12 3,882 2022-04-14, 04:33 AM
Last Post: Antmannz
  All my recordings start 90 sec early ncsercs 2 1,368 2022-03-19, 03:28 AM
Last Post: sub
  nPVR Continually Wakes PC bfos 23 11,260 2022-02-17, 03:48 PM
Last Post: sub
  Can't find tuner filter in NPVR 4.05 on old XP machine (eee 701) with RTL2832U iamanotheruser 3 1,707 2022-01-03, 04:45 AM
Last Post: mvallevand
  Wake - Sleep Interaction -> Failed Recordings mikeh49 48 14,710 2021-03-21, 11:21 PM
Last Post: careads
  Most recordings are zero bytes virtualpaul 4 2,056 2021-01-29, 12:55 PM
Last Post: virtualpaul
  Recordings with Next PVR 4.2.5 (CL0116) have background music but no voice in record DavidF 4 2,095 2021-01-07, 08:47 AM
Last Post: sub
  Streaming Services with NPVR tesla1886 4 2,710 2021-01-04, 02:58 AM
Last Post: tesla1886

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

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

Linear Mode
Threaded Mode