# Accessing System Settings in HTML5 App



## Riley Newson (May 9, 2019)

I'm wondering if there's an easy solution to accessing system settings through an HTML5 App on TiVo 4, 5, 6 boxes. I'm not finding any reference online to accessing these values.

Basically, I'm trying to see in our HTML5 app if the user has CC/Subtitles Enabled/Disabled on a system level.

Any information on where to find this would be gratefully appreciated.

Thanks


----------



## davidblackledge (Sep 9, 2008)

I wouldn't expect it's possible. 

HME provides a lot of system information on startup, but even that doesn't include CC or Zoom settings. (there is a newer Event 10 that nobody knows how to decode that might have more info like Kidzone on/off or something)

HTML5, on the other hand, doesn't even provide the TSN number of the TiVo to identify the device uniquely.

It's just a web page running on a slightly customized browser, so the only information you have is the usual browser javascript variables, Cookies you set yourself, Headers, and url parameters.

Headers are enough to get the model number prefix, but not the full TSN, and that's all I've found aside from checking the browser version (from which you can infer which subset of models this is).
I think there was one other vaguely interesting header, but nothing as interesting as system settings.

I don't think I made an exhaustive search of javascript variables, but I wouldn't be optimistic you'd find anything tivo-specific. That's your best bet, however. Let us know if you find anything!

Existing HTML5 apps appear to just have their own CC status and store it themselves (on server or in a cookie).


----------



## Riley Newson (May 9, 2019)

Thanks for the information!

Any idea on debugging HTML5 app directly on TiVo box? I've been looking through documentation on Dragonfly with Opera 12, but this seems to be out-dated information, connecting through url params doesn't seem to be working with the Vewd URL loader like it was supposed to with Telnet URL loading.

I've looked into the Vewd TV Emulator, but that doesn't seem like my best bet for finding system specific javascript objects, as it's only emulating Vewd rather than the TiVo environment.


----------



## davidblackledge (Sep 9, 2008)

Riley Newson said:


> Any idea on debugging HTML5 app directly on TiVo box? I've been looking through documentation on Dragonfly with Opera 12, but this seems to be out-dated information, connecting through url params doesn't seem to be working with the Vewd URL loader like it was supposed to with Telnet URL loading.


Good idea, I see where you're going. I haven't tried it. This is definitely a custom version of Opera, so it could be disabled, or it just takes some more learning in how to use it I guess? Let us know if you get it working, and how!



> I've looked into the Vewd TV Emulator, but that doesn't seem like my best bet for finding system specific javascript objects, as it's only emulating Vewd rather than the TiVo environment.


Ok, thank you for posting this. It started me thinking and have been able to get some more information.

It exposes the full configured list of VK constants (most of which don't apply of course) 
Some VK's on the Roamio and what I called them before (this isn't necessarily going to work on a Mini or Premiere, however):
VK_PLAY_PAUSE is TIVO_SLOW = 463
VK_CLEAR is TIVO_CLEAR = 12
VK_RECORD is TIVO_RECORD = 416
VK_CLEAR_FAVORITE_0 is OPT_TIVO_THUMBS_DOWN = 437
VK_STORE_FAVORITE_0 is OPT_TIVO_THUMBS_UP = 429
VK_INFO is TIVO_INFO = 457

and it has much more interesting objects available from JavaScript on my Roamio:
(this is formatted as 
full.property.context datatype:string_representation
)

No idea how to use these, but they're pretty enticing:

```
window.AudioContext function:[object NJSEPluginObject]
window.CorrelationTimestamp function:[object Object]
window.SpBridge_create function:[object NJSEPluginObject]
window.TiVoAction function:[object NJSEPluginObject]
window.TiVoDevice function:[object NJSEPluginObject]
window.TiVoLineup function:[object NJSEPluginObject]
window.TiVoLocalData function:[object NJSEPluginObject]
window.TiVoLogger function:[object NJSEPluginObject]
window.TiVoMemory function:[object NJSEPluginObject]
window.TiVoParentalControl function:[object NJSEPluginObject]
window.TiVoTuner function:[object NJSEPluginObject]
window.hawaii object:[object NJSEPluginObject]
```
This OIPF (what would that stand for?) stuff looks like maybe an internal use factory for creating relevant objects, but maybe it's meant for direct use?

