# Is it possible to set up a timed manual recording via telnet?



## JamesBritt (Sep 17, 2014)

I'm having periodic issues where shows fail to record because of either "no signal" or "not authorized" issues. It only happens on one channel; I've yet to find a failed recording on any other channel.

I have Cox for cable and plan on talking to them but from looking through the message boards I've yet to read of anyone with a similar issue ever having it permanently fixed. The work-around always seems to be regular rebooting of the tuning adapter.

One of the biggest annoyances of this problem is that by the time it is known several recordings have been missed. (My problem channel is the Tennis Channel; when there is stuff to record there is often a lot of it.)

I've been exploring the telnet interface and see that I can change channels and tell the tivo (a Roamio) to record.

Assuming this issue is never properly resolved (and how would one know it was never going to happen again?) I've pondered some code that telnet to the tivo, change to the tennis channel, and if see if it was recording.

If not, the script would tel the tivo to record that channel, then check that this is actually happening. 

Where I'm stuck is in trying to set up a short, manually-timed recording. That is, change to channel 1315 and then record for 10 minutes. Not record an entire show. (My concern is in accidentally crating a recording conflict.)

Is there a way to do this via telnet?

Also, is there someway via telnet to tell if a channel is coming up as "no signal" or "not authorized"? I've been searching but found nothing to suggest this was possible, hence the test recording approach.


----------



## lpwcomp (May 6, 2002)

If it is truly a "no signal" or "not authorized" problem caused by the TA, how is a manual recording going to help?


----------



## JamesBritt (Sep 17, 2014)

lpwcomp said:


> If it is truly a "no signal" or "not authorized" problem caused by the TA, how is a manual recording going to help?


If it fails I'll know there's a problem. I get the no signal or not authorized trouble once every few weeks. Sometimes rebooting the TA helps for few weeks, but on some occasions the problem came back two days later after a TA reboot.

I want my script to do a "can record" check periodically to catch issues before I miss too much.

SETCH 1315

This should respond with CH_STATUS 1315 LOCAL (or possible REMOTE; not sure when that changes)

IRCODE RECORD
IRCODE SELECT

wait a few seconds ...

SETCH 1315 

This should respond with CH_STATUS 1315 RECORDING

If not, then there's a problem and my script can send me a text message. Or try changing the channel up and down (something that sometimes works when done manually).

What I prefer to do is only record for five or 10 minutes if 1315 is not currently recording, to avoid introducing a scheduling conflict.

And, ideally, stop and delete that brief recording if all seems OK.


----------



## lpwcomp (May 6, 2002)

Why not just add a low priority repeating manual recording and simply check for the recording?


----------



## lpwcomp (May 6, 2002)

I also urge you to continue to hassle Cox. After many months of periodically losing 3 channels and numerous fruitless tech visits, I finally got a tech who replaced the cable that runs from the pedestal to the building which drastically reduced the noise on the line.

Other techs, if they bothered to check at all, had claimed that the noise problem was entirely within the walls.


----------



## telemark (Nov 12, 2013)

"Expect" can be used to automate telnet.

I agree you'd rather get the signal issue fixed. If it's the TA being flaky, put it on a reboot timer.

Is this channel on SDV? What is the signal strength reading the Tivo reports?


----------



## JamesBritt (Sep 17, 2014)

lpwcomp said:


> Why not just add a low priority repeating manual recording and simply check for the recording?


I'm doing that in the meantime, but it's a bit coarse-grained. Might be a good fall-back approach.

I'm also looking at scraping the Tivo online site to get my todo list. Ideally I'd just check conditions prior to any recording.


----------



## JamesBritt (Sep 17, 2014)

lpwcomp said:


> I also urge you to continue to hassle Cox.


Sure, but in the meantime I'm curious about ways to automate trouble detection.

Besides, there's no way to be absolutely sure the issue won't come back, even if hardware gets changed.

And in any event I know how to code and it's an interesting challenge.

Shame Tivo does not make more info more easily available straight from the device.

But, alas: http://developer.tivo.com/forum/read/159982


----------



## JamesBritt (Sep 17, 2014)

telemark said:


> "Expect" can be used to automate telnet.


I'm using Ruby. It will be tied in to a larger script to do things like text me on errors.



telemark said:


> I agree you'd rather get the signal issue fixed. If it's the TA being flaky, put it on a reboot timer.


I've thought about that but I've had the problem reappear a few days after a TA reboot so there's no provable length of time that a reboot will forestall problems.

That said, if I had automatic reboots (perhaps overnight) it might lower the number of occurrences, but it's not a sure fix. I'd also have to be sure to disable the timer when there are overnight events to be recorded.

There are other things that could cause a failed recording. Local street work might nick a cable and screw up the signal.

