Your Digital Media Has Never Looked So Good

 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Getting channel's ID, how? [answer: roAppInfo.getID()]

Mon Aug 10, 2015 3:00 am

I wonder how a program running on Roku can figure out its channel ID? The (mostly) numeric ID that's used to /launch or /input to.

There are situations that can be useful, one is for a shared/library code between different channels. Another one i have at hand is, say i have two of the same channels - one with ID "12345", the other one "23456". 12345 is a beta, 23456 is a release - they are exactly the same as code base and even use the same registry but need to act a hair differently - say one shows a "beta" placard. So if when started, the code can check "who am i?" - then it can implement that local difference based on hearing back the ID.

Seems to me appropriate place for this is a method (getSelfID? getAppID?) in roDeviceInfo but nothing related i can find so far.
Last edited by EnTerr on Mon Aug 10, 2015 9:50 am, edited 1 time in total.
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Getting channel's ID, how?

Mon Aug 10, 2015 9:24 am

is roAppInfo's GetID() not what your looking for?
FlixRaider channel
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Getting channel's ID, how?

Mon Aug 10, 2015 9:53 am

Why yes - yes, it is!

It's a... it's a <cough> new API :oops:

thank you
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Getting channel's ID, how? [answer: roAppInfo.getID()]

Wed Aug 12, 2015 2:27 pm

Even though I answered that question I never actually thought of doing that till you asked, now my statistics dashboard can distinguish between dev (sideloaded), testing, and production. Realized that once we got published knowing if I'm seeing a pattern or issue in test or in production was a huge need. A case where I really am glad you asked.
FlixRaider channel
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Getting channel's ID, how? [answer: roAppInfo.getID()]

Fri Aug 14, 2015 10:39 am

sjb64 wrote:
Even though I answered that question I never actually thought of doing that till you asked, now my statistics dashboard can distinguish between dev (sideloaded), testing, and production. Realized that once we got published knowing if I'm seeing a pattern or issue in test or in production was a huge need. A case where I really am glad you asked.

"You are welcome!" :mrgreen:
Watch out for my new book "How to Ask the Right Questions (or On Strategic Ignorance)" :lol:

A bit more serious, i call this the Docendo discimus (Latin "by teaching, we learn") effect. At least I find myself understanding things better by answering questions here, StackOverflow etc

Congrats on getting published (8/11), btw!
Ha! 51 channels published on 8/13. FIFTY ONE. In one day. Really?!
I wonder if there is a day (once a month? once a quarter?) when the Co says "oh, f**k it - open the gate, flush the queue, everybody gets a pass"?
 
User avatar
RokuJoel
Posts: 1758
Joined: Mon Nov 14, 2011 5:22 pm

Re: Getting channel's ID, how? [answer: roAppInfo.getID()]

Fri Aug 14, 2015 10:56 am

Just for fun, here's how I did it before getID() was implemented. Anyone writing private channels they want to run on Legacy will still need something like this to get the Channel ID (mIght be some bugs in this code, esp. with regards to handling side-loadedness):

'exerpted from a set of private functions in an AA

    ChannelID:  function () as string
                    'get ip from deviceIP function
                    ip=m.deviceIP()
                    m.ipAddress=ip
                    'read manifest file from local storage               
                    manifest=readAsciiFile("pkg:/manifest")
                   
                    'convert manifest file into array delimited by carriage returns               
                    phase1=manifest.tokenize(chr(10))
                   
                    'iterate through result and find app title
                    for each line in phase1
                        if lcase(line.left(line.instr("=") ) )="title" then
                            apptitle=line.mid(line.instr("=")+1)
                        end if
                    end for
               
                    'to do: handle case if no title field in manifest
     
                    'get list of apps from device ECP                 
                   
                    xfer=createobject("roURLTransfer")
                    xfer.seturl("http://"+ip+":8060/query/apps")
                    data=xfer.gettostring()
                    xml=createobject("roXMLElement")
                    Identity=""
                    if xml.parse(data) then
                        ?"iterate through all apps in list and find one where the title matches manifest title"
                                                   
                        for each entry in xml.app
                            if entry.getText() = apptitle.trim()
                                Identity=entry@id
                                if instr(identity,"_") > 0 then
                                    Identity=left(Identity,instr(Identity,"_")-1)
                                end if
                            end if
                        end for
                       
                        if identity="dev" then
                            ?"ID=DEV"
                            return "00000"
                        else                       
                            if identity=invalid then
                                print "identity is invalid, replacing with 00000"
                                identity="00000"
                            end if
                            if identity="" then
                                print "identity is null string, replacing with 00000"
                                identity="00000"
                            end if
                        end if
                    else
                        ?"got bad xml from device, return null channel id:"
                        return identity
                    end if
                    return identity
                end function

    DeviceIP:   function () as string
                di=createobject("rodeviceinfo")
                temp=di.getipaddrs()
                temp.reset()
                while true
                    aakey=temp.next()
                    if not temp=invalid then
                        return temp[aakey]
                    end if
                end while
    end function 
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Getting channel's ID, how? [answer: roAppInfo.getID()]

Fri Aug 14, 2015 11:11 am

EnTerr wrote:
Congrats on getting published (8/11), btw!
Ha! 51 channels published on 8/13. FIFTY ONE. In one day. Really?!

Thanks, we got to spend like a day and a half visible on the new list. Watching historically I told them it would be a week visible, then 2 to 3 on the list, but seems that changed suddenly just in time for us.

Such is life...

Watching our install counts with no idea what is a good successful number or a rough start, but still fun to watch.
FlixRaider channel
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Getting channel's ID, how? [answer: roAppInfo.getID()]

Fri Aug 14, 2015 11:16 am

RokuJoel wrote:
Just for fun, here's how I did it before getID() was implemented. ...

I like how you parse the manifest for the channel name, so it does not have to be supplied (so potentially can be part of shared library).

I thought about peeking in /query/apps but that wouldn't have helped in my case (or sjb64's), since i could have all 3 installed together - dev, beta and public - all with the same name but different ID. So a search can return the first (or last, or all) ID but not help me know "who am i".
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Getting channel's ID, how? [answer: roAppInfo.getID()]

Fri Aug 14, 2015 11:37 am

RokuJoel wrote:
Just for fun, here's how I did it before getID() was implemented. ...

Makes me realize how easy I've had it having joined the rokudev world well after 3.1 (actually right at 6.1).
FlixRaider channel
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: Getting channel's ID, how? [answer: roAppInfo.getID()]

Fri Aug 14, 2015 12:02 pm

sjb64 wrote:
Thanks, we got to spend like a day and a half visible on the new list. Watching historically I told them it would be a week visible, then 2 to 3 on the list, but seems that changed suddenly just in time for us.

Such is life...

Agreed - does not seem fair getting buried under a 6 screens avalanche just a day or two after debut. Heck, it is unfair even to the bottom half of that truckload of 51. They should spread such "goodness" over longer period, say drip 3 per day for a month.

Watching our install counts with no idea what is a good successful number or a rough start, but still fun to watch.

You got thousands of downloads already - that is (was?) good! I see also floated up a little in "Movies and TV" category, being more fortunate than DirecTV's "Yaveo". Though, i presume the release of Yaveo for Roku will be drummed up soon and shoot way up.

Who is online

Users browsing this forum: No registered users and 12 guests