ATV XML API/Info - where to find?

I've been trying to play around with some of the xml templates to add input fields, but i'm completely stumped. I mean, worse case scenario, I over-ride the element, but there has to be a better way.

 

Has anyone found any kind of API or syntax list for the xml? I know I'm grasping here, but it's worth a try..

 

Thanks in advance.

There is no api documentation as such, if you have a jailbroken atv you can extract the xml schema file which will give a list of all the xml keys and attributes that are available. There is a ftp site with a ton of xml samples. ftp://209.222.29.73/apple/sample-xml/

roidy: that is an awesome resource. Thanks for sharing!

I found similar code on that previous google code repo and managed to implement dialog and input routines into my plexconnect code.

Has anyone considered using a function like this:

atv.showDialog = function(message, description)
{
    var dialogXML = '<?xml version="1.0" encoding="UTF-8"?> \
    \
    \
    \
    \
    \
    \
    \
    ';

    atv.loadXML(atv.parseXML(dialogXML));
};

var methods = [];
for (var m in atv)
{
    if (typeof obj[m] == "function")  //might even want to comment this out so we get all the objects, not just functions!
    {
        methods.push(m);
    }
}
//put the info on screen
atv.showDialog("Debug", methods.join(","));


 

Depending on the implementation, this might give us insight into all the function names within the javascript atv object. After that, we just pass atv.functionname to whatever alert/dialog code we have and unless it's a native method, it should give us some code/understanding.

I was going to look into this at some point this weekend, but it's worth checking if it's been done by someone else at this point. If all we'll get is a list of "object not found" or native code, or something that the ATV won't even run, it's worth knowing if someone else tried first.

Edited twice because I'm apparently too stupid to make the code block work right.

Yep, already done that, these are the js functions I found:-

ATVLogger : atv.savedCredentials
ATVLogger : atv.uuid
ATVLogger : atv.localStorage
ATVLogger : atv.crypto
ATVLogger : atv.device
ATVLogger : atv.Document
ATVLogger : atv.View
ATVLogger : atv.sessionStorage
ATVLogger : atv.Node
ATVLogger : atv.TextView
ATVLogger : atv.slideShow
ATVLogger : atv.SKPaymentTransactionStatePurchasing
ATVLogger : atv.ImageView
ATVLogger : atv.Element
ATVLogger : atv.unloadPage
ATVLogger : atv.isITunesAuthenticated
ATVLogger : atv.SKErrorPaymentInvalid
ATVLogger : atv.localtime
ATVLogger : atv.clearTimeout
ATVLogger : atv.NSLocaleQuotationBeginDelimiterKey
ATVLogger : atv.SKPaymentTransactionStatePurchased
ATVLogger : atv.ProxyDocument
ATVLogger : atv.SKErrorUnknown
ATVLogger : atv.logout
ATVLogger : atv.SKPaymentTransactionStateFailed
ATVLogger : atv.loadURL
ATVLogger : atv._debugDumpControllerStack
ATVLogger : atv.NSLocaleVariantCode
ATVLogger : atv.loadAndSwapXML
ATVLogger : atv.NSLocaleCurrencyCode
ATVLogger : atv.PINEntry
ATVLogger : atv.parseXML
ATVLogger : atv.SKPaymentTransactionStateRestored
ATVLogger : atv.setTimeout
ATVLogger : atv.NSLocaleLanguageCode
ATVLogger : atv.DOMView
ATVLogger : atv.SKErrorPaymentCancelled
ATVLogger : atv.NSLocaleMeasurementSystem
ATVLogger : atv.NSLocaleAlternateQuotationEndDelimiterKey
ATVLogger : atv.setScreensaverPhotosCollection
ATVLogger : atv.TextEntry
ATVLogger : atv.NSLocaleExemplarCharacterSet
ATVLogger : atv.loadAndSwapURL
ATVLogger : atv.RatingControl
ATVLogger : atv.NSLocaleCountryCode
ATVLogger : atv.showMoreInfo
ATVLogger : atv.NSLocaleDecimalSeparator
ATVLogger : atv.loadPlist
ATVLogger : atv.SKErrorClientInvalid
ATVLogger : atv.NSLocaleCollationIdentifier
ATVLogger : atv.parsePlist
ATVLogger : atv.loadAndSwapPlist
ATVLogger : atv.NSLocaleScriptCode
ATVLogger : atv.clearInterval
ATVLogger : atv.NSLocaleAlternateQuotationBeginDelimiterKey
ATVLogger : atv.setInterval
ATVLogger : atv.SKPaymentTransactionStatePurchasing
ATVLogger : atv.NSLocaleCalendar
ATVLogger : atv.SKProductsRequest
ATVLogger : atv.FullScreenMediaBrowser
ATVLogger : atv.NSLocaleGroupingSeparator
ATVLogger : atv.NSLocaleCurrencySymbol
ATVLogger : atv.NSLocaleCollatorIdentifier
ATVLogger : atv.NSLocaleIdentifier
ATVLogger : atv.exitApp
ATVLogger : atv.SKDefaultPaymentQueue
ATVLogger : atv.loadXML
ATVLogger : atv.SKErrorPaymentNotAllowed
ATVLogger : atv.exitApp
ATVLogger : atv.config
ATVLogger : atv.NSLocaleUsesMetricSystem
ATVLogger : atv.NSLocaleQuotationEndDelimiterKey

That's awesome.