Tivo lacks any good means of indicating that something has failed, at the time of the failure. It has a network connection; it could send email or SMS. Or blink the front lights. But as it is you have t notice something missing from your list of recordings, or check the To Do history.

I'm looking at some way to check recording conditions automatically.



telemark said:


> Is this channel on SDV? What is the signal strength reading the Tivo reports?


Right now the box is recording three shows. Two of them off the same tennis channel (I pad the recording time for sports events, so there's often overlap), which is SDV.

Signal strength on all three of these channels are 87% to 90%. S/N is around 35dB or 36dB.

I have signal booster attached. It's reduced the occurrences. I was actually surprised when it happened last month. Now it's occurred again. This particular channel is part of an add-on package, so it may be something goofy with how Cox does authorization.

I should set up another brief, repeating, recording on a different SDV channel to see if fails the same way.

It's odd. I had a test recording set for 6:30am today. It failed with "Not authorized." But other shows a few hours later in the day recorded fine, with no intervention on my part.


----------



## lpwcomp (May 6, 2002)

Exactly what information are you looking for that _*isn't*_ available directly from the TiVo?


----------



## JamesBritt (Sep 17, 2014)

lpwcomp said:


> Exactly what information are you looking for that _*isn't*_ available directly from the TiVo?


I'm looking to see how to do a timed manual recording via telnet. I want to do this via an automated script. If the script detects that the recording failed then it will send me an alert.

More broadly, I want an automated way to know as soon as possible if any given recording has failed (for whatever reason) or if tuning to, or recording from, any given channel is not possible (for whatever reason).

All sorts of information is available from Tivo (either viewing the tv screen directly or going to a Web page) but getting to it in an automated and unsupervised way is difficult.


----------



## telemark (Nov 12, 2013)

This is easy to do using the TivoToGo html or xml page.

One view has the most recent recordings on top. One field is the current byte count and another is time length. These get updated periodically while it's recording. There's also a "Recording" indicator.

Gross errors should be clear from monitoring one or all of these fields.

I have a toolkit for for TivoToGo automation, but it's Linux and Mac only. It's not hard to build yourself in your preferred language though.


----------



## JamesBritt (Sep 17, 2014)

telemark said:


> This is easy to do using the TivoToGo html or xml page.
> 
> One view has the most recent recordings on top. One field is the current byte count and another is time length. These get updated periodically while it's recording. There's also a "Recording" indicator.
> 
> ...


What are the URLs for these pages? Do they show when a planned recording has failed or is missing? (I went Googling for info on TivoToGo but found nothing that explained it well.)

I can get the list of recorded shows from the Tivo built-in Web server. What's also needed is a list of what *should* be recorded, in order to know what may have failed.

(I do have a script that looks at the Now Playing page and alerts me if any recordings have suspiciously small file sizes. Decent for when an in-progress recording losses signal, but useless for missed recordings.)

I've looked at http://online.tivo.com/start#myshows and parsing it is doable but tedious.

And that needs to be checked against the To Do list. That's also available at http://online.tivo.com/start#todolist with the same less-than-ideal HTML. It has the benefit of prefixing manaul recordings with "Manual" (unlike the Now Playing page served from the tivo box.)

And none of this helps me test the tuning or recording ability of any given channel at arbitrary times (one of the motivations for wanting to do brief manual recordings via telnet). Having that would make it easier to detect issue before other recordings are lost.


----------



## telemark (Nov 12, 2013)

JamesBritt said:


> I can get the list of recorded shows from the Tivo built-in Web server. What's also needed is a list of what *should* be recorded, in order to know what may have failed.
> 
> (I do have a script that looks at the Now Playing page and alerts me if any recordings have suspiciously small file sizes. Decent for when an in-progress recording losses signal, but useless for missed recordings.)


I meant this. The internal TivoToGo webserver's NowPlaying list. There's an HTML view and XML view with more fields.



> And that needs to be checked against the To Do list. That's also available at http://online.tivo.com/start#todolist with the same less-than-ideal HTML. It has the benefit of prefixing manaul recordings with "Manual" (unlike the Now Playing page served from the tivo box.)


There is a ToDo List available from another API that KMTTG uses. Should be easy to parse but not easy to access unless you script KMTTG.



> And none of this helps me test the tuning or recording ability of any given channel at arbitrary times (one of the motivations for wanting to do brief manual recordings via telnet). Having that would make it easier to detect issue before other recordings are lost.


I have to agree with lpwcomp. If you want a proactive system, set a recurring recording timer on the Tivo. Say 10minutes, twice a day. Either check it's reported time length is correct or Transfer it off with TivoToGo. Verify the video's complete.


----------



## JamesBritt (Sep 17, 2014)

telemark said:


> I meant this. The internal TivoToGo webserver's NowPlaying list. There's an HTML view and XML view with more fields.


Ah. Googled for the XML details; that's easier to parse than the HTML (though that's a nut I already cracked). However, the ShowingStartTime field is handy (if I can decode the hex value).