```
window.oipfObjectFactory.createApplicationManagerObject function:[object createApplicationManagerObject]
window.oipfObjectFactory.createCSManager function:[object createCSManager]
window.oipfObjectFactory.createCapabilitiesObject function:[object createCapabilitiesObject]
window.oipfObjectFactory.createChannelConfig function:[object createChannelConfig]
window.oipfObjectFactory.createConfigurationObject function:[object createConfigurationObject]
window.oipfObjectFactory.createDownloadManagerObject function:[object createDownloadManagerObject]
window.oipfObjectFactory.createDownloadTriggerObject function:[object createDownloadTriggerObject]
window.oipfObjectFactory.createDrmAgentObject function:[object createDrmAgentObject]
window.oipfObjectFactory.createGatewayInfoObject function:[object createGatewayInfoObject]
window.oipfObjectFactory.createMediaSynchroniser function:[object createMediaSynchroniser]
window.oipfObjectFactory.createParentalControlManagerObject function:[object createParentalControlManagerObject]
window.oipfObjectFactory.createRecordingSchedulerObject function:[object createRecordingSchedulerObject]
window.oipfObjectFactory.createSearchManagerObject function:[object createSearchManagerObject]
window.oipfObjectFactory.createVideoBroadcastObject function:[object createVideoBroadcastObject]
window.oipfObjectFactory.createVideoMpegObject function:[object createVideoMpegObject]
window.oipfObjectFactory.debug function:[object debug]
window.oipfObjectFactory.isObjectSupported function:[object isObjectSupported]
```
And the exciting item most likely meant to be used by us, the object "tivo"
Mostly it's a bunch of enumerations and a few functions that likely accept them, and two special objects (trio and mindrpc) that I don't know how to invoke again. 
(any guesses what the sound "TAG_UP" refers to?)
I'm thinking "createClient()" may result in an object with more available methods.

```
window.tivo.core.extend function:function (base, sub)
window.tivo.core.trace function:function (msg)
window.tivo.core.exit function:function ()
window.tivo.core.trio object:[object Object]
window.tivo.core.mindrpc object:[object Object]
window.tivo.client.createClient function:function (props)
window.tivo.client.NetworkInterfaceType.CA_CARD string:ca_card
window.tivo.client.NetworkInterfaceType.DOCSIS string:docsis
window.tivo.client.NetworkInterfaceType.ETHERNET string:ethernet
window.tivo.client.NetworkInterfaceType.EXTERNAL string:external
window.tivo.client.NetworkInterfaceType.MOCA string:moca
window.tivo.client.NetworkInterfaceType.WIRED string:wired
window.tivo.client.NetworkInterfaceType.WIRELESS string:wireless
window.tivo.client.MediaEventType.LOAD number:0
window.tivo.client.MediaEventType.PLAY number:1
window.tivo.client.MediaEventType.PAUSE number:2
window.tivo.client.MediaEventType.SEEK number:3
window.tivo.client.MediaEventType.ENDED number:4
window.tivo.client.ShowcaseActionType.RFI number:0
window.tivo.client.ShowcaseActionType.SCROLLSH number:1
window.tivo.client.LeadGenMenuActionType.MENU_ACTION_SUBMIT number:1
window.tivo.client.LeadGenMenuActionType.MENU_ACTION_CANCEL number:2
window.tivo.client.LeadGenMenuActionType.MENU_ACTION_INFO number:3
window.tivo.client.PinType.PARENTAL_CONTROL string:parental
window.tivo.client.PinType.PURCHASE_CONTROL string:purchase
window.tivo.client.TiVoSound.ALERT number:1
window.tivo.client.TiVoSound.BONK number:2
window.tivo.client.TiVoSound.DESELECT number:3
window.tivo.client.TiVoSound.ERROR number:4
window.tivo.client.TiVoSound.LEFT number:5
window.tivo.client.TiVoSound.PAGE_DOWN number:6
window.tivo.client.TiVoSound.PAGE_UP number:7
window.tivo.client.TiVoSound.RIGHT number:8
window.tivo.client.TiVoSound.SELECT number:9
window.tivo.client.TiVoSound.SHOWCASE_ENTER number:10
window.tivo.client.TiVoSound.SHOWCASE_EXIT number:11
window.tivo.client.TiVoSound.SIGNAL_TONE number:12
window.tivo.client.TiVoSound.SLOW_DOWN_1 number:13
window.tivo.client.TiVoSound.SPEED_UP_1 number:14
window.tivo.client.TiVoSound.SPEED_UP_2 number:15
window.tivo.client.TiVoSound.SPEED_UP_3 number:16
window.tivo.client.TiVoSound.SPEED_UP_4 number:17
window.tivo.client.TiVoSound.TAG_UP number:18
window.tivo.client.TiVoSound.THUMBS_DOWN number:19
window.tivo.client.TiVoSound.THUMBS_UP number:20
window.tivo.client.TiVoSound.TIVO number:21
window.tivo.client.TiVoSound.UP_DOWN number:22
window.tivo.client.NodeGroupType.TSID number:1
window.tivo.client.NodeGroupType.TSID_LIST number:2
window.tivo.client.NodeGroupType.SERVICE_GROUP number:3
window.tivo.client.VodProvider.VIRGIN number:1
window.tivo.client.VodProvider.ONO number:2
window.tivo.client.VodProvider.MAGNUM_OPUS number:3
window.tivo.client.ViewBroadcast function:function ViewBroadcast()
window.tivo.client.ViewOnDemand function:function ViewOnDemand()
window.tivo.client.ViewStartEvent function:function ViewStartEvent(programPosition, what)
window.tivo.client.ViewStopEvent function:function ViewStopEvent(programPosition, source)
window.tivo.client.ViewStateEvent function:function ViewStateEvent(programPosition)
window.tivo.client.ViewSource.IN_HOME_RECORDING number:1
window.tivo.client.ViewSource.LIVE_TV number:2
window.tivo.client.ViewSource.LOCAL_RECORDING number:3
window.tivo.client.ViewSource.ON_DEMAND number:4
window.tivo.client.ViewSource.REMOTE_RECORDING number:5
window.tivo.client.ViewSource.IN_HOME_LIVE_TV number:6
window.tivo.client.ViewSource.REMOTE_LIVE_TV number:7
```
I haven't gotten the equivalent data from my Mini... my script isn't working there yet, but I thought I'd post what I have so far (it's likely the VK's are a little different at least).