I'm nowhere near an ATV right now, but I'm psyched. I have to ask - have you been able to pull out any code from those functions?

If I load a page in a browser on my pc - something like google.com and then type javascript:alert(window.alert) after the page load, I get a javascript alert window that says

"function alert() { [native code] }" - Obviously, this is useless.

If I do the same thing with javascript:alert(userdefinedobject.function), the alert typically just fires the entire source code back to you. This is extremely useful.

The third option is that the alert replies with [object] (or some variant) - in which case we re-run the code from the last post and replace the atv object with the child object (atv.TextEntry would be good)

So my question of the day is whether the atv object's children are native objects or not. (though the fact that you can list them is encouraging - you can't pull that off with the "Math" object, for example)

I can test when I get home, but if you've got an ATV handy, you might be able to solve this sooner than I can.

I’ve tried searching deeper into a few of the functions but It never returns anything :frowning:
 

for (var i in atv.TextEntry)
{
log(i);
}
No… wait I’ve found one that works:-
for (var i in atv.device)
{
log(“atv.device.” + i);
}
Returns:-
ATVLogger: atv.device.preferredVideoPreviewFormat
ATVLogger: atv.device.language
ATVLogger: atv.device.udid
ATVLogger: atv.device.softwareVersion
ATVLogger: atv.device.preferredVideoFormat
ATVLogger: atv.device.screenFrame
ATVLogger: atv.device.isInRetailDemoMode
ATVLogger: atv.device.displayName

I wonder if something like this would get us anywhere... (typed by hand, I can't test this from here and it's incomplete)

function parseObject(var o)
{
    var retVal = "";
    for (var m in o)
    {
 if (typeof obj[m] == "function")
 {
     //maybe try to show it?
     atv.showDialog("function", obj[m])
     retVal += "function: " + m
        }
 if (typeof obj[m] == "boolean")
 {
  ...
 }
 else
    retVal += parseObject(obj[m])
    }
    return retVal;
}

Syntax could be (and probably is) completely out to lunch, but you get the idea.

Hell, now that I better see how your logger implementation works, you could adapt that to just log (typeof obj[m] + ":" + m)

I've tried searching deeper into a few of the functions but It never returns anything :(
 

for (var i in atv.TextEntry)
{
  log(i);
}
No... wait I've found one that works:-
for (var i in atv.device)
{
  log("atv.device." + i);
}
Returns:-
ATVLogger: atv.device.preferredVideoPreviewFormat
ATVLogger: atv.device.language
ATVLogger: atv.device.udid
ATVLogger: atv.device.softwareVersion
ATVLogger: atv.device.preferredVideoFormat
ATVLogger: atv.device.screenFrame
ATVLogger: atv.device.isInRetailDemoMode
ATVLogger: atv.device.displayName

I'm just grasping here, but have you tried:

1:

for (var i in obj[atv.TextEntry]) { log(i); }

2:

for (var i in atv.TextEntry()) { log(i); }

 

3:

var test = new atv.TextEntry();

for (var i in test) { log(i); }

Edit: The more I think about it, perhaps 3 is the ticket - maybe it's not returning anything because the object hasn't been created... Ah well. I hope you make out well, but not too well, I kind of want to play with this when I get home.

None of those 3 work :frowning: Number 1 wont work as obj is undefined. I’ll leave it for you to play around with :slight_smile: good luck and have fun.

obj is undefined?

I'm taking standard implementations for granted, I guess.

Thanks for testing those out - I'll work on it this evening and report findings back (if there's anything worth reporting...)

I found this online - not sure if linking is ok, so i'll post the snippet here but will supply credit where it's due if that's ok. I'll try a variation of this tonight:

The issue is that properties can be set to non-enumerable, but this works around that. I'm not sure if it's implemented on the ATV, BUT this code was confirmed tested in Safari, so that's something (or not...)

function getAllPropertyNames( obj )

{

    var props = [];

    do

    {

        Object.getOwnPropertyNames( obj ).forEach(function ( prop )

        {

            if ( props.indexOf( prop ) === -1 )

            {

                props.push( prop ); // replace with log ( prop )?

            }

        });

    }

    while ( obj = Object.getPrototypeOf( obj ) );

    return props; //remove if log ( prop )?

};

No clue if this will have us gain anything, but it seems interesting.

Sad news to report.

I finally got it. atv.TextEntry.prototype.show

18:53:34 ATVLogger: function show() {
    [native code]
}

No reverse engineering this way :(

Alright, well, I've taken it about as far as I can.

http://pastebin.com/x4eZDYM7

That's a list of all the atv methods and properties I could ■■■■■■ from the code. Some of the objects aren't exposed at all.

Every one of the functions exported as native code, so we haven't learned anything new - except for the existence of some new stuff.

I hope someone wiser than me can pick this up and run.

On Apple TV 4:

atv.device.preferredVideoPreviewFormat
atv.device.storeFrontCountryCode
atv.device.language
atv.device.idForVendor
atv.device.udid
atv.device.screenFrame
atv.device.preferredVideoFormat
atv.device.isInRetailDemoMode
atv.device.displayName
atv.device.softwareVersion

But, atv.device.udid is empty. Any ideas?

UDID is retired by Apple, as it was a way to exactly track your one unique device. It has basically replaced by IdForVendor and/or IdForAdvertiser.
Google finds a lot about this - eg. https://possiblemobile.com/2013/04/unique-identifiers/

baa, Thanks already solved my problem using idForVendor