telemark said:


> There is a ToDo List available from another API that KMTTG uses. Should be easy to parse but not easy to access unless you script KMTTG.


I can get the ToDo list from the public Tivo online page now. But I may dig into KMTTG to see what it's doing. Thank you.

The fixed-timed manual recording is a useful stop-gap that I will employ while I sort out a way to verify every expected recording.

I called Cox, one CSR said she had now just pushed something to my TA, and a tech is coming to check things out.

I appreciate the help everyone has offered.


----------



## telemark (Nov 12, 2013)

JamesBritt said:


> However, the ShowingStartTime field is handy (if I can decode the hex value).


I forget but it was something like seconds or milliseconds since the UNIX epoch, in hex instead of decimal.

There's some code in my repo:
https://github.com/marked/kist/blob/master/docroot/html/date.js


----------



## lpwcomp (May 6, 2002)

telemark said:


> I forget but it was something like seconds or milliseconds since the UNIX epoch, in hex instead of decimal.
> 
> There's some code in my repo:
> https://github.com/marked/kist/blob/master/docroot/html/date.js


It's the hex representation of a Unix timestamp. Be aware that it is also GMT a.k.a. "Zulu" time.


----------



## JamesBritt (Sep 17, 2014)

Took a look at KMTTG (pretty sure telnet is a dead-end for my ambitions).

It uses the MindRPC protocol (I think this is also referred to as the "iPad Interface").

If one day I am really ambitious I might see if individual java classes can be used in JRuby as part of a custom program.

In the meantime there's a workaround for getting JSON data from KMTTG.

The KMTTG provides a Web server (if you turn that on in the config).

You can then go to localhost:8181 and follow a few links for things like My Shows, To Do, device info.

Some of these pages have a drop-down list for you to pick what device to query. Even if you have but one device nothing is set as a default. You have to select one.This makes using something like curl or wget a problem.

But the pages are built using JSON; when you select a device from the list and click Refresh it makes a background request to get a chunk of data for that device.

That's something you can do using wget or curl (for example). You need to pass along the name of tivo device

http://127.0.0.1:8181/getToDo?tivo=Roamio

http://127.0.0.1:8181/getMyShows?tivo=Roamio

I happened to have configured my device with that name.

The JSON URLs are defined in the file kmttgServer.java (if you grab the source code).

As with the TivoToGo XML, the time appears to be UTC.


----------



## JamesBritt (Sep 17, 2014)

I have in place a system that uses kmttg to grab json-formatted data from my local Tivo box. It polls the Tivo box every 30 minutes and does a few operations.

It manages a historical To Do list and uses that to see items that had been scheduled to record have in fact been recorded (or are currently being recorded) . It checks the recorded duration as reported by tivo against the expected duration. 

It sends a status message on each poll, indicating what's OK and what (if anything) is amiss.

It works quite well, but today I discovered that tivo will report a program as recording when in fact that is not the case.

I went to watch a program that was still being recorded. The red light was on, Tivo indicated the show was being recorded, looking at he list of shows indicated it was recording, but when i went to watch it there was nothing. A black screen and no green bar.

I went to live TV and tuned in the show. I got a message that the channel was not available. I did the up/down channel thing and it appeared. I could even jump back in time (though not all the way back to when the show started).

I stopped the failed recording, and then from live TV had tivo record that channel. Even though I could get the signal, Tivo again quietly failed while falsly indicating that the channel was recording. Only by trying to watch that new recording in progress could I tell it wasn't actually recording.

I left that recording to go, and set up a manual recording for the same channel. *That* worked. The other recording never recorded anything.

There was nothing in the History list indicating any trouble.

I went through the channel signal pages and the signals seemed fine. (I took pictures and may go through them again.)

The upshot to all this is that there seems to be no way to detect when Tivo is failing to record short of physically trying to watch a recording.

I had a failed recording alert from my script the other day. It wasn't until the program had completed that Tivo reported the actual recording duration(8 seconds, plainly borked). 

All while it was supposed to be recording, queries to the Tivo box reported the a duration that suggested it was correctly recording the show.

I now have no idea how to programmatically check for Tivo errors at the time they are occurring. The only way to know Tivo is failing is to be at the TV manually inspecting each recording.


UPDATE: Had a show fail to record again. While the Tivo was pretending to record, the KMTTG GUI reported the duration as 0:00 and the Mbps as "Infinity".

There are data in the json feed that will indicate a recording issue. The ratio of duration to size should be around 2000. When a show is failing to record (despite Tivo show the red circle, etc) reported duration will change but the size will not. If you periodically check these values and compute the ratio you should be able to tell when a show is not actually getting recorded to disk.


----------

