SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #281  
Old 01-28-2011, 02:19 PM
bradvido's Avatar
bradvido bradvido is offline
Sage User
 
Join Date: Nov 2010
Location: MN
Posts: 68
Quote:
Originally Posted by skiingwiz View Post
I heard back from Sage today and both of these issues are fixed for 7.1.
Excellent

Another question regarding the API.
Is the SetWatchedTimes command supported?
I believe I am calling it correctly, but I am not seeing the times updated when I view the data after calling the update.

I don't really know how to tell if it's really working, because the return type is void.

Anyway, here's the command I'm trying to use to say "I started watching this show on 01/02/2011 18:00:05 [represented as 1294012805000] and I am 30 seconds into it [represented as 30000]".
Code:
http://192.168.88.10:8080/sagex/api?c=SetWatchedTimes&1=airing:121074&2=30000&3=1294012805000
Do you see any problems?
Reply With Quote
  #282  
Old 01-28-2011, 07:48 PM
jreichen's Avatar
jreichen jreichen is offline
Sage Icon
 
Join Date: Jul 2004
Posts: 1,192
The second parameter is an Airing-relative time, so you'll need to add your 30,000 to the time the airing started recording. To get that value, call the GetScheduleStartTime API.

To check your results, call the GetLatestWatchedTime API. And remember that your new value will be ignored if the existing latest watched time is later than the new time you're passing in.

I think the airing is set to "watched" if the latest watched time is within a given range of the end of the show, and the latest watched time value is reset if you clear the watched status of the airing.
__________________
Server: Intel Core i5 760 Quad, Gigabyte GA-H57M-USB3, 4GB RAM, Gigabyte GeForce 210, 120GB SSD (OS), 1TB SATA, HD HomeRun.
Extender: STP-HD300, Harmony 550 Remote,
Netgear MCA1001 Ethernet over Coax.
SageTV: SageTV Server 7.1.8 on Ubuntu Linux 11.04, SageTV Placeshifter for Mac 6.6.2, SageTV Client 7.0.15 for Windows, Linux Placeshifter 7.1.8 on Server and Client
, Java 1.6.
Plugins: Jetty, Nielm's Web Server, Mobile Web Interface.

Reply With Quote
  #283  
Old 01-31-2011, 02:47 PM
bradvido's Avatar
bradvido bradvido is offline
Sage User
 
Join Date: Nov 2010
Location: MN
Posts: 68
Quote:
Originally Posted by jreichen View Post
The second parameter is an Airing-relative time, so you'll need to add your 30,000 to the time the airing started recording. To get that value, call the GetScheduleStartTime API.

To check your results, call the GetLatestWatchedTime API. And remember that your new value will be ignored if the existing latest watched time is later than the new time you're passing in.

I think the airing is set to "watched" if the latest watched time is within a given range of the end of the show, and the latest watched time value is reset if you clear the watched status of the airing.
Really banging my head against the wall. I've tried all of your tips here. I am trying to update an airing that is not marked as watched.


Here's an XML snippet from GetAiringForID call:
Code:
http://192.168.88.10:8080/sagex/api?c=GetAiringForID&1=121074
  <ScheduleStartTime>1294012800000</ScheduleStartTime> 
  <ScheduleEndTime>1294016400000</ScheduleEndTime> 
  <ScheduleDuration>3600000</ScheduleDuration> 
  <IsWatched>false</IsWatched> 
  <WatchedDuration>0</WatchedDuration> 
  <WatchedStartTime>0</WatchedStartTime> 
  <WatchedEndTime>0</WatchedEndTime> 
  <RealWatchedStartTime>0</RealWatchedStartTime> 
  <RealWatchedEndTime>0</RealWatchedEndTime> 
  <LatestWatchedTime>1294012800000</LatestWatchedTime> 
  <IsWatchedCompletely>false</IsWatchedCompletely> 
  <AiringID>121074</AiringID>
It has an existing latest watched time of 1294012800000 (18:00)
I'm trying to setting it to: 1294014600000 (30 minutes later)
So, I call this command to say I started watching it at the schedule start time, and I watched it for 30 minutes past that:

