SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV v9 Customizations

Notices

SageTV v9 Customizations This forums is for discussing and sharing user-created modifications for the SageTV version 9 application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss plugins for SageTV version 9 and newer.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-16-2020, 07:15 PM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
What plug-in or API can identify when SageTV is recording?

I have a scheduled task that performs a reboot of the SageTV server every day at 4:30am for stability and reliability. It is rare, but occasionally something records at that time, resulting in a gap or failure.

Is there any API or plug-in that I could call from the scheduled task CMD file to cancel the reboot if a recording is active?
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.
Reply With Quote
  #2  
Old 04-16-2020, 11:12 PM
peternm22 peternm22 is offline
Sage Expert
 
Join Date: Jan 2005
Posts: 661
If you have the web interface installed, you could check the XML files it produces to verify if there is anything currently recording.

http://YourIP/sage/Home?xml=currrecording
This XML file will list any currently recording shows. If you don't want to actually process the XML, you could just check the file size (it will be much smaller if nothing is recording).

http://YourIP/sage/Home?xml=nextrecordings
This XML file will list the next scheduled recording(s). If you want to get fancy, you could also check this file to make sure there aren't any recordings scheduled within minutes of your planned reboot.
Reply With Quote
  #3  
Old 04-17-2020, 06:29 AM
wayner wayner is online now
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,937
There is an additional API call that was created by Slugger that tested if anything was recording. Here wrote some useful addon extensions to the API that allowed you to do things like determine what type of extender you had, etc. Unfortunately I can't find them now.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #4  
Old 04-17-2020, 11:12 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,294
Quote:
Originally Posted by wayner View Post
There is an additional API call that was created by Slugger that tested if anything was recording. Here wrote some useful addon extensions to the API that allowed you to do things like determine what type of extender you had, etc. Unfortunately I can't find them now.
Are these the ones your are referring to?

Your post from 11/18: https://forums.sagetv.com/forums/sho...4&postcount=16
Reply With Quote
  #5  
Old 04-17-2020, 11:24 AM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
Quote:
Originally Posted by peternm22 View Post
If you have the web interface installed.
I'm not sure - what is "the web interface"?

I have these plugins:
Apache Mina Core by ShadeBlue
log4j by stuckless
sagex-api by by stuckless
slf4j by stuckless
JSON.org by Slugger

And DarkSky and the "jacksons" for weather...

Which of those should I explore?

