SageTV Community

SageTV Community (http://forums.sagetv.com/forums/index.php)
-   SageTV Software (http://forums.sagetv.com/forums/forumdisplay.php?f=6)
-   -   Setting padding via API? (http://forums.sagetv.com/forums/showthread.php?t=65425)

syrel 03-03-2018 02:06 PM

Setting padding via API?
 
I have default padding set within Sage (v9), but when I schedule a recording using the webui, the default padding is always zero and needs to be set manually. That's a bit of an irritation, but I believe that is expected behaviour. If I'm wrong and is there a way of doing automatic padding via the webui, someone please correct me!

However, may main question is - Is there a way of setting the padding for a manual recording and/or a favourite using the Sage API? I'm asking because I control most of my Sage viewing via the Kodi plugin. If there is an API call to set the padding for a scheduled recording, I (think I) could conceivably create a context menu item to at least set the padding with one click.

Any advice/suggestions gratefully received.

syrel

wayner 03-03-2018 02:33 PM

I don't think that there is an API call to just add padding - I think this is dealt with my changing the StopTime parameter in a call to SetRecordingTimes in the Airing API. So to add 30 minutes of airings you would increment StopTime by 1800 (or 1800000 if it is in ms).

see: http://download.sage.tv/api/sage/api...g, long, long)

Quote:

SetRecordingTimes
public java.lang.Object SetRecordingTimes(sage.Airing Airing, long StartTime, long StopTime)
Modifies or creates a time-based recording that is associated with this Airing. This is also a type of Manual Record.
Parameters:
Airing - the Airing object
StartTime - the time the recording of this Airing should start
StopTime - the time the recording of this Airing should stop
Returns:
true if the call succeeds, otherwise a localized error message is returned

syrel 03-03-2018 02:41 PM

Thanks. Hmm, that seems tricky. I'm wondering how I would avoid setting an absolute time in case the epg schedule changes at a later date. Could I potentially send a command that says 'make the start time XX milliseconds before the airing start time?'.

syrel

stuckless 03-04-2018 05:07 AM

The Favorite API has a SetStartPadding and SetStopPadding, is that what you are looking for?

http://download.sage.tv/api/sage/api...(sage.Favorite, long)

syrel 03-04-2018 05:11 AM

Ideally, I'd like it more for manual recordings.

thanks

syrel

stuckless 03-04-2018 07:52 AM

I guess I'm a little confused based on the requirements.

You mention Favorites and Manual Recording (or time based recording).

So, if it's a favorite, then you use the FavouriteAPI to adjust the padding. If it's a Manaul Recording (ie, you've said, record this show on this channel at this time) then it's a time based recording the Wayner's response is how you adjust that.

I'm not sure what you are asking here if neither of those things are what you need or want :(

I guess there isn't an api like AdjustPadding(Airing, +/-mins) that will look at the airing and if it's a part of a favorite then it will adjust the favorite, but if if a manual recording it will adjust the scheduled start/end times. Although you could easily add that using the sagex services and javascript and/or you could cleverly create it as well using the EvaluateExpression api and passing a bunch of nested sagetv apis using sagetv's If api.

syrel 03-04-2018 10:39 AM

Thanks for replying. I might not be explaining clearly - or it might just be that I'm confused (and confusing)...

Favourites - okay, can see how SetStartPadding works, thanks.

Manual record - What I want to be able to do is, having set up a timed record, to send a command that says 'set start [airingtimestart - 5 mins] and set end [airingtimeend + 5 minutes]'. My interpretation of SetRecordingTimes is that it requires me to input a specific/absolute time (i.e. 10.25pm) and not a 'relative to airingtime' number, which could prove a problem if the airingtime changes at all. Or am I misinterpreting SetRecordingTimes?

thanks

syrel

stuckless 03-04-2018 02:46 PM

Quote:

Originally Posted by syrel (Post 614663)
Thanks for replying. I might not be explaining clearly - or it might just be that I'm confused (and confusing)...

Favourites - okay, can see how SetStartPadding works, thanks.

Manual record - What I want to be able to do is, having set up a timed record, to send a command that says 'set start [airingtimestart - 5 mins] and set end [airingtimeend + 5 minutes]'. My interpretation of SetRecordingTimes is that it requires me to input a specific/absolute time (i.e. 10.25pm) and not a 'relative to airingtime' number, which could prove a problem if the airingtime changes at all. Or am I misinterpreting SetRecordingTimes?

thanks

syrel

I guess for a manual recording (and I don't use them, so I could be misunderstanding how they work) you are saying , record Hawaii Five 0, on channel 800, from 9pm to 10pm. Now if for some reason the guide changes and hawaii five 0 got moved to 10pm-11pm, I don't think the manual recording would update, and record it at 10pm. I think you'd get the show that aired at 9pm... since the manual recording is really just recording a channel with a given start/end. For that reason, I think that setting the Airing Start/End is really all you can do, and hope that the guide doesn't change it's time.

So to update an existing airing you'd end up with something like,

Code:

SetRecordingsTimes(airing, GetAiringStartTime(ariing)-3*60*1000, GetAringEndTime(airing)+3*60*1000)
Which would add a 3 minute padding to both ends of its current start/end times.

Now granted, I know very little about Manual Recordings, so I could be completely wrong here :(

syrel 03-04-2018 03:30 PM

If I remember rightly, if the epg schedule for a manually recorded individual program changes, sage sends an alert telling me that it has re-scheduled the timed record and asks me if that's ok. I guess the question is whether the preset padding also changes - but given that I always set the padding via the webserver and I can't remember a case where this has caused me a problem, I'm guessing it probably does. Anyway, you've given me enough hints that I might be able to make this work. Thanks.

wnjj 03-04-2018 05:33 PM

Stuckless, I think what youíre referring to is a timed recording. I think a manual recording is just a way of marking an EPG entry for recording, without making it a favorite. Itís still linked to an airing.

Iím not sure what the timed recording in the GUI does but is suspect it just adds a dummy entry to the schedule without linking to a specific airing.

stanger89 03-05-2018 06:39 AM

Quote:

Originally Posted by syrel (Post 614671)
If I remember rightly, if the epg schedule for a manually recorded individual program changes, sage sends an alert telling me that it has re-scheduled the timed record and asks me if that's ok.

I use manual recordings very infrequently, but... I thought the alert you got was that the EPG data for the manual recording changed.

I don't think Sage reschedules manual recordings, I'm not sure how it could. When the EPG gets updated, all the sudden that old airing is gone, how is it to know which new airing corresponds to it?

wnjj 03-05-2018 10:06 AM

Quote:

Originally Posted by stanger89 (Post 614682)
I use manual recordings very infrequently, but... I thought the alert you got was that the EPG data for the manual recording changed.

I don't think Sage reschedules manual recordings, I'm not sure how it could. When the EPG gets updated, all the sudden that old airing is gone, how is it to know which new airing corresponds to it?

It can still follow the airing by the ID. Itís no different than tracking watched versus unwatched favorites. Think of a manual record as a one episode favorite.

syrel 03-07-2018 03:16 PM

OK, I've been giving this a go but hit a wall. My command is
/sagex/api?command=SetRecordingsTimes&1=(airing:14903964, GetAiringStartTime(airing:14903964)-2*60*1000, GetAiringEndTime(airing:14903964)+5*60*1000)

But I get an 'unknow sage command' error. Full log below. Any ideas?

thanks

syrel

<error sagex-version="7.1.9.1"><message>Unknown Sage Command: SetRecordingsTimes</message><exception>java.lang.RuntimeException: Unknown Sage Command: SetRecordingsTimes
at sagex.remote.factory.request.SageRPCRequestFactory.createRequest(SageRPCRequestFactory.java:1211)
at sagex.remote.api.ApiHandler.callSageAPI(ApiHandler.java:208)
at sagex.remote.api.ApiHandler.handleRequest(ApiHandler.java:150)
at sagex.remote.SagexServlet.doPost(SagexServlet.java:87)
at sagex.remote.SagexServlet.doGet(SagexServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.rewrite.RewriteHandler.handle(RewriteHandler.java:230)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:864)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
</exception></error>

stuckless 03-08-2018 07:19 AM

THere is a few things wrong there...

Apis are called as... c=APINAME&1=arg1&2=arg2... (see /sagex/api for examples of using the API)

args CANNOT be expressions. So to do what you want to todo, you need to use the EvaluateExpression command passing a single arg with your complete expressions...

/sagex/api?c=EvaluateExpression&1=SetRecordingsTimes(GetAiringForID(14903964), GetAiringStartTime(GetAriingForID(14903964))-2*60*1000, GetAiringEndTime(GetAiringForID(14903964))+5*60*1000)

So when calling an API like SetWatched, for example, you can pass 1=mediafile:12312 or 1=airing:123123, etc but you can't pass an expression as the arg. The only API that supports expressions is the EvaluateExpression AND in there you cannot use the "airing:" notation, so you need resolve the airing by ID.

syrel 03-08-2018 02:24 PM

Ah, I see. I have much to learn; thanks for the guidance.
syrel

syrel 03-13-2018 04:12 PM

I'm beginning to wonder if what I want to do isn't actually possible using SetRecordingTimes:

Just to prove I can get something to work (ie I'm not being completely stupid), I've tried
/sagex/api?c=EvaluateExpression&1=GetAiringForID(14903964)
/sagex/api?c=EvaluateExpression&1=GetScheduleEndTime(GetAiringForID(14903964))
/sagex/api?c=EvaluateExpression&1=GetScheduleEndTime(GetAiringForID(14903964))-300000

(I've also swapped GetAiringEndTime in place of GetScheduleEndTime and had same results)

And all produce the correct response. But when I try
/sagex/api?c=EvaluateExpression&1=SetRecordingTimes(GetAiringForID(14903964), GetAiringStartTime(GetAiringForID(14903964))-300000, GetAiringEndTime(GetAiringForID(14903964))+300000

I just get an empty result and nothing changes.

syrel

stuckless 03-13-2018 05:18 PM

It looks like you are missing a bracket at the end

/sagex/api?c=EvaluateExpression&1=SetRecordingTimes(GetAiringForID(14903964), GetAiringStartTime(GetAiringForID(14903964))-300000, GetAiringEndTime(GetAiringForID(14903964))+300000)

syrel 03-14-2018 01:45 AM

Thanks again. Yes I had missed off the bracket, but it didn't solve the problem. I've simplified it as much as I can just to get it working:

/sagex/api?c=EvaluateExpression&1=SetRecordingTimes(GetAiringForID(14903964), 1521153300000, 1521157800000)

but still nothing. Browser just returns "<Result/>" and no change to the schedule times.

syrel

stuckless 03-14-2018 06:31 AM

Quote:

Originally Posted by syrel (Post 614862)
Thanks again. Yes I had missed off the bracket, but it didn't solve the problem. I've simplified it as much as I can just to get it working:

/sagex/api?c=EvaluateExpression&1=SetRecordingTimes(GetAiringForID(14903964), 1521153300000, 1521157800000)

but still nothing. Browser just returns "<Result/>" and no change to the schedule times.

syrel

Since you are simplifying... try this...

/sagex/api?c=SetRecordingTimes&1=airing:14903964&2=1521153300000&3=1521157800000

That calls the SetRecordingTimes api directly passing the airing, and the start/end times. Now, the reply for this should either be "true" or an error message.

syrel 03-14-2018 08:30 AM

That produces the following error:

<error>
<message>Cannot Serialize Reply</message>
<class>sage.Catbert$AsyncTaskID</class>
<data>sage.Catbert$AsyncTaskID@1e916d8</data>
<exception>
Cannot Serialize [Field: Result, Type: sage.Catbert$AsyncTaskID ToString: sage.Catbert$AsyncTaskID@1e916d8]</exception>
</error>

syrel


All times are GMT -6. The time now is 01:15 PM.

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