Code:
Parameters explained:
1 = airing:121074 (the airing identifier)
2 = 1294014600000 (WatchedEndTime, airing relative, 30 minutes past the schedule start time)
3 = 1294012800000 (RealStartTime, set to the same as the schedule start time)

The call:
http://192.168.88.10:8080/sagex/api?c=SetWatchedTimes&1=airing:121074&2=1294014600000&3=1294012800000

The result:
  <Result />
However, none of the values get updated when I refresh the GetAiringForID info.

Can you see anything that I am missing?

Last edited by bradvido; 01-31-2011 at 02:51 PM.
Reply With Quote
  #284  
Old 01-31-2011, 03:09 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
@bradvido - have you tried to do this using the expression evaluator in studio? maybe it's the args... maybe it's something to do with sagex remote apis??
Reply With Quote
  #285  
Old 01-31-2011, 03:12 PM
bradvido's Avatar
bradvido bradvido is offline
Sage User
 
Join Date: Nov 2010
Location: MN
Posts: 68
Quote:
Originally Posted by stuckless View Post
@bradvido - have you tried to do this using the expression evaluator in studio? maybe it's the args... maybe it's something to do with sagex remote apis??
No. I don't have studio and have never used it (so far). Will that give me more debugging info?
Reply With Quote
  #286  
Old 01-31-2011, 04:20 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by bradvido View Post
No. I don't have studio and have never used it (so far). Will that give me more debugging info?
Not that it will give any more detail... it will just take sagex-apis out of the equation and allow you to test the native api, just to see if sagex is somehow causing the issue.
Reply With Quote
  #287  
Old 01-31-2011, 06:19 PM
jreichen's Avatar
jreichen jreichen is offline
Sage Icon
 
Join Date: Jul 2004
Posts: 1,192
AFAIK I'm the only one who has used this. Jeff added it for me to use in the iOS streaming.

I'm not familiar with all its nuances. If your latest watched time is within the start padding time it may have no effect. You might also try adding your time to the value returned by GetAiringStartTime or GetFileStartTime and compare the results. I thought you wanted 30 seconds which is why I suggested 30,000 ms. If you want 30 minutes, use 30*60*1000.
__________________
Server: Intel Core i5 760 Quad, Gigabyte GA-H57M-USB3, 4GB RAM, Gigabyte GeForce 210, 120GB SSD (OS), 1TB SATA, HD HomeRun.
Extender: STP-HD300, Harmony 550 Remote,
Netgear MCA1001 Ethernet over Coax.
SageTV: SageTV Server 7.1.8 on Ubuntu Linux 11.04, SageTV Placeshifter for Mac 6.6.2, SageTV Client 7.0.15 for Windows, Linux Placeshifter 7.1.8 on Server and Client
, Java 1.6.
Plugins: Jetty, Nielm's Web Server, Mobile Web Interface.

Reply With Quote
  #288  
Old 02-01-2011, 11:37 AM
jreichen's Avatar
jreichen jreichen is offline
Sage Icon
 
Join Date: Jul 2004
Posts: 1,192
bradvido, try this out. I was able to get it working in Studio's expression evaluator. I had a nice write-up prepared but my computer crashed, so you get the short version

Code:
SetWatchedTimes(Airing, GetAiringStartTime(Airing) + 30*60*1000, GetRealWatchedStartTime(Airing))
__________________
Server: Intel Core i5 760 Quad, Gigabyte GA-H57M-USB3, 4GB RAM, Gigabyte GeForce 210, 120GB SSD (OS), 1TB SATA, HD HomeRun.
Extender: STP-HD300, Harmony 550 Remote,
Netgear MCA1001 Ethernet over Coax.
SageTV: SageTV Server 7.1.8 on Ubuntu Linux 11.04, SageTV Placeshifter for Mac 6.6.2, SageTV Client 7.0.15 for Windows, Linux Placeshifter 7.1.8 on Server and Client
, Java 1.6.
Plugins: Jetty, Nielm's Web Server, Mobile Web Interface.

Reply With Quote
  #289  
Old 02-16-2011, 11:14 AM
cncb cncb is offline
Sage Icon
 
Join Date: Jul 2006
Posts: 1,271
Some questions about "custom services":