PS I tried "http://YourIP/sage/Home?xml=currrecording" (of course with my server's IP inserted) and got a timeout. Tried it with localhost, too, and also timeout.
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.

Last edited by timg11; 04-17-2020 at 11:30 AM.
Reply With Quote
  #6  
Old 04-17-2020, 11:25 AM
wayner wayner is online now
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,937
Yes - that's it. These three calls would be helpful:
Code:
	/**
	 * Check if there is something currently recording
	 * @return True if there is something currently recording or false otherwise
	 */
	static boolean isSomethingRecording() {
		return Global.GetCurrentlyRecordingMediaFiles().size() > 0
	}

	/**
	 * Check if media is being played somewhere on any connected device
	 * @return True if media is being played on any connected device or false otherwise
	 */
	static boolean isMediaPlaying() {
		def connected = []
		connected += Global.GetUIContextNames().toList()
		connected += Global.GetConnectedClients().toList()
		for(def c : connected)
			if(MediaPlayerAPI.GetCurrentMediaFile(new UIContext(c)) != null)
				return true
		return false
	}

	/**
	 * Get the number of seconds until the start of the next scheduled recording
	 * @return The number of seconds until the next scheduled recording; returns Long.MAX_VALUE if there are no scheduled recordings
	 */
	static long getSecondsUntilNextRecording() {
		def sched = Database.Sort(Global.GetScheduledRecordings(), false, "GetScheduleStartTime")
		def now = System.currentTimeMillis()
		if(sched.size() == 0)
			return Long.MAX_VALUE
		def start = 0
		for(def i = 0; i < sched.size(); ++i) {
			def time = AiringAPI.GetScheduleStartTime(sched[i])
			if(time > now) {
				start = time
				break
			}
		}
		if(start == 0)
			return Long.MAX_VALUE
		return (start - now) / 1000L
	}
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #7  
Old 04-17-2020, 12:03 PM
peternm22 peternm22 is offline
Sage Expert
 
Join Date: Jan 2005
Posts: 661
Quote:
Originally Posted by timg11 View Post
I'm not sure - what is "the web interface"?
It's the plugin called "SageTV Web Interface". It gives you a webpage for managing SageTV recordings/schedule.

Install that and configure it (you'll need to give it a username, password, and port number). Then you will be able to use the XML URL's I provided.
Reply With Quote
  #8  
Old 04-17-2020, 04:47 PM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
@peternm22, thanks I'll try that first.

@wayner, I'm still curious about the code you posted containing:
Code:
static boolean isSomethingRecording()
Is that code that is already part of SageTV9, and can be called through an API? Can you point me to an example of calling that API?
I followed the link below and ended up at Slugger's Utility Helpers
and Global Helpers

https://searchcode.com/codesearch/view/1107144/
and
https://searchcode.com/codesearch/view/1107145/

That code looks like it is on the SageTV side, but I need something that runs as a client to access the API?
Ultimately, I would build a Windows console executable "IsSageRecording.exe" that would return 1 if yes and 0 if no.
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.
Reply With Quote
  #9  
Old 04-18-2020, 08:08 AM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
Quote:
Originally Posted by peternm22 View Post
It's the plugin called "SageTV Web Interface".
@peternm22, I'm working on installing "SageTV Web Interface"

First I went to the SageTV GUI on the server machine, and found SageTV Web Interface among the list of all available plugins. I installed it without any issue.

I tried accessing with http://192.168.1.110/sage/Home?xml=currrecording and http://localhost/sage/Home?xml=currrecording, but still get timeouts. "Unable to connect Firefox canít establish a connection to the server at localhost."

So I look deeper into the plugin for settings, etc. No Settings. Close, Details, Uninstall, and View Web Sites. Trying Web Site 1, it takes me to "http://tools.assembla.com/sageplugins/wiki/WebServer" which is 404.
Trying Web Site 2, I I go to "http://www.geektonic.com/2008/03/sag...ol-sagetv.html"

I follow "BASIC INSTALLATION INSTRUCTIONS" since the link to detailed instructions is also 404.

It takes me to get files at SourceForge I download jetty-starter-jars-2.3.0.14.zip. Latest version from March 2011.

First red flag- the geektonic page says "The download is just under 900K in size and is a java web server embedded into the SageTV process so IIS or Apache needed"

The file I downloaded was 5215K in size.
Second red flag - IIS or Apache needed? My SageTV server is a Win 7 Pro machine. I have a Windows 2008r2 server, but it is physically separated from the HDPVR2 and the HTPC setup - impractical for USB and HDMI.

Finally the Geektonic page shows a Windows Installer dialog -


However the downloaded zip file contains nothing but JAR files. There is no Windows installer of type exe or msi.

So I'm not sure where to go next - any suggestions?
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.
Reply With Quote
  #10  
Old 04-18-2020, 09:14 AM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
Still working on this.

Found the SageTV Web Interface V2 for Jetty thread. I was not looking there at first since the forum says "Use this forum to discuss customizations for SageTV version 6 and earlier"

Quote:
This needs to be in some kind of FAQ somewhere. The path is case sensitive:
Code:
http://mediaserver:8080/sage/Home
When I try the form:
Code:
http://localhost:8080/sage/Home
I get an "Authentication Required" dialog for "SageTV Web Service". So it is running after all.

However, the Plugin installer did not ask me to set the port 8080 or ask to set any credentials when installing...

Off to the wayback machine to try and find answers...
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.
Reply With Quote
  #11  
Old 04-18-2020, 09:30 AM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
The Jetty Server Basic Configuration page (from archive.org) says:

"The Jetty plugin is configured using the JettyStarter.properties file that is unzipped into the SageTV installdirectory"

Unfortunately, there is no file with the name "JettyStarter.properties" in the SageTV installdirectory. It does not exist anywhere on the entire machine.

As I poke around, it looks like I installed Jetty sometime in the past (or it was installed as a dependency for another plugin). There is a jetty folder in "C:\Program Files\SageTV\SageTV", dated 2018. the \jetty\etc folder is dated 2011, as are the files it contains.

Edit - further searching brought me to this thread on the Jetty Password.

I was able to locate the SageTV\jetty\etc\realm.properties file and reset the password. Now I can access the server and download the XML file from
Code:
http://localhost:8080/sage/Home?xml=currrecording
Now onward to parsing that file into something that can return an error level.
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.

Last edited by timg11; 04-18-2020 at 10:04 AM.
Reply With Quote
  #12  
Old 04-18-2020, 10:07 AM
wayner wayner is online now
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,937
Regarding the Web UI - assuming it is installed correctly there are configuration options in the SageTV UI, such as port number, username, password, etc.

I think some of those threads on password may now be deprecated - I don't think that you beed to edit a text file.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #13  
Old 04-18-2020, 10:32 AM
wayner wayner is online now
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,937
Quote:
Originally Posted by timg11 View Post
@peternm22, thanks I'll try that first.

@wayner, I'm still curious about the code you posted containing:

That code looks like it is on the SageTV side, but I need something that runs as a client to access the API?
Ultimately, I would build a Windows console executable "IsSageRecording.exe" that would return 1 if yes and 0 if no.
This may be too much info, but here goes:

I haven't done much of this stuff in several years and I am not really a programmer but generally the way that you access the API is via Java or Groovy. Groovy is a language that is a superset of Java - so Java code works in Groovy but Groovy code may not work in Java. A SageTV user named Slugger developed a bunch of useful plugins, especially Sage Job Queue (SJQ). He also took over support of the Sage Web Server and made extensions so that you could easily write Groovy code to expand the functionality of the SageTV Jetty web server. I used this to write some code that shows me the status of all of my SageTV extenders.

So you could write some code in Java or Groovy that could return you a 1 or 0 or other info. It might require groovy but it wouldn't be a big deal. You would run something like "groovy.exe getrecordingstatus.groovy" and it would execute.

Slugger also created a Groovy Development Environment for SageTV

But you might want to look into SJQ. It has this exact functionality. For example, in this document (https://sourceforge.net/p/sagetv-add...Sjq4UserGuide/) it says:
Quote:
Should I Use SJQv4?
Do you want to run tasks conditionally based on the state of an object or the state of your SageTV server? If so, then SJQ is the tool for you! Ever wanted to reboot your system on a weekly basis, but were afraid you might reboot during a recording? With SJQ, you can be sure that it is "safe" to reboot before rebooting.
tmiranda wrote a guide on SJQv4 that is here: https://code.google.com/archive/p/tm...Interface.wiki

And I am pretty sure that somewhere on the internet there is a full tutorial on using SJQ to do reboots as Slugger did this and provide docs on this. The problem is that lots of things have disappeared over the years.

The other issue is that many of these tools are VERY out of date. Like Jetty which is now known as Eclipse Jetty and Groovy is now Apache Groovy

Hopefully I didn't confuse you too much.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #14  
Old 04-18-2020, 10:35 AM
wayner wayner is online now
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,937
But if you want to do a quick and dirty check on whether something is recording then I would suggest just using the XML file. You could just use curl to hit the XML web page and send the ouptut to a web file. You would then parse the XML file to return a 0 or 1.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #15  
Old 04-18-2020, 11:04 AM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
Quote:
Originally Posted by wayner View Post
Regarding the Web UI - assuming it is installed correctly there are configuration options in the SageTV UI, such as port number, username, password, etc.
@wayner, I guess it is not installed correctly because I cannot find any setting in the UI. Where do you find them?

Here's windows CMD code for testing the recording status:

Code:
curl -u jettyuser:jettypassword "http://localhost:8080/sage/Home?xml=currrecording" > SageRecStatus.xml
grep channelId SageRecStatus.xml
if errorlevel==1 goto NotRec
echo Recording
goto end
:NotRec
echo Not Recording
:end

I have tested this as a standalone CMD file, it works. I have also incorporated it into my daily reboot scheduled task.

Edit: @Wayner, thank you for the additional information in your post 2 and 3. I didn't refresh the thread while I was replying to the first, and missed them. As you can see, I did your "quick and dirty" approach which seems to be working fine. I will definitely look into SJQv4 the next time I need to automate something. I saved the linked pages in case they are 404 next time I look.
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.

Last edited by timg11; 04-18-2020 at 11:22 AM.
Reply With Quote
  #16  
Old 04-18-2020, 11:24 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,294
Nice work getting that going. As a final precaution you should change your reboot time to something like 4:10 so you donít stomp on a recording that was going to start right at 4:30.
Reply With Quote
  #17  
Old 04-18-2020, 11:28 AM
peternm22 peternm22 is offline
Sage Expert
 
Join Date: Jan 2005
Posts: 661
Quote:
Originally Posted by timg11 View Post
@wayner, I guess it is not installed correctly because I cannot find any setting in the UI. Where do you find them?
In SageTV, go to Setup > SageTV Plugins > Installed Plugins.

Find the entry that says "Jetty Web Server", click on it and select "Configure Plugin". You can set the username, password and port there.
Reply With Quote
  #18  
Old 04-18-2020, 01:27 PM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
Quote:
Originally Posted by wnjj View Post
...change your reboot time to something like 4:10 so you donít stomp on a recording that was going to start right at 4:30.
Yes, the time is set to 04:45. I have a backup task scheduled for 05:00, so I picked 04:45 to be sure the system was restarted and still awake then.
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.
Reply With Quote
  #19  
Old 04-18-2020, 01:38 PM
timg11's Avatar
timg11 timg11 is offline
Sage Aficionado
 
Join Date: Sep 2008
Posts: 430
Quote:
Originally Posted by peternm22 View Post
In SageTV, go to Setup > SageTV Plugins > Installed Plugins.

Find the entry that says "Jetty Web Server", click on it and select "Configure Plugin". You can set the username, password and port there.

There was an interesting transformation that occurred during this thread. When I started, I set out to install the "SageTV Web Interface" as recommended by you. There is indeed a plugin called the "SageTV Web Interface", and I installed it. It didn't work, and I started researching, which brought me to many dead links, but eventually connected to the jetty topic.

My conclusion is that some time over the past 10 years, the "SageTV Web Interface" turned into or was replaced by Jetty.

In my plugins, I still have "SageTV Web Interface" and I also have "jetty Web Server". Apparently the jetty is the one that counts, since it has configuration settings you mention above, that match what I'm seeing for the server authentication and port, while "SageTV Web Interface" has no settings.

Is the "SageTV Web Interface" plugin doing anything or should I remove it as a plugin?
__________________
HD300 extender with SageTV V9.1.10 (service mode), Running on Windows 7 (32 bit), E8400 3GHz dual core CPU, 4G RAM, Gigabyte GA-P35-DS3L motherboard. NVidia 8600GT; Viewsonic LCD on one output and Mitsubishi WD57734 HDTV via DVI/HDMI on other output. HDHomeRun HDHR5-4US tuner, Hauppauge 1512 HD-PVR2 connected to Google Fiber TV GFHD200, tuned with USB-UIRT.
Reply With Quote
  #20  
Old 04-18-2020, 01:42 PM
wayner wayner is online now
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,937
If I remember correctly the Jetty web server is a prerequisite to the SageTV Web UI. Jetty was required for other types of services - so you might need it even if you didn't actually use the web UI. There is/was also a mobile UI, SageAlert, BatchMetaDataTools, LivePVRData, etc that were web services and many (or all) of these required Jetty.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upgrade to 7 - Plug ins from 6 not showing in plug in list personalt SageTV v7 Customizations 1 05-23-2010 11:29 AM
Can anyone help me identify this icon? ddikeht SageTV Customizations 4 08-15-2009 09:10 AM
Nielm's Recording padding plug-in problem henk99 SageTV Customizations 26 10-17-2006 01:00 AM
pvr-250 driver identify and upd jsturtevant Hardware Support 1 01-20-2005 06:53 PM


All times are GMT -6. The time now is 02:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.