This is all just some small effort based on the javascript equivalent of introspection (you can loop over object property string names, then access a property by string name).

I still think you won't get CC mode info, but this is more than I knew was available before!


----------



## Allanon (Nov 2, 2005)

davidblackledge said:


> This OIPF (what would that stand for?) stuff looks like maybe an internal use factory for creating relevant objects, but maybe it's meant for direct use?


Did a google search for *oipfObjectFactory *and found this:
OIPF - Release 2 Specification - Volume 5, Declarative Application Environment, V2.3

Some of the methods are mentioned in the spec.


----------



## Allanon (Nov 2, 2005)

Also check this out:

Play TiVo library sound on KEY press of Remote control

Get TiVo STB Box details using TiVo library functions

Debugging TiVo application using Opera Dragonfly


----------



## Dan203 (Apr 17, 2000)

You could also use some sort of proxy software on a PC to access the mind/RPC interface. (Like kmttg does)


----------



## davidblackledge (Sep 9, 2008)

Dan203 said:


> You could also use some sort of proxy software on a PC to access the mind/RPC interface. (Like kmttg does)


Oddly enough, even that won't give you CC system status, as I recall.

I believe the remote apps that perform CC toggle just assume a starting state and track how many times you pressed it when toggling.


----------



## Allanon (Nov 2, 2005)

Riley Newson said:


> Any idea on debugging HTML5 app directly on TiVo box?


I recently started messing with a Tivo HTML5 app and also found it hard to debug. What I did was create a simple HTTP server in Python and I use the Vewd URL Loader to connect to the server. The server sends the app's code when it receives a GET message and prints the contents of a POST message to the console of the Python IDE where I edit the code. I also created a function in Javascript that allow me to easily POST debug messages back to the server. This works great for sending information back to my computer but it's still a pain if I make a syntax error but using the following Javascript code which posts error messages makes it a little easier:


```
function post(message) {
   var xhr = new XMLHttpRequest();
   xhr.open("POST", 'http://192.168.1.122:7001', true);
   xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   xhr.send(message);
}

window.onerror = function(message, source, lineno, colno, error) {
    post(message +'\nline number:  ' + lineno + '\ncolumn number: ' + colno + '\n' + error);
}
```


----------



## davidblackledge (Sep 9, 2008)

Allanon said:


> I recently started messing with a Tivo HTML5 app and also found it hard to debug. What I did was create a simple HTTP server in Python and I use the Vewd URL Loader to connect to the server. The server sends the app's code when it receives a GET message and prints the contents of a POST message to the console of the Python IDE where I edit the code. I also created a function in Javascript that allow me to easily POST debug messages back to the server. This works great for sending information back to my computer but it's still a pain if I make a syntax error but using the following Javascript code which posts error messages makes it a little easier


Nice!
My lazy-setup version I've been using is to test my html files with KMTTG's webserver, and debug on-screen in the page.

I put my files in a folder under kmttg's "web" folder.
I launch the files with a URL like the following typed into my computer's browser:

```
http://192.168.0.37:8181/rpc?tivo=Family+Room&operation=Navigate&json=%7B%22uri%22:%22x-tivo:web:http:%5c/%5c/192.168.0.37:8181%5c/web%5c/tivo%5c/%22%7D
```
 note the %5c to escape in front of each "/" in the URL.
And I show errors on the tivo by including the following on the html file:

```
window.onerror = function(msg, url, linenumber) {
    var text = 'Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber;

    // show the error in a self-hiding div.
   var d = document.createElement('DIV');
   d.innerHTML = text;
   d.id="onerrordisplay";
   d.style="position:absolute;top:50px;left:50px;"+
   "width:75%;height:75%;"+
   "font-family: monospace;white-space: pre-wrap;"+
   "background:black;color:white;font-size:20pt;"
   document.body.appendChild(d);
   
   setTimeout(function(){document.getElementById("onerrordisplay").remove()},5000);
   
    return true;
}
```


----------