1) Is the .js file (re)loaded each time when a function is called? I ask because if I overwrite the file it picks up the changes without reloading the web server (and I have turned off the constant check for new files in jetty). I would be concerned about a lot of disk reads if this is the case.

2) json for custom objects: I have tried to return a custom object and it fails to encode as json because it is not a Sage object. I can construct the json string manually but it is wrapped in "Result" XML tags (not a big deal but an extra "layer" that is not necessary). Is there a better way to do this?

Thanks.
__________________
-Craig
Reply With Quote
  #290  
Old 02-16-2011, 12:24 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by cncb View Post
Some questions about "custom services":

1) Is the .js file (re)loaded each time when a function is called? I ask because if I overwrite the file it picks up the changes without reloading the web server (and I have turned off the constant check for new files in jetty). I would be concerned about a lot of disk reads if this is the case.

2) json for custom objects: I have tried to return a custom object and it fails to encode as json because it is not a Sage object. I can construct the json string manually but it is wrapped in "Result" XML tags (not a big deal but an extra "layer" that is not necessary). Is there a better way to do this?

Thanks.
1. Yes. The file is read and processed every time. While I don't put any restrictions on the services, they are meant to be used ligthly. ie, if you need something done quickly and repetively, then create a native java api... but if all you want is to do something easily, then use the .js service.

2. The return types are basically Strings and Serializable save objects. The main encoder simply takes the result and then converts it into Xml or Json. If you return JSONObject, I'm not quite sure what will happen, but I suspect it will break. When you call a service, you specify the encoding of either xml or json. So if you return a String that is json data, it will simply be assigned the "result" in the returning object, as a string, and not as json data.

To be honest, no one has ever played with this (except for myself) so there's been very little enhancements. Unfortunately the timing isn't good for me right now, but if you have the java experience to make the services better by natively supporting json/xml, etc, I'd certainly review the patch.
Reply With Quote
  #291  
Old 02-16-2011, 01:20 PM
cncb cncb is offline
Sage Icon
 
Join Date: Jul 2006
Posts: 1,271
Quote:
Originally Posted by stuckless View Post
1. Yes. The file is read and processed every time. While I don't put any restrictions on the services, they are meant to be used ligthly. ie, if you need something done quickly and repetively, then create a native java api... but if all you want is to do something easily, then use the .js service.
Is it possible to create a java api that exposes "commands" that can be invoked by the sagex remote http access? Basically I want to group related information obtained from the Sage api instead of having to make separate calls for each piece of information (e.g. get both the available and used disk space in one command instead of having to do two command corresponding to the separate api calls). I can do this easily with the custom services but it will be called quite often. Thanks again.
__________________
-Craig
Reply With Quote
  #292  
Old 02-16-2011, 01:50 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by cncb View Post
Is it possible to create a java api that exposes "commands" that can be invoked by the sagex remote http access? Basically I want to group related information obtained from the Sage api instead of having to make separate calls for each piece of information (e.g. get both the available and used disk space in one command instead of having to do two command corresponding to the separate api calls). I can do this easily with the custom services but it will be called quite often. Thanks again.
Not out of the box... but it's possible in that I did it with sagex

But for your needs, you can probably "simulate" a json reply using lists, arrays, and maps.

ie, if in the sagex service that you create, you create a java.util.HashMap and fill it with named data, then it will look like a json object in the reply. I'm pretty sure the sagex apis will serialize maps, lists and arrays, since many of the sage apis natively return those types.

If you want the reply to be sent back as json, then set the json encoder in the request url (by default it uses the xml encoder)
Reply With Quote
  #293  
Old 02-16-2011, 02:26 PM
cncb cncb is offline
Sage Icon
 
Join Date: Jul 2006
Posts: 1,271
Quote:
Originally Posted by stuckless View Post
If you want the reply to be sent back as json, then set the json encoder in the request url (by default it uses the xml encoder)
Using a string works just fine for this. My concern is with the .js file constantly being reloaded since this custom service will be called a lot. Would there be any way to optionally keep the .js file loaded until a restart of jetty?
__________________
-Craig
Reply With Quote
  #294  
Old 02-16-2011, 02:30 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by cncb View Post
Using a string works just fine for this. My concern is with the .js file constantly being reloaded since this custom service will be called a lot. Would there be any way to optionally keep the .js file loaded until a restart of jetty?
It can certainly be changed... but i didn't do it that way, so that you wouldn't need to restart sagetv everytime your made a change to the script. Maybe what the service code needs is a "test" flag that when sent, it will recompile the script... but under normal use it would only do it once.
Reply With Quote
  #295  
Old 02-16-2011, 03:00 PM
cncb cncb is offline
Sage Icon
 
Join Date: Jul 2006
Posts: 1,271
Quote:
Originally Posted by stuckless View Post
Maybe what the service code needs is a "test" flag that when sent, it will recompile the script... but under normal use it would only do it once.
If you could add that at some point it sounds perfect. Thanks.
__________________
-Craig
Reply With Quote
  #296  
Old 02-19-2011, 05:54 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Security Change in next release Sagex Services

By default, /sagex/api will have a security handler and will require the same user/passwrd that also protects bmt, and neilm's webserver.

I did a search of the plugins and I didn't find any plugins that depend on sagex-services directly, which is the plugin that exposed the sagex apis over http/rmi, so this change may not affect anyone. There were 28 plugins that depend on sagex-api, so if you are depending on sagex-api but really doing it to use the http services, then you'll be affected.

This update will probably be rolled out sometime tomorrow.
Reply With Quote
  #297  
Old 02-19-2011, 07:14 AM
babgvant babgvant is offline
Sage Icon
 
Join Date: Jul 2008
Location: London
Posts: 1,834
Quote:
Originally Posted by stuckless View Post
By default, /sagex/api will have a security handler and will require the same user/passwrd that also protects bmt, and neilm's webserver.

I did a search of the plugins and I didn't find any plugins that depend on sagex-services directly, which is the plugin that exposed the sagex apis over http/rmi, so this change may not affect anyone. There were 28 plugins that depend on sagex-api, so if you are depending on sagex-api but really doing it to use the http services, then you'll be affected.

This update will probably be rolled out sometime tomorrow.
TBC, this just means that we'll have to support basic auth to keep using sagex?
__________________
babgvant.com | @babgvant | Missing Remote
Reply With Quote
  #298  
Old 02-19-2011, 07:20 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by babgvant View Post
TBC, this just means that we'll have to support basic auth to keep using sagex?
Yeah, it will be basic auth... but, you'll have the ability to turn off the authentication, if you want. It's just that out of the box it will require user/pass. I am only locking down the /sagex/api and not the media handlers.
Reply With Quote
  #299  
Old 02-19-2011, 10:22 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by stuckless View Post
1. Yes. The file is read and processed every time. While I don't put any restrictions on the services, they are meant to be used ligthly. ie, if you need something done quickly and repetively, then create a native java api... but if all you want is to do something easily, then use the .js service.
Actually, apparently I do not compile the services every time. I only re-compile the services when the file's timestamp changes. So while you are developing it will recompile, but one you stop modifying the file, it will use the last compiled version of the service.
Reply With Quote
  #300  
Old 02-21-2011, 02:00 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Revisit of UIContext

I saw some info in the thread regarding using UIContext in Get/SetProperty() to make sure the data was actually written to the correct .properties file but it was old and I'd like to revisit the issue.

If I use SetProperty(UIContext.SAGETV_PROCESS_LOCAL_UI, "Name", "Value") from within my Java code will that write the property to the correct place or do I need to get the UIContext Name and then use SetProperty(new UIContext(UIContextName), "Name", "Value")?
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
Reply


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

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
Hauppauge Remote Issue yacht_boy Hardware Support 4 05-01-2008 09:25 PM
MCE remote transmitting keypresses twice arnabbiswas Hardware Support 1 02-22-2007 10:55 AM
MCE Remote not work fully with Placeshifter devinteske SageTV Placeshifter 5 02-08-2007 11:45 PM
Harmony Remote IR Reciever Help brundag5 Hardware Support 2 01-13-2007 09:08 PM
How to get SageTV to release focus to NVDVD for remote IncredibleHat SageTV Software 4 07-06-2006 07:47 AM


All times are GMT -6. The time now is 12:59 PM.


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